Linear Algebra / Unit 1, Vectors / Topic 1.1
Unit 1. Vectors
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.
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.
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 = 32In 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 tailTo 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 sumThe 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 + uThe two orders together make a parallelogram, and the sum is its diagonal.
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−1The 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)vThe two operations can be used together. Take two vectors v and w, multiply each one by a scalar, and add the results:
av + bwThis 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 vectorsTry 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 + 2jThe 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.
Suppose the target is given and the coefficients are not. Find a and b so that
a 21 + b −11 = 45The 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 equationThis 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.
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.
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.
| Term | Meaning |
|---|---|
| Vector | A quantity with a size and a direction, written as an arrow or as a column of components |
| Scalar | A single number |
| Vector addition | Tip to tail with arrows, or component by component with numbers |
| Scalar multiplication | Multiply each component by the scalar |
| Linear combination | av + bw, with scalars a and b |
| Span | The set of all the linear combinations of the given vectors |
Work each problem on paper first. Then open the answer to check your work.
The vector is (5, 3).
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.
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 targetNo. 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.
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.
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.
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
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
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 componentsNow change the last line of the next box so that it prints v − w.
Python
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.
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
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.
Add the matching components.4 + (−1) = 3the first components−2 + 5 = 3the second components
2. An arrow starts at the point (2, −3) and ends at the point (−1, 1). Find the components of the vector.
Subtract the tail from the tip.−1 − 2 = −3the first component1 − (−3) = 4the second component
3. Which of these vectors is a scalar multiple of (3, −6)?
Multiplying (3, −6) by −1/3 gives (−1, 2). In each of the other vectors, the two components do not have the ratio 3 to −6.
4. Find the coefficients a and b so that a(1, 1) + b(2, −1) = (7, 1).
a + 2b = 7the first componentsa − b = 1the second components3b = 6subtract the second equation from the firstb = 2divide both sides by 3a = 1 + 2 = 3substitute b = 2 into the second equation3(1, 1) + 2(2, −1) = (7, 1)the check
5. What is the span of the vectors (2, 1) and (−4, −2)?
The vector (−4, −2) is −2 times (2, 1), so both vectors are on one line through the origin. Their linear combinations stay on that line, which is y = x/2.