Vectors as Objects#
A vector is the basic object of linear algebra. In , a vector is an ordered list of real numbers. We write it as a column:
Each entry is a component (or coordinate). Two vectors are equal only when every corresponding component matches. The space is the set of all such -tuples; most of this course works in and for geometry, then lifts the same rules to higher dimensions used in data and machine learning.
Geometry in the plane. In , the vector can be drawn as an arrow from the origin to the point . The tip of the arrow is the point with those coordinates; the shaft is the directed segment from the origin. For example,
points three units right and two units up. In , the same idea holds in three axes; in with we keep the algebraic definition and drop the picture, but addition, scaling, and the dot product still work component-wise exactly as in the plane.
Vectors are not the same as free-floating points: a vector has direction and magnitude relative to a chosen origin and basis. In this course we always fix the standard basis of unless we say otherwise, so the components of are exactly its coordinates in that basis.
Vector Addition and Scalar Multiplication#
Two fundamental operations turn the set of vectors into a vector space: addition and scalar multiplication.
Addition is component-wise. If
then
Geometrically, place the tail of at the tip of ; the diagonal of the parallelogram they form is . That is the parallelogram law: the same sum is obtained whether you start with then add , or start with then add .
Scalar multiplication multiplies every component by a real number :
If , the arrow stretches; if , it shrinks; if , it flips direction and scales by . The zero vector has every component zero; it is the unique vector with for all .
Worked example. Let and . Then
Algebra rules (we state them without proof; they follow from the same rules for real numbers, applied component-wise):
- Commutativity of addition:
- Associativity of addition:
- Distributivity: and
- Compatibility of scalars:
- Identity scalars: and
These rules are the entire algebraic interface of a vector space. Everything else in the course — linear combinations, matrices as maps, bases, and projections — is built from them.
Linear Combinations and Span#
A linear combination of vectors is any vector of the form
where the coefficients are real scalars. Linear combinations are how we build new vectors from a given set: add them after scaling each one independently.
Worked example. Take
in . Can we reach the target ? We need scalars such that
Adding the two component equations: , so . Subtracting: , so . Check:
So is a linear combination of and .
Span. The span of a set of vectors is the set of all linear combinations of those vectors:
If the span is all of , the set is said to span . In the example above, and are not parallel, so their span is the whole plane : every target in is some linear combination of them. If instead both vectors lie on the same line through the origin, their span is only that line.
Span is the geometric answer to “what can these vectors generate?” Week 5 will refine this with linear independence and bases; for now, treat span as the reachable set under addition and scaling.
The Dot Product#
The dot product (also called the inner product on ) of two vectors is the scalar
It is symmetric () and linear in each argument separately.
Length (norm). The length or Euclidean norm of is defined from the dot product with itself:
This is the ordinary distance from the origin to the tip of . For example, .
Angle between vectors. The geometric meaning of the dot product is the angle between two nonzero vectors:
with taken in . When the angle is acute; when it is obtuse; when the vectors are perpendicular (next section).
Worked example. Let and . Then
So
That matches the picture: the unit vector along the -axis and the diagonal of the unit square meet at .
Compute the dot product of u = (1, 2, 3) and v = (4, -1, 2).
Orthogonality#
Two vectors and are orthogonal (written ) when their dot product is zero:
(for nonzero vectors; the zero vector is orthogonal to every vector by the same algebraic definition). Orthogonality is the coordinate-free way to say “perpendicular”: the angle formula gives , so .
Examples. In , and are orthogonal. So are and , because . In , the standard basis vectors are pairwise orthogonal.
Pythagorean theorem for vectors. When , lengths add in the familiar squared form:
Why. Expand the left side with the dot product:
If , the cross term vanishes and we recover . Conversely, if the Pythagorean identity holds, then , so the vectors are orthogonal. This is the clean algebraic form of the classical theorem in the plane, and it holds in every .
Orthogonality will reappear constantly: orthogonal projections (Week 7), orthonormal bases and the QR idea later in the course, and least-squares solutions where residual vectors are orthogonal to the column space.
Knowledge check#
What is the length (norm) of the vector v = (3, 4)?
Browser lab#
Compute the dot product, length, and angle between two vectors, then visualize them.
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()