Scientia sine finibus

Linear Algebra / Unit 1, Vectors / Topic 1.1

Units and Topics

Unit 1. Vectors

1.1 Vectors and Linear Combinations

Linear algebra is the study of vectors and of the rules for combining them. This topic covers what a vector is, how to add two vectors, how to multiply a vector by a number, and what a linear combination is.

You have already used some of this in physics. Adding two forces, or splitting a velocity into a horizontal part and a vertical part, is linear algebra. The same ideas are used in computer graphics, in data science, in engineering, and in quantum mechanics, so the subject is worth learning carefully from the start.

What you need for this topic: algebra and the coordinate plane. Calculus is not used in this topic. It will be used in later topics.

1. What a Vector Is

A vector is a quantity that has a size and a direction. A displacement of 3 meters to the east is a vector. A temperature of 20 degrees is not a vector, because a temperature has no direction. A quantity that has only a size is called a scalar.

There are two ways to describe the same vector.

  • As an arrow. The length of the arrow is the size of the vector, and the arrow points in the direction of the vector.
  • As a list of numbers. Place the tail of the arrow at the origin. The coordinates of the tip are called the components of the vector.

The vector that goes 3 units to the right and 2 units up is written as a column, with the horizontal component on top:

v = 32

In print, a vector is written with a bold letter, such as v. By hand, write the letter with a small arrow above it. To save space in a sentence, the same vector is also written as (3, 2).

An arrow does not have to start at the origin. An arrow from (1, 1) to (4, 3) and an arrow from (0, 0) to (3, 2) are the same vector, because both arrows go 3 units to the right and 2 units up. A vector records a change in position. It does not record a location.

To find the components of an arrow, subtract the coordinates of the tail from the coordinates of the tip. For the arrow from (1, 1) to (4, 3):

first component = 4 − 1 = 3the horizontal coordinates, tip minus tailsecond component = 3 − 1 = 2the vertical coordinates, tip minus tail

2. Adding Two Vectors

To add two vectors with arrows, place the tail of the second arrow at the tip of the first arrow. The sum is the arrow from the tail of the first arrow to the tip of the second arrow. This is called the tip-to-tail method.

To add two vectors with numbers, add the matching components.

31 + 12 = 3 + 11 + 2add the first components, and add the second components31 + 12 = 43the sum

The two methods always agree. Walking 3 to the right and 1 up, and then 1 to the right and 2 up, is the same as walking 4 to the right and 3 up.

Try it: adding two vectors

Drag the tip of the blue arrow or the tip of the red arrow. The green arrow is the sum.

Turn on “Show the other order” in the drawing. Adding the red vector first and the blue vector second ends at the same point. The order of addition does not change the sum:

u + v = v + u

The two orders together make a parallelogram, and the sum is its diagonal.

3. Multiplying a Vector by a Number

Multiplying a vector by a number changes its length. Multiplying by 2 makes the arrow twice as long in the same direction. Multiplying by one half makes the arrow half as long. Multiplying by a negative number also reverses the direction of the arrow.

With numbers, multiply each component by the number.

2 21 = 42−1 21 = −2−1

The number is called a scalar, because it scales the vector. The operation is called scalar multiplication.

Try it: scaling a vector

Move the slider to change the scalar c. You can also drag the tip of the blue arrow.

All of the multiples of one vector lie on a single line through the origin. A scalar can make the arrow longer, shorter, or reversed, but it cannot turn the arrow off that line.

Subtraction does not need a new rule. To subtract v, add −1 times v:

u − v = u + (−1)v

4. Linear Combinations

The two operations can be used together. Take two vectors v and w, multiply each one by a scalar, and add the results:

av + bw

This expression is called a linear combination of v and w. The scalars a and b are called the coefficients.

For example, with v = (2, 1) and w = (−1, 1), the linear combination with a = 3 and b = 2 is

3v + 2w = 3 21 + 2 −11the two vectors with their scalars3v + 2w = 63 + −22multiply each vector by its scalar3v + 2w = 45add the two vectors

Try it: linear combinations

Move the sliders to change a and b. Try to make the green arrow end on the purple target. You can also drag the tips of the thin arrows to change v and w.

