While we have extensively visualised vectors as directed segments with magnitude and direction in R2 and R3, the algebraic structure we have built is not confined to two or three dimensions. By defining a vector algebraically as an ordered list of numbers, we can seamlessly extend these concepts to spaces of any dimension.
Definition 1 (n-vector)
For a positive integer n, an n-vector is an ordered list of n real numbers, written as a column. The collection of all possible n-vectors is denoted by Rn.
Example 1
The column containing (−3,4.9,1/2,0,1) written vertically is a 5-vector belonging to R5.
Remark (Points and Vectors in $\mathbb{R}^n$)
Some linear algebra texts make no distinction between a point of Rn and a vector of Rn, since both are specified by the same ordered list of real numbers. In these notes we keep the earlier convention: points are written with capital letters and parentheses, whereas vectors are written in bold as columns. The underlying numerical data are the same; what changes is the geometric interpretation. Once an origin has been fixed, every point determines a position vector and every position vector determines a point.
Once n > 3, the classical physical interpretation of a vector as an arrow possessing magnitude and direction is no longer a meaningful way to conceptualise the space. However, vectors in higher dimensions are indispensable across both the physical sciences and data-driven fields. In complex physical systems, describing the complete state of a model often requires grouping numerous 3-vectors into a single, massive n-vector.
It is equally important to recognise a second point of view. An n-vector may simply be a structured list of numerical data. In that setting, the entries need not describe motion in space at all. They may record measurements, scores, counts, or coded information drawn from some underlying system.
Example 2 (Rainfall Record)
Suppose a weather station records the rainfall on each day of a non-leap year. These measurements may be arranged into the vector
R=r1r2⋮r365,
where rk is the rainfall measured on the kth day. The entries do not describe a point moving through space; they simply collect related numerical information into a single mathematical object.
Example 3 (Inventory Data)
Suppose a warehouse stores m different products, and let qk denote the number of units currently held of the kth product. The entire stock list may be written as
q=q1q2⋮qm.
Such a vector provides a compact way to encode the state of the warehouse at a given time.
Example 4 (Sensor Data)
Consider a large engineering system fitted with n sensors. If sk denotes the reading of the kth sensor at a fixed moment, then the entire state of the sensor network may be represented by
s=s1s2⋮sn,
where n may be very large. Again, the point is not that s is an arrow in ordinary space, but that vector notation organises a large collection of related measurements in a form that algebra can handle cleanly.
Calling such lists vectors is not merely a change of language. Once the data are placed into Rn, the algebra developed throughout these notes becomes available. We may add vectors, scale them, compare them, and later use further tools to detect structure hidden inside the data.
The extension is not limited to addition and scalar multiplication. The metric ideas developed earlier also admit a uniform algebraic formulation. In R2 and R3 these formulas were recovered from geometry. In Rn we now adopt them as definitions, since once n>3 there is no longer a literal picture in ordinary space to appeal to.
Example 5 (Distance from a Starting Point in Space)
Suppose a signal lamp is mounted on a framework so that, relative to a fixed origin, it lies 4 units in the positive x-direction, 3 units in the positive y-direction, and 12 units above the xy-plane. Its position vector is
p=4312.
The question “how far is the lamp from the starting point?” is exactly the question of finding the length of p. Using the three-dimensional distance formula,
∥p∥=42+32+122=16+9+144=169=13.
This is the same pattern already seen in the plane and in space: the distance from the origin to a point is the magnitude of its position vector.
Definition 2 (Magnitude in Rn)
Let
v=v1v2⋮vn∈Rn.
The magnitude (or norm) of v is defined by
∥v∥=v12+v22+⋯+vn2.
When n=2 or n=3, this reduces to the formulas already established in Lesson 1AM and earlier in this lesson. For larger n, the formula is no longer visual, but it remains the correct algebraic continuation of the same metric structure.
Let x,y∈Rn. The distance between x and y is defined by
d(x,y)=∥x−y∥.
Thus the distance between two vectors is computed by taking the difference vector and then measuring its magnitude. This agrees with the ordinary distance formulas in R2 and R3, where x−y is the displacement from the point represented by y to the point represented by x. In higher dimensions we keep the same formula because it extends those lower-dimensional cases exactly and behaves in the way a distance should. In particular,
d(x,y)=d(y,x),
since y−x=−(x−y) and ∥−v∥=∥v∥.
Note (Notation)
When primes are used on vectors or parameters, as in v′, v′′, or t′, they simply distinguish one object from another. They do not denote derivatives here.
Example 6 (Distance Computation in R4)
Let
x=12−13,y=3−10−1.
Then
x−y=−23−14,
so the distance between x and y is
d(x,y)=∥x−y∥=(−2)2+32+(−1)2+42=4+9+1+16=30.
Problem 1
Let
a=2−103,b=−112−1.
Compute a−b and d(a,b). Then compute b−a and explain why the distance is unchanged.
Dot Products and Angles in Rn
Length and distance are not the end of the metric story. In the plane and in space, the Law of Cosines tied lengths to angles, and the dot product gave an algebraic way to package that relation. The same algebraic construction extends to Rn.
Definition 4 (Dot Product in Rn)
Let
x=x1x2⋮xn,y=y1y2⋮yn∈Rn.
Their dot product is the scalar
x⋅y=x1y1+x2y2+⋯+xnyn=i=1∑nxiyi.
This is only defined when the two vectors belong to the same Rn.
Remark (Summation Notation)
The symbol
i=1∑nxiyi
means “add the expression xiyi as the index i runs from 1 to n”. In other words,
i=1∑nxiyi=x1y1+x2y2+⋯+xnyn.
The letter i is only a running index: writing ∑k=1nxkyk would mean exactly the same thing.
As in the earlier lessons, the output of a dot product is a scalar, not a vector. The self dot product recovers the square of the magnitude:
x⋅x=x12+x22+⋯+xn2=∥x∥2.
Theorem 2 (Algebraic Properties of the Dot Product in Rn)
For all x,y,z∈Rn and all scalars r∈R:
Symmetry:x⋅y=y⋅x.
Bilinearity:(rx+y)⋅z=r(x⋅z)+y⋅z, and likewise in the second argument.
Positive Definiteness:x⋅x≥0, with equality if and only if x=0.
Proof
Each statement is verified component by component exactly as in R2 and R3; the only difference is that there are n summands instead of two or three.
■
Example 7 (Using the Algebraic Rules)
Let
u=12−1,v=304,w=−215.
Then
u⋅v=1⋅3+2⋅0+(−1)⋅4=−1,
and by symmetry v⋅u=−1 as well. Also,
u⋅u=12+22+(−1)2=6=∥u∥2.
Finally,
u⋅(2v−w)=2(u⋅v)−u⋅w=2(−1)−((−2)+2−5)=3.
Example 8 (Computing Dot Products)
For
213⋅3−24,
we obtain
2⋅3+1⋅(−2)+3⋅4=16.
Likewise, in R4,
3101/2⋅1−236=3−2+0+3=4.
Example 9 (Prices and Quantities)
Suppose an economy tracks n goods. Let
p=p1p2⋮pn
be the price vector and
x=x1x2⋮xn
the quantity vector for a particular consumer. Then
p⋅x=p1x1+p2x2+⋯+pnxn
is the total amount spent. This is a typical higher-dimensional use of the dot product: the vectors encode data, not directions in physical space.
Theorem 3 (Cauchy-Schwarz in Rn)
For all vectors x,y∈Rn,
−∥x∥∥y∥≤x⋅y≤∥x∥∥y∥.
Equivalently,
∣x⋅y∣≤∥x∥∥y∥.
Moreover, equality holds in one of these inequalities if and only if one of the two vectors is a scalar multiple of the other.
Proof
If x=0 or y=0, the statement is immediate, and equality certainly holds because 0 is a scalar multiple of every vector. Assume from now on that both vectors are non-zero.
For any real number t,
0≤∥x+ty∥2=∥y∥2t2+2(x⋅y)t+∥x∥2.
Thus the quadratic polynomial
q(t)=∥y∥2t2+2(x⋅y)t+∥x∥2
is non-negative for every real t. Since its leading coefficient ∥y∥2 is positive, its discriminant must be non-positive:
(2(x⋅y))2−4∥y∥2∥x∥2≤0.
Rearranging gives
(x⋅y)2≤∥x∥2∥y∥2,
and taking square roots yields
∣x⋅y∣≤∥x∥∥y∥.
This is equivalent to the two-sided inequality.
For the equality case, equality in Cauchy-Schwarz means
(x⋅y)2=∥x∥2∥y∥2,
so the discriminant of q(t) is 0. Hence q(t) has a real root, meaning ∥x+ty∥2=0 for some t, so x+ty=0. Thus one vector is a scalar multiple of the other. Conversely, if x=cy for some scalar c, then
x⋅y=c∥y∥2,∥x∥∥y∥=∣c∣∥y∥2,
so equality holds.
■
Definition 5 (Angle and Orthogonality in Rn)
Let x,y∈Rn be non-zero. Their angle is the unique number θ∈[0,π] satisfying
cosθ=∥x∥∥y∥x⋅y.
Because of Cauchy-Schwarz, the right-hand side always lies in the interval [−1,1], so this definition makes sense.
Two vectors x,y∈Rn are orthogonal (or perpendicular) if
x⋅y=0.
Remark (Changing Orientation)
If one of the two vectors is multiplied by −1, the dot product changes sign while the magnitudes do not. The cosine therefore changes sign, so the angle is replaced by its supplementary angle π−θ. This is the same acute-versus-obtuse ambiguity that appears when one speaks about the angle between two lines through the origin rather than between two directed vectors.
Example 10 (Angles with Scalar Multiples)
Let x∈Rn be non-zero and let c=0 be a scalar. The angle between x and cx behaves exactly as geometric intuition suggests.
Indeed,
cosθ=∥cx∥∥x∥(cx)⋅x=∣c∣∥x∥2c(x⋅x)=∣c∣c.
If c>0, then cosθ=1, so θ=0. If c<0, then cosθ=−1, so θ=π.
In fact, by the equality case of Cauchy-Schwarz, these are the only situations in which the angle between two non-zero vectors can be 0 or π: that happens precisely when one is a scalar multiple of the other.
Example 11 (Angle Computation in R4)
Let
x=1100,y=1010.
Then
x⋅y=1,∥x∥=2,∥y∥=2.
Hence
cosθ=(2)(2)1=21,
so the angle between x and y is θ=π/3.
Theorem 4 (Pythagoras in Rn)
If u,v∈Rn are orthogonal, then
∥u+v∥2=∥u∥2+∥v∥2.
Proof
Since u⊥v, we have u⋅v=0. Therefore
∥u+v∥2=(u+v)⋅(u+v)=u⋅u+u⋅v+v⋅u+v⋅v.
By symmetry and orthogonality, the middle two terms are both 0, so
∥u+v∥2=∥u∥2+∥v∥2.■
Problem 2
Let v,w∈Rn be non-zero.
(a) Show that if v+w and v−w are perpendicular, then ∥v∥=∥w∥.
(b) Show the converse: if ∥v∥=∥w∥, then v+w and v−w are perpendicular.
Example 12 (Cosine Similarity)
Suppose v,w∈Rn have the same length ℓ, and let θ be the angle between them. Then
∥v−w∥2=(v−w)⋅(v−w)=∥v∥2−2(v⋅w)+∥w∥2.
Since v⋅w=∥v∥∥w∥cosθ=ℓ2cosθ, this becomes
∥v−w∥2=2ℓ2(1−cosθ).
So if the angle is small, then cosθ is close to 1 and the vectors are close together. For unit vectors, the quantity cosθ=v⋅w itself becomes a direct measure of similarity. This is why cosine similarity appears so often in document retrieval, embeddings, and other large-scale data problems.
Example 13 (Correlation Coefficient)
Given data points (x1,y1),…,(xn,yn), first recenter the data by subtracting the averages:
xi=xi−x,yi=yi−y.
Then form the two vectors
X=x1x2⋮xn,Y=y1y2⋮yn.
The correlation coefficient is
r=∥X∥∥Y∥X⋅Y.
Thus r is the cosine of the angle between the centred data vectors. It always lies in the interval [−1,1]. Values near 1 indicate a strong positive linear relationship, values near −1 a strong negative linear relationship, and values near 0 suggest little linear correlation.
Example 14 (A Computed Correlation Example)
Consider the five data points
(−3,4),(−2,1),(0,−1),(1,−1),(4,−3).
Their x-coordinates and y-coordinates already have average 0, so no recentering is needed. The associated vectors are
X=−3−2014,Y=41−1−1−3.
We compute
X⋅Y=−12−2+0−1−12=−27,
and
∥X∥=30,∥Y∥=28.
Therefore the correlation coefficient is
r=∥X∥∥Y∥X⋅Y=3028−27≈−0.9316.
This is close to −1, so the data are strongly clustered around a line of negative slope.
Problem 3
Consider the four data points
(1,1),(−1,−1),(k,−k),(−k,k),
where k=0.
(a) Compute the correlation coefficient when k=1.
(b) Compute the correlation coefficient r(k) for general k.
(c) Explain algebraically why −1<r(k)<1 for every non-zero k, and then explain the same fact geometrically.
Problem 4
Let
u=2−130,v=14−22,w=10−1.
Compute u⋅v. Use its sign to decide whether the angle between u and v is acute, right, or obtuse. Then explain why u⋅w is not defined.
Theorem 5 (Triangle Inequality in Rn)
For any vectors x,y∈Rn,
∥x+y∥≤∥x∥+∥y∥.
Equivalently, for any u,v,w∈Rn,
d(u,w)≤d(u,v)+d(v,w).
Proof
By the dot-product identity,
∥x+y∥2=(x+y)⋅(x+y)=∥x∥2+2(x⋅y)+∥y∥2.
Applying Cauchy-Schwarz gives
x⋅y≤∣x⋅y∣≤∥x∥∥y∥,
so
∥x+y∥2≤∥x∥2+2∥x∥∥y∥+∥y∥2=(∥x∥+∥y∥)2.
Taking square roots yields the first inequality.
For the distance form, observe that
w−u=(v−u)+(w−v),
and then apply the first inequality.
■
Problem 5
Use the triangle inequality to prove that for any x,y∈Rn,
∥x∥−∥y∥≤∥x−y∥.
Unit Vectors in Rn
Definition 6 (Zero Vector and Unit Vector in Rn)
The zero vector in Rn is
0=00⋮0.
A vector u∈Rn is called a unit vector if ∥u∥=1.
As before, every magnitude is non-negative. Moreover, if ∥v∥=0, then
v12+v22+⋯+vn2=0,
so each component must vanish, and therefore v=0. Thus if v=0, division by ∥v∥ is legitimate and produces a new vector whose magnitude is 1.
Theorem 6 (Normalising a Non-zero Vector)
Let v∈Rn be non-zero. Then
∥v∥1v
is a unit vector. Moreover, it is the unique unit vector obtained from v by multiplication by a positive scalar.
Proof
Since v=0, we have ∥v∥>0. Using the homogeneity of magnitude,
∥v∥1v=∥v∥1∥v∥=1.
So this vector is indeed a unit vector.
Now let c>0. Then cv is a positive scalar multiple of v, so geometrically it has the same direction as v. If cv is required to be a unit vector, then
∥cv∥=c∥v∥=1,
whence
c=∥v∥1.
So no other positive scalar multiple of v can have magnitude 1.
■
The vector
v=∥v∥v
is often called the unit vector in the direction of v. The unit vector in the opposite direction is
−v=−∥v∥v.
The standard coordinate vectors e1,…,en, each having a single entry equal to 1 and all remaining entries equal to 0, are basic examples of unit vectors.
Example 15 (Normalising a Vector in R3)
Let
v=2−21.
Then
∥v∥=22+(−2)2+12=4+4+1=3.
Hence the corresponding unit vector is
v=312−21=2/3−2/31/3.
A direct check gives
∥v∥=(2/3)2+(−2/3)2+(1/3)2=4/9+4/9+1/9=1.
Example 16 (A Compass Direction)
Suppose the positive x-axis points east and the positive y-axis points north. A vector pointing exactly north-west is
[−11].
Its magnitude is
(−1)2+12=2.
Therefore the unit vector pointing north-west is
21[−11]=[−1/21/2].
Problem 6
Let
u=11⋮1∈Rn.
Find ∥u∥ and the unit vector pointing in the same direction as u.
Example 17 (K-means and Distance in Rn)
Suppose data points x1,x2,…,xm in Rn are to be split into K clusters. The K-means method begins with centres c1,…,cK and assigns each data vector to the centre with smallest distance:
xi is assigned to the cluster whose centre cj minimises d(xi,cj).
After that, each centre is replaced by the average of the vectors assigned to its cluster. Thus the method depends directly on two ideas already present in these notes: averaging vectors and measuring distances in Rn.
Remark (Higher Dimensions)
Once n>3, there is no need to force a literal spatial interpretation onto every vector. The point of Rn is practical, not mystical: many problems naturally involve many variables, and the geometric language of magnitude, distance, and direction gives a disciplined way to think about them.
Exercises
Exercise 1 (Arithmetic in Higher Dimension)
Let
u=5−216,v=13−10,w=2−421.
(a) Compute u−2v+3w.
(b) Find the vector x such that
u+x=2v−w.
Exercise 2 (Distance in R4)
Let
p=2−140,q=−121−2.
Compute d(p,q).
Exercise 3 (Dot Products and Angles)
Let
u=3101/2,v=1−236.
(a) Compute u⋅v.
(b) Compute the angle between u and v.
(c) Decide whether the angle is acute, right, or obtuse.
Exercise 4 (Normalising Vectors)
For each of the following vectors, compute its magnitude and the unit vector pointing in the same direction.
(a)
[−815]
(b)
11⋮1∈Rn
Your answer in part (b) should be expressed in terms of n.
Exercise 5 (A Metric Identity)
Prove that for any v,w∈Rn,
∥v+w∥2+∥v−w∥2=2∥v∥2+2∥w∥2.
Exercise 6 (A First Clustering Computation)
Five customers rate two drinks on a scale from 1 to 5. The first entry records the rating for tea and the second the rating for coffee: