Skip to main content
© 2026 ePowerAI. All rights reserved.
CoursesContact
eAI
CoursesContact
Week 1: Vectors and Linear Combinations
Linear Algebra
01Week 1: Vectors and Linear Combinations
02Week 2: Linear Transformations and Matrices
03Week 3: Elimination and LU Factorization
04Week 4: Determinants
05Week 5: Vector Spaces, Independence, and Basis
06Week 6: The Four Fundamental Subspaces
07Week 7: Orthogonality and Projections
08Week 8: Least Squares and QR
09Week 9: Eigenvalues and Eigenvectors
10Week 10: Diagonalization and Markov Matrices
11Week 11: Differential Equations
12Week 12: Symmetric and Positive Definite Matrices
13Week 13: The SVD and Complex Matrices
14Week 14: The Fourier Matrix, FFT, and PCA
Week 01· Linear Algebra18 min read

Week 1: Vectors and Linear Combinations

✦Learning Outcomes
  • Represent vectors in Rn\mathbb{R}^nRn and perform vector addition and scalar multiplication
  • Compute linear combinations of vectors and interpret them geometrically
  • Compute the dot product and use it to find vector length and the angle between vectors
  • Determine whether two vectors are orthogonal using the dot product
◆Prerequisites

Background knowledge assumed:

  • Basic algebra (solving equations, working with variables)
  • Comfort with coordinate geometry in two and three dimensions

Recommended: Review the Course Index for an overview of the learning path.

Vectors as Objects#

A vector is the basic object of linear algebra. In Rn\mathbb{R}^nRn, a vector is an ordered list of nnn real numbers. We write it as a column:

v=(v1v2⋮vn)v = \begin{pmatrix} v_1 \\ v_2 \\ \vdots \\ v_n \end{pmatrix}v=​v1​v2​⋮vn​​​

Each entry viv_ivi​ is a component (or coordinate). Two vectors are equal only when every corresponding component matches. The space Rn\mathbb{R}^nRn is the set of all such nnn-tuples; most of this course works in R2\mathbb{R}^2R2 and R3\mathbb{R}^3R3 for geometry, then lifts the same rules to higher dimensions used in data and machine learning.

Geometry in the plane. In R2\mathbb{R}^2R2, the vector v=(v1v2)v = \begin{pmatrix} v_1 \\ v_2 \end{pmatrix}v=(v1​v2​​) can be drawn as an arrow from the origin (0,0)(0,0)(0,0) to the point (v1,v2)(v_1, v_2)(v1​,v2​). The tip of the arrow is the point with those coordinates; the shaft is the directed segment from the origin. For example,

v=(32)v = \begin{pmatrix} 3 \\ 2 \end{pmatrix}v=(32​)

points three units right and two units up. In R3\mathbb{R}^3R3, the same idea holds in three axes; in Rn\mathbb{R}^nRn with n>3n > 3n>3 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 Rn\mathbb{R}^nRn unless we say otherwise, so the components of vvv 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

u=(u1⋮un),v=(v1⋮vn),u = \begin{pmatrix} u_1 \\ \vdots \\ u_n \end{pmatrix}, \quad v = \begin{pmatrix} v_1 \\ \vdots \\ v_n \end{pmatrix},u=​u1​⋮un​​​,v=​v1​⋮vn​​​,

then

u+v=(u1+v1⋮un+vn).u + v = \begin{pmatrix} u_1 + v_1 \\ \vdots \\ u_n + v_n \end{pmatrix}.u+v=​u1​+v1​⋮un​+vn​​​.

Geometrically, place the tail of vvv at the tip of uuu; the diagonal of the parallelogram they form is u+vu + vu+v. That is the parallelogram law: the same sum is obtained whether you start with uuu then add vvv, or start with vvv then add uuu.

Scalar multiplication multiplies every component by a real number ccc:

cv=(cv1⋮cvn).cv = \begin{pmatrix} c v_1 \\ \vdots \\ c v_n \end{pmatrix}.cv=​cv1​⋮cvn​​​.

If c>1c > 1c>1, the arrow stretches; if 0<c<10 < c < 10<c<1, it shrinks; if c<0c < 0c<0, it flips direction and scales by ∣c∣|c|∣c∣. The zero vector 000 has every component zero; it is the unique vector with v+0=vv + 0 = vv+0=v for all vvv.

Worked example. Let u=(12)u = \begin{pmatrix} 1 \\ 2 \end{pmatrix}u=(12​) and v=(3−1)v = \begin{pmatrix} 3 \\ -1 \end{pmatrix}v=(3−1​). Then

u+v=(41),2u=(24),−v=(−31).u + v = \begin{pmatrix} 4 \\ 1 \end{pmatrix}, \qquad 2u = \begin{pmatrix} 2 \\ 4 \end{pmatrix}, \qquad -v = \begin{pmatrix} -3 \\ 1 \end{pmatrix}.u+v=(41​),2u=(24​),−v=(−31​).