The slanted grid in the drawing is made of copies of v and w. The coefficient a counts steps along v, and the coefficient b counts steps along w. In this sense, a and b are coordinates on the slanted grid.

The ordinary components of a vector are the same idea. Let i = (1, 0) be one step to the right, and let j = (0, 1) be one step up. Then

32 = 3 10 + 2 01 = 3i + 2j

The components 3 and 2 are the coefficients of a linear combination of i and j. You have used this in physics each time you wrote a force as a horizontal part plus a vertical part.

Finding the coefficients

Suppose the target is given and the coefficients are not. Find a and b so that

a 21 + b −11 = 45

The top components must match, and the bottom components must match. This gives two equations:

2a − b = 4the top componentsa + b = 5the bottom components3a = 9add the two equationsa = 3divide both sides by 3b = 5 − 3 = 2substitute a = 3 into the second equation

This is the same answer as in the example above.

A question about a linear combination is a system of linear equations, and a system of linear equations is a question about a linear combination. This connection is used in almost all of the topics that follow.

5. Span

The set of all the linear combinations of v and w is called the span of v and w. The span is the set of all the points that can be reached by using only these two vectors.

In the plane there are two main cases.

  • If v and w point along different lines, their span is the whole plane. Any target can be reached, and there is exactly one pair of coefficients for each target.
  • If v and w point along the same line, their span is only that line. The second vector does not add a new direction, so a target that is off the line cannot be reached.

Press “Make w parallel to v” in the drawing above and move the sliders. The green arrow stays on one line for all values of a and b. If the target is not on that line, no choice of a and b reaches it.

There is also a third case. If both vectors are the zero vector (0, 0), the span is only the origin.

Common Mistakes

  • Adding the lengths. The length of a sum is usually not the sum of the lengths. A displacement of 3 meters east followed by 4 meters north has a length of 5 meters, not 7 meters. Add the components, and then find the length.
  • Treating a vector as a location. The same vector can be drawn starting from any point. Only the change from tail to tip matters.
  • Subtracting in the wrong order. The components of an arrow are tip minus tail, not tail minus tip.
  • Forgetting that a negative scalar reverses the direction. The vector −2v is twice as long as v and points the opposite way.
  • Assuming that two vectors always reach the whole plane. Two vectors on the same line reach only that line.

Summary

TermMeaning
VectorA quantity with a size and a direction, written as an arrow or as a column of components
ScalarA single number
Vector additionTip to tail with arrows, or component by component with numbers
Scalar multiplicationMultiply each component by the scalar
Linear combinationav + bw, with scalars a and b
SpanThe set of all the linear combinations of the given vectors

Practice

Work each problem on paper first. Then open the answer to check your work.

1. Let u = (2, −1) and v = (1, 3). Calculate u + v and 2u − v. u + v = (2 + 1, −1 + 3)add the matching componentsu + v = (3, 2)2u − v = (4, −2) − (1, 3)multiply u by 22u − v = (3, −5)subtract the matching components
2. An arrow starts at (−2, 1) and ends at (3, 4). Write the components of the vector. first component = 3 − (−2) = 5tip minus tailsecond component = 4 − 1 = 3tip minus tail

The vector is (5, 3).

3. Is (6, −3) a scalar multiple of (−2, 1)?

Yes. Multiplying (−2, 1) by −3 gives (6, −3). The two vectors lie on the same line through the origin and point in opposite directions.

4. Find a and b so that a(1, 2) + b(3, 1) = (5, 5). a + 3b = 5the first components2a + b = 5the second componentsa = 5 − 3bsolve the first equation for a2(5 − 3b) + b = 5substitute into the second equation10 − 5b = 5collect the termsb = 1subtract 10, then divide by −5a = 5 − 3(1) = 2substitute b = 1

Check:

2(1, 2) + 1(3, 1) = (2 + 3, 4 + 1)multiply each vector by its scalar, then add2(1, 2) + 1(3, 1) = (5, 5)the target
5. Can (1, 1) be written as a linear combination of (2, 4) and (1, 2)?

