Linear Algebra / Unit 1, Vectors / Topic 1.4
Unit 1. Vectors
This topic extends vectors to any number of components. A vector with more than three components cannot be drawn as an arrow, but all of the rules from Topics 1.1 and 1.2 still work.
You need Topics 1.1 and 1.2 for this topic.
In Topic 1.1, a vector in the plane was a list of two numbers. In Topic 1.3, a vector in three dimensions was a list of three numbers. A vector can be a list of any number of numbers. A vector with n components is called a vector in n dimensions.
v = (v₁, v₂, …, vₙ)The set of all vectors with n real components is written ℝⁿ. The plane is ℝ², and the space of three dimensions is ℝ³. The vector (1, 2, 0, −1) is in ℝ⁴.
Vectors with many components appear whenever several numbers describe one thing.
A vector in ℝ⁴ or ℝ¹⁰⁰ is not a statement about extra directions in physical space. The word dimension only counts how many numbers are in the list. The algebra does not need a drawing.
The two operations from Topic 1.1 work component by component, for any number of components.
u + v = (u₁ + v₁, u₂ + v₂, …, uₙ + vₙ) cv = (cv₁, cv₂, …, cvₙ)For example, take u = (1, 2, 0, −1) and v = (3, −1, 4, 2) in ℝ⁴.
u + v = (4, 1, 4, 1) 2u = (2, 4, 0, −2) 2u − v = (−1, 5, −4, −4)Two vectors can be added only when they have the same number of components. The sum of a vector in ℝ³ and a vector in ℝ⁴ is not defined.
The zero vector in ℝⁿ has n components, and all of them are 0. A linear combination has the same meaning as before: multiply each vector by a scalar, and add the results.
Try it: vectors as bars
Each vector has five components, and each component is drawn as one bar. Move the sliders to change a and b. The green bars show the linear combination au + bv. Press New vectors for a different pair.
The definitions from Topic 1.2 also extend to n components.
u · v = u₁v₁ + u₂v₂ + … + uₙvₙ |v| = √v · v = √v₁² + v₂² + … + vₙ²For u = (1, 2, 0, −1) and v = (3, −1, 4, 2),
u · v = (1)(3) + (2)(−1) + (0)(4) + (−1)(2)multiply the matching componentsu · v = 3 − 2 + 0 − 2 = −1add the products|u| = √1 + 4 + 0 + 1 = √6 ≈ 2.45the length of u|v| = √9 + 1 + 16 + 4 = √30 ≈ 5.48the length of vIn two and three dimensions, the angle between two vectors can be measured in a drawing. In more dimensions there is no drawing, so the angle is defined by the same equation as in Topic 1.2.
cos θ = (u · v)/(|u| |v|)For the two vectors above:
cos θ = −1/(√6 √30) ≈ −0.075divide the dot product by the two lengthsθ ≈ 94.3°take the inverse cosineThis definition works only if the right side is between −1 and 1, because a cosine cannot be outside that range. A result called the Cauchy-Schwarz inequality guarantees this for any two vectors:
|u · v| ≤ |u| |v|For the example, the left side is 1 and the right side is about 13.4.
Two vectors are called orthogonal when their dot product is 0. In two and three dimensions, orthogonal means the same as perpendicular. For example, (1, 1, 1, 1) and (1, −1, 1, −1) are orthogonal, because 1 − 1 + 1 − 1 = 0. The word orthogonal is used in the rest of the course.
In a drawing, the sum u + v is the third side of a triangle with the sides u and v, and one side of a triangle cannot be longer than the other two sides together. The same statement is true in any number of dimensions:
|u + v| ≤ |u| + |v|For the example:
|u + v| = √16 + 1 + 16 + 1 = √34 ≈ 5.83the length of the sum (4, 1, 4, 1)|u| + |v| ≈ 2.45 + 5.48 = 7.93the sum of the two lengthsThe dot product is useful even when there are no arrows or angles. Suppose that a course grade is 20 percent homework, 30 percent quizzes, and 50 percent tests. Write the weights as the vector w = (0.2, 0.3, 0.5). A student with the scores s = (90, 80, 70) has the course grade
w · s = (0.2)(90) + (0.3)(80) + (0.5)(70)multiply each score by its weightw · s = 18 + 24 + 35the three productsw · s = 77the course gradeAn average is also a dot product. The average of four numbers is the dot product of the list of numbers with the vector (¼, ¼, ¼, ¼).
In physics, the work done by a force is F · d, and the power delivered by a force is F · v. In each case the dot product multiplies matching components and adds the results. The weighted sum above uses the same operation.
In ℝⁿ there are n vectors that have one component equal to 1 and all of the other components equal to 0. They are called the standard unit vectors, and they are written e₁, e₂, …, eₙ. In ℝ⁴ they are
e₁ = (1, 0, 0, 0) e₂ = (0, 1, 0, 0) e₃ = (0, 0, 1, 0) e₄ = (0, 0, 0, 1)Each of these vectors has the length 1, and any two different ones are orthogonal. Any vector is a linear combination of them, and the coefficients are the components of the vector.
(3, −1, 4, 2) = 3e₁ − e₂ + 4e₃ + 2e₄The dot product of a vector with a standard unit vector gives one component. For example, (3, −1, 4, 2) · e₃ = 4.
In physics, the standard unit vectors in three dimensions are usually written î, ĵ, and k̂. A force of (3, −1, 4) newtons is the same as 3î − ĵ + 4k̂ newtons.
| Term | Meaning |
|---|---|
| ℝⁿ | The set of all vectors with n real components |
| Dot product | u₁v₁ + u₂v₂ + … + uₙvₙ, one number |
| Length | √v · v |
| Orthogonal | The dot product is 0 |
| Cauchy-Schwarz inequality | |u · v| ≤ |u| |v| |
| Triangle inequality | |u + v| ≤ |u| + |v| |
| Standard unit vectors | e₁, …, eₙ, each with one component equal to 1 |
Work each problem on paper first. Then open the answer to check your work.
u + v = (3, 4, 1, 1, 1)add the matching components3u − 2v = (6, 0, −3, 9, 3) − (2, 8, 4, −4, 0)multiply u by 3 and v by 23u − 2v = (4, −8, −7, 13, 3)subtract the matching components
dot product = (2)(1) + (0)(4) + (−1)(2) + (3)(−2) + (1)(0)multiply the matching componentsdot product = 2 + 0 − 2 − 6 + 0 = −6add the products
length = √1 + 1 + 1 + 1 = √4 = 2the vector (1, 1, 1, 1)length = √nfor n components, the sum under the square root is n
dot product = 2 − 2 + 3c − 4 = 3c − 4multiply the matching components and add3c − 4 = 0the vectors are perpendicularc = 4/3add 4, then divide by 3
dot product = 2first length = √2second length = 2cos θ = 2/2√2 = 1/√2divide the dot product by the two lengthsθ = 45°take the inverse cosine
The weights are w = (0.25, 0.25, 0.5), and the scores are s = (88, 92, 76).
w · s = (0.25)(88) + (0.25)(92) + (0.5)(76)multiply each score by its weightw · s = 22 + 23 + 38 = 83the course grade
Python reads the code one line at a time, from the top to the bottom. The equals sign stores the value on its right under the name on its left, and print shows a result. A vector is written as np.array([1, 2, 0, -1]), where np stands for NumPy, the part of Python that works with vectors and matrices. The components go inside the square brackets, with commas between them. A vector can have any number of components.
The instruction len counts the components of a vector.
Python
The second result is 4, so this vector is in ℝ⁴.
The + sign adds two vectors, and the * sign multiplies a vector by a number. The code is the same as for vectors with two components.
Python
The result is [4 1 4 1], as in Part 2 of this topic.
Now change the last line so that it prints 2u − v.
Python
Python reports an error if you add two vectors that have different numbers of components. You can test this by deleting one component of v and pressing Run.
The instruction np.dot calculates a dot product. The code below calculates the course grade from Part 4 of this topic. Python writes a decimal number with a period, as in 0.2.
Python
The result is 77.0.
Now change the weights and the scores to the ones in Practice Problem 6. The weights are 0.25, 0.25, and 0.5, and the scores are 88, 92, and 76.
Python
The instruction np.linalg.norm calculates the length of a vector. The code below finds the two lengths and the angle from Part 3 of this topic. The fifth line calculates cos θ. The sixth line finds the angle with np.arccos, the inverse cosine, and changes it from radians to degrees with np.degrees.
Python
The lengths are about 2.45 and 5.48, and the angle is about 94.3 degrees.
In the code below, the third component of u is stored under the name c, so the vector is (1, 2, c, −1). Change the value of c so that u is orthogonal to v. This is Practice Problem 4. A fraction can be typed with the / sign, as in 2 / 3.
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. The vector (5, 0, −2, 0, 1) belongs to which space?
The vector has five components, so it belongs to ℝ⁵. A component that is 0 still counts as a component.
2. Let u = (2, 0, −1, 3) and v = (1, 4, 2, −2). Calculate 2u − v.
2u = (4, 0, −2, 6)multiply each component by 22u − v = (4 − 1, 0 − 4, −2 − 2, 6 + 2)subtract the matching components2u − v = (3, −4, −4, 8)
3. Find the length of the vector (1, 2, 2, 4).
length = √1² + 2² + 2² + 4²the square root of the sum of the squareslength = √25 = 5
4. For which value of c are the vectors (1, c, 2, −1) and (2, 1, 3, 4) perpendicular?
dot product = 2 + c + 6 − 4 = c + 4multiply the matching components and addc + 4 = 0the vectors are perpendicularc = −4subtract 4 from both sides
5. A course grade uses the weights w = (0.3, 0.3, 0.4) for homework, quizzes, and tests. A student has the scores s = (80, 90, 70). Find the course grade w · s.
dot product = (0.3)(80) + (0.3)(90) + (0.4)(70)multiply each score by its weightdot product = 24 + 27 + 28 = 79add the products