Vectors in 3D
Vectors in 3D have three components, written ⟨a, b, c⟩ or ai + bj + ck. The magnitude (length) of ⟨a, b, c⟩ is √(a² + b² + c²). You add vectors and multiply them by scalars one component at a time, and the dot product a₁b₁ + a₂b₂ + a₃b₃ gives the angle between two vectors.
Before this lesson: Magnitude and Direction of a Vector, Dot Product and 3D Coordinate System
What a vector in 3D means
A vector is an arrow with a length and a direction, but no fixed starting point. In the plane it takes two numbers. In space it takes three: how far the arrow moves in x, in y and in z.
The vector from P(x₁, y₁, z₁) to Q(x₂, y₂, z₂) is found by subtracting the starting point from the ending point. If the arrow starts at the origin, its components are just the coordinates of its tip. This is called a position vector.
The standard unit vectors i = ⟨1, 0, 0⟩, j = ⟨0, 1, 0⟩ and k = ⟨0, 0, 1⟩ point along the three axes. Any vector can be built from them: ⟨2, −6, 3⟩ = 2i − 6j + 3k.
Formulas for vectors in 3D
\overrightarrow{PQ} = \langle x_2 - x_1, \; y_2 - y_1, \; z_2 - z_1 \rangle\|\mathbf{v}\| = \sqrt{a^2 + b^2 + c^2} \quad \text{for } \mathbf{v} = \langle a, b, c \rangle\mathbf{u} = \dfrac{\mathbf{v}}{\|\mathbf{v}\|} \quad \text{(unit vector in the direction of } \mathbf{v})\mathbf{v} \cdot \mathbf{w} = v_1 w_1 + v_2 w_2 + v_3 w_3, \qquad \cos\theta = \dfrac{\mathbf{v} \cdot \mathbf{w}}{\|\mathbf{v}\| \, \|\mathbf{w}\|}- Add or subtract vectors by adding or subtracting matching components. Multiply by a scalar c by multiplying every component by c.
- The magnitude is the 3D distance formula from the tail to the tip.
- A unit vector has length 1. Dividing a vector by its own length keeps its direction and makes its length 1.
- The dot product is a number, not a vector. Two nonzero vectors are orthogonal (perpendicular) exactly when their dot product is 0.
Vectors in 3D examples
Example 1: Component form, magnitude and unit vector
Find the vector from P(1, 5, −2) to Q(3, −1, 1), its magnitude and the unit vector in its direction.
\overrightarrow{PQ} = \langle 3 - 1, \; -1 - 5, \; 1 - (-2) \rangleSubtract the coordinates of P from the coordinates of Q.
= \langle 2, -6, 3 \rangle
Simplify each component.
\|\overrightarrow{PQ}\| = \sqrt{2^2 + (-6)^2 + 3^2}Substitute into the magnitude formula.
= \sqrt{4 + 36 + 9}Square each component.
= \sqrt{49}Add.
= 7
Take the square root.
\mathbf{u} = \left\langle \dfrac{2}{7}, -\dfrac{6}{7}, \dfrac{3}{7} \right\rangleDivide each component by the magnitude, 7.
Answer: the vector is ⟨2, −6, 3⟩, its magnitude is 7, and the unit vector is ⟨2/7, −6/7, 3/7⟩.
Example 2: Combining vectors
Let v = ⟨3, −1, 2⟩ and w = ⟨−2, 4, 5⟩. Find 2v − 3w and the magnitude of v + w.
2\mathbf{v} = \langle 6, -2, 4 \rangleMultiply each component of v by 2.
3\mathbf{w} = \langle -6, 12, 15 \rangleMultiply each component of w by 3.
2\mathbf{v} - 3\mathbf{w} = \langle 6 - (-6), \; -2 - 12, \; 4 - 15 \rangleSubtract matching components.
= \langle 12, -14, -11 \rangle
Simplify each component.
\mathbf{v} + \mathbf{w} = \langle 3 + (-2), \; -1 + 4, \; 2 + 5 \rangleAdd matching components.
= \langle 1, 3, 7 \rangle
Simplify each component.
\|\mathbf{v} + \mathbf{w}\| = \sqrt{1^2 + 3^2 + 7^2}Substitute into the magnitude formula.
= \sqrt{1 + 9 + 49}Square each component.
= \sqrt{59}Add.
\approx 7.68
Approximate the square root.
Answer: 2v − 3w = ⟨12, −14, −11⟩, and the magnitude of v + w is √59 ≈ 7.68.
Example 3: Angle between two vectors
Find the angle between a = ⟨1, 2, 2⟩ and b = ⟨3, 0, 4⟩.
\mathbf{a} \cdot \mathbf{b} = 1 \cdot 3 + 2 \cdot 0 + 2 \cdot 4Multiply matching components (see dot product).
= 3 + 0 + 8
Multiply.
= 11
Add.
\|\mathbf{a}\| = \sqrt{1 + 4 + 4} = \sqrt{9} = 3Find the magnitude of a.
\|\mathbf{b}\| = \sqrt{9 + 0 + 16} = \sqrt{25} = 5Find the magnitude of b.
\cos\theta = \dfrac{11}{3 \cdot 5} = \dfrac{11}{15}Substitute into the angle formula.
\theta = \cos^{-1}\left(\dfrac{11}{15}\right) \approx 42.83^\circTake the inverse cosine (see inverse trig functions).
Answer: the angle is about 42.83°. The dot product is positive, so the angle is acute.
Example 4: Making two vectors orthogonal
Find k so that ⟨2, k, −3⟩ and ⟨4, 1, 2⟩ are orthogonal.
2 \cdot 4 + k \cdot 1 + (-3) \cdot 2 = 0
Set the dot product equal to 0.
8 + k - 6 = 0
Multiply.
k + 2 = 0
Combine like terms.
k = -2
Subtract 2 from both sides.
Answer: k = −2. Check: ⟨2, −2, −3⟩ · ⟨4, 1, 2⟩ = 8 − 2 − 6 = 0.
Example 5: Force and work (word problem)
A constant force F = ⟨6, −2, 9⟩ newtons moves a box in a straight line from A(1, 0, 2) to B(5, 3, 2), measured in meters. Find the size of the force and the work done. Work is the dot product of force and displacement.
\|\mathbf{F}\| = \sqrt{6^2 + (-2)^2 + 9^2}Substitute into the magnitude formula.
= \sqrt{36 + 4 + 81}Square each component.
= \sqrt{121}Add.
= 11
Take the square root.
\overrightarrow{AB} = \langle 5 - 1, \; 3 - 0, \; 2 - 2 \rangleSubtract A from B to get the displacement.
= \langle 4, 3, 0 \rangle
Simplify each component.
W = 6 \cdot 4 + (-2) \cdot 3 + 9 \cdot 0
Take the dot product of F and the displacement.
= 24 - 6 + 0
Multiply.
= 18
Add.
Answer: the force has a size of 11 newtons, and it does 18 joules of work. Only the part of the force along the path does work, so W is much less than 11 times the 5-meter distance.
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Subtracting in the wrong order | From P(1, 5, −2) to Q(3, −1, 1): ⟨−2, 6, −3⟩ | Use end minus start: Q − P = ⟨2, −6, 3⟩. |
| Forgetting the square root | Magnitude of ⟨2, −6, 3⟩ is 49 | Take the square root: √49 = 7. |
| Writing the dot product as a vector | ⟨1, 2, 2⟩ · ⟨3, 0, 4⟩ = ⟨3, 0, 8⟩ | Add the products to get one number: 3 + 0 + 8 = 11. |
| Dividing only one component | Unit vector of ⟨2, −6, 3⟩ is ⟨2/7, −6, 3⟩ | Divide every component by the magnitude. |
| Using radian mode for degrees | cos⁻¹(11/15) ≈ 0.75 written as degrees | 0.75 is in radians; set degree mode to get 42.83°. |
Related methods
Direction angles
The direction angles α, β and γ are the angles a vector makes with the positive x-, y- and z-axes. Their cosines are the components of the unit vector. For v = ⟨2, −6, 3⟩ with magnitude 7:
\cos\alpha = \dfrac{2}{7}, \quad \alpha \approx 73.40^\circDivide the x-component by the magnitude, then take cos⁻¹.
\cos\beta = -\dfrac{6}{7}, \quad \beta \approx 149.00^\circDivide the y-component by the magnitude, then take cos⁻¹.
\cos\gamma = \dfrac{3}{7}, \quad \gamma \approx 64.62^\circDivide the z-component by the magnitude, then take cos⁻¹.
\dfrac{4}{49} + \dfrac{36}{49} + \dfrac{9}{49} = 1Check: the squared cosines always add to 1.
Vectors in the plane
Everything here works in two dimensions by dropping the third component. For drawings, components and bearings in the plane, see adding and subtracting vectors and vector word problems. The next lesson, Cross Product, builds a vector perpendicular to two given vectors, something that only works in 3D.
Practice problems
- Write the vector from P(−2, 4, 1) to Q(3, 1, 7) in component form.
- Find the magnitude of ⟨4, −4, 7⟩.
- Find the unit vector in the direction of ⟨−6, 2, 3⟩.
- Let u = ⟨1, −2, 4⟩ and v = ⟨3, 0, −1⟩. Find 3u + 2v.
- Write 4i − j + 8k in component form and find its magnitude.
- Are ⟨2, −3, 5⟩ and ⟨4, 1, −1⟩ orthogonal?
- Find the angle between ⟨1, 1, 0⟩ and ⟨0, 1, 1⟩.
- Find c so that ⟨c, 2, −1⟩ and ⟨3, c, 4⟩ are orthogonal.
- Find the vector of length 10 in the direction of ⟨2, −1, 2⟩.
- Two forces, ⟨3, 4, −2⟩ N and ⟨1, −1, 8⟩ N, act on the same point. Find the size of the combined (resultant) force.
Show answers
1.
\overrightarrow{PQ} = \langle 3 - (-2), \; 1 - 4, \; 7 - 1 \rangleSubtract P from Q.
= \langle 5, -3, 6 \rangle
Simplify each component.
Answer: ⟨5, −3, 6⟩
2.
\sqrt{4^2 + (-4)^2 + 7^2}Substitute into the magnitude formula.
= \sqrt{16 + 16 + 49}Square each component.
= \sqrt{81}Add.
= 9
Take the square root.
Answer: 9
3.
\sqrt{(-6)^2 + 2^2 + 3^2}Substitute into the magnitude formula.
= \sqrt{36 + 4 + 9}Square each component.
= \sqrt{49}Add.
= 7
Take the square root.
\mathbf{u} = \left\langle -\dfrac{6}{7}, \dfrac{2}{7}, \dfrac{3}{7} \right\rangleDivide each component by 7.
Answer: ⟨−6/7, 2/7, 3/7⟩
4.
3\mathbf{u} = \langle 3, -6, 12 \rangleMultiply each component of u by 3.
2\mathbf{v} = \langle 6, 0, -2 \rangleMultiply each component of v by 2.
3\mathbf{u} + 2\mathbf{v} = \langle 3 + 6, \; -6 + 0, \; 12 + (-2) \rangleAdd matching components.
= \langle 9, -6, 10 \rangle
Simplify each component.
Answer: ⟨9, −6, 10⟩
5.
4\mathbf{i} - \mathbf{j} + 8\mathbf{k} = \langle 4, -1, 8 \rangleThe coefficients of i, j and k are the components.
\sqrt{4^2 + (-1)^2 + 8^2}Substitute into the magnitude formula.
= \sqrt{16 + 1 + 64}Square each component.
= \sqrt{81}Add.
= 9
Take the square root.
Answer: ⟨4, −1, 8⟩, with magnitude 9
6.
2 \cdot 4 + (-3) \cdot 1 + 5 \cdot (-1)
Multiply matching components.
= 8 - 3 - 5
Multiply.
= 0
Add.
Answer: yes. The dot product is 0, so the vectors are orthogonal.
7.
1 \cdot 0 + 1 \cdot 1 + 0 \cdot 1 = 1
Find the dot product.
\sqrt{1 + 1 + 0} = \sqrt{2}Find the magnitude of each vector; both are √2.
\cos\theta = \dfrac{1}{\sqrt{2} \cdot \sqrt{2}} = \dfrac{1}{2}Substitute into the angle formula.
\theta = \cos^{-1}\left(\dfrac{1}{2}\right) = 60^\circTake the inverse cosine.
Answer: 60°
8.
c \cdot 3 + 2 \cdot c + (-1) \cdot 4 = 0
Set the dot product equal to 0.
3c + 2c - 4 = 0
Multiply.
5c - 4 = 0
Combine like terms.
5c = 4
Add 4 to both sides.
c = \dfrac{4}{5}Divide both sides by 5.
Answer: c = 4/5
9.
\sqrt{2^2 + (-1)^2 + 2^2} = \sqrt{9} = 3Find the magnitude of ⟨2, −1, 2⟩.
\left\langle \dfrac{2}{3}, -\dfrac{1}{3}, \dfrac{2}{3} \right\rangleDivide by 3 to get the unit vector.
10 \left\langle \dfrac{2}{3}, -\dfrac{1}{3}, \dfrac{2}{3} \right\rangle = \left\langle \dfrac{20}{3}, -\dfrac{10}{3}, \dfrac{20}{3} \right\rangleMultiply the unit vector by 10.
Answer: ⟨20/3, −10/3, 20/3⟩
10.
\langle 3 + 1, \; 4 + (-1), \; -2 + 8 \rangle
Add the forces component by component.
= \langle 4, 3, 6 \rangle
Simplify each component.
\sqrt{4^2 + 3^2 + 6^2}Substitute into the magnitude formula.
= \sqrt{16 + 9 + 36}Square each component.
= \sqrt{61}Add.
\approx 7.81
Approximate the square root.
Answer: about 7.81 N
Vectors in 3D FAQ
How do you find the magnitude of a 3D vector?
Square each component, add the squares and take the square root. For ⟨4, −4, 7⟩, that is √(16 + 16 + 49) = √81 = 9.
How do you find the angle between two vectors in 3D?
Divide the dot product by the product of the magnitudes to get cos θ, then take the inverse cosine. The angle is always between 0° and 180°.
What are i, j and k?
They are the standard unit vectors ⟨1, 0, 0⟩, ⟨0, 1, 0⟩ and ⟨0, 0, 1⟩, which point along the x-, y- and z-axes. The vector ai + bj + ck is the same as ⟨a, b, c⟩.
How do you know if two 3D vectors are orthogonal?
Find their dot product. If it is 0, the vectors are orthogonal (perpendicular); if it is not 0, they are not.
Summary
- A 3D vector has three components: ⟨a, b, c⟩ = ai + bj + ck. The vector from P to Q is Q − P.
- Magnitude: √(a² + b² + c²). Unit vector: divide each component by the magnitude.
- Add, subtract and scale vectors component by component.
- Dot product: v₁w₁ + v₂w₂ + v₃w₃, a number. cos θ = (v · w) ÷ (‖v‖‖w‖).
- A dot product of 0 means the vectors are orthogonal.
Previous lesson: 3D Coordinate System
Next lesson: Cross Product
Back to the Calculus 3 Index