No. The vector (2, 4) is 2 times (1, 2), so the two vectors lie on the same line, y = 2x. All of their linear combinations are on that line. The point (1, 1) is not on that line.

6. A box is pushed with a force of 30 N to the east and a force of 40 N to the north. Write the net force as a vector and calculate its magnitude.

With east as the first component and north as the second component, the net force is (30, 40) N.

The magnitude comes from the Pythagorean theorem: the square root of 30² + 40² is 50 N. The magnitude is not 70 N, because the two forces do not point in the same direction.

Python Practice

This part shows how to do the calculations of this topic with Python. Python is a programming language that is widely used in science and engineering. You do not need to know any programming, and you do not need to install anything, because the code runs on this page.

Work through the steps in order. Each step explains the code before you run it. Press Run to run the code in a box. The result appears in the gray area under the box. Some steps ask you to change the code. Type in the box, press Run again, and the page tells you whether the result is correct. Press Reset to bring back the original code. The first run takes a few seconds, because the page has to load Python.

Step 1. Print a result

Python reads the code one line at a time, from the top to the bottom. The instruction print shows a result. The value to show goes inside the parentheses. The code in the box below adds two numbers and shows the sum. Press Run.

Python

The gray area shows 5. Python uses + for addition, - for subtraction, * for multiplication, and / for division.

Now change the code in the next box so that it prints the product of 7 and 6. Replace the two numbers and the symbol between them. Then press Run.

Python

Step 2. Store a vector under a name

A name can store a value, so that the value can be used again on a later line. The equals sign stores the value on its right under the name on its left. In the code below, the second line stores the vector (2, 1) under the name v, and the third line prints it.

A vector is written as np.array([2, 1]). The components go inside square brackets, with a comma between them, and the square brackets go inside parentheses. The name np stands for NumPy. NumPy is the part of Python that works with vectors and matrices. This page has already loaded it.

A line that starts with # is a comment. Python skips comments. They are notes for the person who reads the code.

Python

Python prints the vector as [2 1], with a space between the components and no comma.

In the next box, change the code so that w is the vector (−1, 1). On a keyboard, type the minus sign with the hyphen key.

Python

Step 3. Add two vectors

When two names store vectors, the + sign adds the vectors component by component, as in Part 2 of this topic.

Python

The result is [1 2].

2 + (−1) = 1the first components1 + 1 = 2the second components

Now change the last line of the next box so that it prints v − w.

Python

Step 4. Multiply a vector by a number

The * sign between a number and a vector multiplies each component by the number, as in Part 3 of this topic.

Python

The result is [6 3]. Now change the code so that it prints −1.5v. Python writes a decimal number with a period, as in 1.5.

Python

Python prints −3 as -3. with a period after it. The period shows that the number is stored as a decimal number. The value is still −3.

Step 5. Calculate a linear combination

The code below calculates the linear combination av + bw from Part 4 of this topic, with a = 3 and b = 2. Each name is stored on its own line, and the last line combines them.

Python

The result is [4 5], which agrees with the example in Part 4.

In the next box, change the values of a and b so that the linear combination is the vector (1, 5). Do not change v or w. You can try different values, or you can write the two equations for a and b and solve them on paper first, as in Part 4.

Python

Quiz

This quiz has 5 questions on this topic. A question asks you either to choose one answer or to type numbers. The page grades your answers and explains each one. A number can be typed as a whole number, a decimal, a fraction such as 1/3, or a calculation such as sqrt(18)/2 or arccos(1/2). The page shows the value of a calculation next to the box. Angles in a calculation are in degrees. The Calculator button under each question opens a calculator. Your answers are saved in your browser, so they are still on the page when you come back to it.

Choose how your answers are checked

1. Let u = (4, −2) and v = (−1, 5). Calculate u + v.

2. An arrow starts at the point (2, −3) and ends at the point (−1, 1). Find the components of the vector.

3. Which of these vectors is a scalar multiple of (3, −6)?

4. Find the coefficients a and b so that a(1, 1) + b(2, −1) = (7, 1).

5. What is the span of the vectors (2, 1) and (−4, −2)?

Next: Topic 1.2, Length and the Dot Product