Two arrows leave the origin. Drag either tip.
u · v = 5.00. Projection scale of v onto u = 1.00. u + v = (3.0, 4.0).
The amber arrow is . The teal arrow is . The ink arrow is the diagonal . The short ink mark on is the projection of onto , and the readout under the picture is the scalar .
The tip of each arrow is an ordered pair. That pair is the vector once the standard basis of the plane is fixed. The same addition and the same dot product work in by doing the arithmetic on every component. The picture stays in the plane, where you can see it.
Addition and scaling#
Addition is component-wise. With the arrows on the picture,
Place the tail of at the tip of , or the other way around. The two routes close a parallelogram, and is the diagonal. Drag a tip and the diagonal moves with it. That is the parallelogram law, and it is the same statement as .
A scalar multiplies every component.
If the arrow stretches. If it shrinks. If it reverses. The zero arrow is the origin, and it is the only arrow with .
Span in the plane#
A linear combination is for real scalars and . The span is every vector you can reach that way.
Take and , and the target . The equation is the pair and . Adding gives . Subtracting gives . Check .
Those two arrows are not on the same line, so their span is the whole plane. Every target in is some pair of scalars. If both arrows lie on one line through the origin, the span is only that line. Week 5 turns this picture into linear independence and bases.
The span of two non-parallel vectors is the whole plane. The target is assembled as .
The dot product#
The dot product is the scalar on the readout.
In the same sum runs over every component, . The length is , so and . The angle between the arrows satisfies
so and . The lab prints those three numbers.
The projection scale is . The projection of onto is , which is why the ink mark sits on the tip of the amber arrow until you drag.
If the scalar is zero, the arrows are orthogonal. For and , . Then
because the cross term drops out. That is Pythagoras in every . The same idea returns in orthogonal projections (Week 7).
Knowledge Check#
What is the length of the vector v = (3, 4)?
Browser lab: dot product, length, and angle#
The cell uses the same two arrows as the picture. Run it, then drag a tip and compute the new scalar by hand.
import numpy as np
import matplotlib.pyplot as plt
u = np.array([2, 1])
v = np.array([1, 3])
dot = np.dot(u, v)
length_u = np.linalg.norm(u)
length_v = np.linalg.norm(v)
cos_theta = dot / (length_u * length_v)
angle_deg = np.degrees(np.arccos(cos_theta))
print(f"u . v = {dot}")
print(f"|u| = {length_u:.3f}, |v| = {length_v:.3f}")
print(f"angle between u and v = {angle_deg:.1f} degrees")
fig, ax = plt.subplots(figsize=(5, 5))
ax.quiver(0, 0, u[0], u[1], angles="xy", scale_units="xy", scale=1, color="tab:blue", label="u")
ax.quiver(0, 0, v[0], v[1], angles="xy", scale_units="xy", scale=1, color="tab:orange", label="v")
ax.set_xlim(-1, 4)
ax.set_ylim(-1, 4)
ax.set_aspect("equal")
ax.legend()
ax.set_title("Vectors u and v")
plt.show()
Key takeaways#
- Addition is the diagonal of the parallelogram.
- Scaling stretches, shrinks, or reverses an arrow.
- Two arrows that are not on the same line span the plane.
- The dot product is one scalar. It is zero exactly when the arrows are orthogonal.
Further reading#
- Gilbert Strang, Introduction to Linear Algebra (5th ed., Wellesley-Cambridge Press, 2016). Chapters 1 and 2.
- David C. Lay, Steven R. Lay, and Judi J. McDonald, Linear Algebra and Its Applications (6th ed., Pearson, 2021). Chapter 1.
- Stephen Boyd and Lieven Vandenberghe, Introduction to Applied Linear Algebra (Cambridge University Press, 2018). Chapters 1 to 3, free at vmls-book.stanford.edu.
- 3Blue1Brown, Essence of Linear Algebra. The first two videos match this page.
Reading is free. PDF and ePub unlock with the newsletter. Join once and every lesson opens in this browser.