Algebra rules (we state them without proof; they follow from the same rules for real numbers, applied component-wise):

  • Commutativity of addition: u+v=v+uu + v = v + uu+v=v+u
  • Associativity of addition: (u+v)+w=u+(v+w)(u + v) + w = u + (v + w)(u+v)+w=u+(v+w)
  • Distributivity: c(u+v)=cu+cvc(u + v) = cu + cvc(u+v)=cu+cv and (c+d)u=cu+du(c + d)u = cu + du(c+d)u=cu+du
  • Compatibility of scalars: (cd)u=c(du)(cd)u = c(du)(cd)u=c(du)
  • Identity scalars: 1⋅u=u1 \cdot u = u1⋅u=u and 0⋅u=00 \cdot u = 00⋅u=0

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 v1,v2,…,vkv_1, v_2, \ldots, v_kv1​,v2​,…,vk​ is any vector of the form

c1v1+c2v2+⋯+ckvk,c_1 v_1 + c_2 v_2 + \dots + c_k v_k,c1​v1​+c2​v2​+⋯+ck​vk​,

where the coefficients c1,…,ckc_1, \ldots, c_kc1​,…,ck​ 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

v1=(11),v2=(1−1)v_1 = \begin{pmatrix} 1 \\ 1 \end{pmatrix}, \quad v_2 = \begin{pmatrix} 1 \\ -1 \end{pmatrix}v1​=(11​),v2​=(1−1​)

in R2\mathbb{R}^2R2. Can we reach the target b=(42)b = \begin{pmatrix} 4 \\ 2 \end{pmatrix}b=(42​)? We need scalars c1,c2c_1, c_2c1​,c2​ such that

c1v1+c2v2=b⟺(c1+c2c1−c2)=(42).c_1 v_1 + c_2 v_2 = b \quad\Longleftrightarrow\quad \begin{pmatrix} c_1 + c_2 \\ c_1 - c_2 \end{pmatrix} = \begin{pmatrix} 4 \\ 2 \end{pmatrix}.c1​v1​+c2​v2​=b⟺(c1​+c2​c1​−c2​​)=(42​).

Adding the two component equations: 2c1=62c_1 = 62c1​=6, so c1=3c_1 = 3c1​=3. Subtracting: 2c2=22c_2 = 22c2​=2, so c2=1c_2 = 1c2​=1. Check:

3(11)+1(1−1)=(33)+(1−1)=(42).3\begin{pmatrix} 1 \\ 1 \end{pmatrix} + 1\begin{pmatrix} 1 \\ -1 \end{pmatrix} = \begin{pmatrix} 3 \\ 3 \end{pmatrix} + \begin{pmatrix} 1 \\ -1 \end{pmatrix} = \begin{pmatrix} 4 \\ 2 \end{pmatrix}.3(11​)+1(1−1​)=(33​)+(1−1​)=(42​).

So b=3v1+v2b = 3v_1 + v_2b=3v1​+v2​ is a linear combination of v1v_1v1​ and v2v_2v2​.

Span. The span of a set of vectors {v1,…,vk}\{v_1, \ldots, v_k\}{v1​,…,vk​} is the set of all linear combinations of those vectors:

span⁡{v1,…,vk}={c1v1+⋯+ckvk:ci∈R}.\operatorname{span}\{v_1, \ldots, v_k\} = \{ c_1 v_1 + \cdots + c_k v_k : c_i \in \mathbb{R} \}.span{v1​,…,vk​}={c1​v1​+⋯+ck​vk​:ci​∈R}.

If the span is all of Rn\mathbb{R}^nRn, the set is said to span Rn\mathbb{R}^nRn. In the example above, v1v_1v1​ and v2v_2v2​ are not parallel, so their span is the whole plane R2\mathbb{R}^2R2: every target in R2\mathbb{R}^2R2 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 Rn\mathbb{R}^nRn) of two vectors x,y∈Rnx, y \in \mathbb{R}^nx,y∈Rn is the scalar

x⋅y=∑i=1nxiyi=x1y1+x2y2+⋯+xnyn.x \cdot y = \sum_{i=1}^{n} x_i y_i = x_1 y_1 + x_2 y_2 + \cdots + x_n y_n.x⋅y=i=1∑n​xi​yi​=x1​y1​+x2​y2​+⋯+xn​yn​.

It is symmetric (x⋅y=y⋅xx \cdot y = y \cdot xx⋅y=y⋅x) and linear in each argument separately.

Length (norm). The length or Euclidean norm of xxx is defined from the dot product with itself:

∥x∥=x⋅x=x12+⋯+xn2.\|x\| = \sqrt{x \cdot x} = \sqrt{x_1^2 + \cdots + x_n^2}.∥x∥=x⋅x​=x12​+⋯+xn2​​.

This is the ordinary distance from the origin to the tip of xxx. For example, ∥(3,4)∥=9+16=5\|(3,4)\| = \sqrt{9 + 16} = 5∥(3,4)∥=9+16​=5.

Angle between vectors. The geometric meaning of the dot product is the angle θ\thetaθ between two nonzero vectors:

cos⁡θ=x⋅y∥x∥ ∥y∥,\cos\theta = \dfrac{x \cdot y}{\|x\|\,\|y\|},cosθ=∥x∥∥y∥x⋅y​,

with θ\thetaθ taken in [0,π][0, \pi][0,π]. When cos⁡θ>0\cos\theta > 0cosθ>0 the angle is acute; when cos⁡θ<0\cos\theta < 0cosθ<0 it is obtuse; when cos⁡θ=0\cos\theta = 0cosθ=0 the vectors are perpendicular (next section).

Worked example. Let x=(10)x = \begin{pmatrix} 1 \\ 0 \end{pmatrix}x=(10​) and y=(11)y = \begin{pmatrix} 1 \\ 1 \end{pmatrix}y=(11​). Then

x⋅y=1⋅1+0⋅1=1,∥x∥=1,∥y∥=2.x \cdot y = 1 \cdot 1 + 0 \cdot 1 = 1, \quad \|x\| = 1, \quad \|y\| = \sqrt{2}.x⋅y=1⋅1+0⋅1=1,∥x∥=1,∥y∥=2​.

So

cos⁡θ=11⋅2=12,θ=45∘=π4.\cos\theta = \frac{1}{1 \cdot \sqrt{2}} = \frac{1}{\sqrt{2}}, \quad \theta = 45^\circ = \frac{\pi}{4}.cosθ=1⋅2​1​=2​1​,θ=45∘=4π​.

That matches the picture: the unit vector along the xxx-axis and the diagonal of the unit square meet at 45∘45^\circ45∘.

Exercise · Fill in the blank

Compute the dot product of u = (1, 2, 3) and v = (4, -1, 2).


Orthogonality#

Two vectors xxx and yyy are orthogonal (written x⊥yx \perp yx⊥y) when their dot product is zero:

x⋅y=0  ⟺  x⊥yx \cdot y = 0 \iff x \perp yx⋅y=0⟺x⊥y

(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 cos⁡θ=0\cos\theta = 0cosθ=0, so θ=90∘\theta = 90^\circθ=90∘.

Examples. In R2\mathbb{R}^2R2, (10)\begin{pmatrix} 1 \\ 0 \end{pmatrix}(10​) and (01)\begin{pmatrix} 0 \\ 1 \end{pmatrix}(01​) are orthogonal. So are (21)\begin{pmatrix} 2 \\ 1 \end{pmatrix}(21​) and (−12)\begin{pmatrix} -1 \\ 2 \end{pmatrix}(−12​), because 2⋅(−1)+1⋅2=02\cdot(-1) + 1\cdot 2 = 02⋅(−1)+1⋅2=0. In R3\mathbb{R}^3R3, the standard basis vectors e1,e2,e3e_1, e_2, e_3e1​,e2​,e3​ are pairwise orthogonal.

Pythagorean theorem for vectors. When x⊥yx \perp yx⊥y, lengths add in the familiar squared form:

∥x+y∥2=∥x∥2+∥y∥2.\|x + y\|^2 = \|x\|^2 + \|y\|^2.∥x+y∥2=∥x∥2+∥y∥2.

Why. Expand the left side with the dot product:

∥x+y∥2=(x+y)⋅(x+y)=∥x∥2+2 x⋅y+∥y∥2.\|x + y\|^2 = (x + y) \cdot (x + y) = \|x\|^2 + 2\, x \cdot y + \|y\|^2.∥x+y∥2=(x+y)⋅(x+y)=∥x∥2+2x⋅y+∥y∥2.

If x⋅y=0x \cdot y = 0x⋅y=0, the cross term vanishes and we recover ∥x∥2+∥y∥2\|x\|^2 + \|y\|^2∥x∥2+∥y∥2. Conversely, if the Pythagorean identity holds, then x⋅y=0x \cdot y = 0x⋅y=0, so the vectors are orthogonal. This is the clean algebraic form of the classical theorem in the plane, and it holds in every Rn\mathbb{R}^nRn.

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#

Question 1 of 3

What is the length (norm) of the vector v = (3, 4)?

5
7
3.5
12

Browser lab#

Compute the dot product, length, and angle between two vectors, then visualize them.

python · runs in browser
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()
Next →
Week 2: Linear Transformations and Matrices
On this page
  • Vectors as Objects
  • Vector Addition and Scalar Multiplication
  • Linear Combinations and Span
  • The Dot Product
  • Orthogonality
  • Knowledge check
  • Browser lab