Recent posts in Linear Algebra

808
808 views

🎯 What is Orthogonality?

Orthogonal is just a fancy word for perpendicular — a 90° angle.

This entire chapter is about:

  • When are two vectors orthogonal?
  • When are two subspaces orthogonal?
  • When are bases orthogonal?

1️⃣ Orthogonal Vectors

  • The Test: Two vectors x and y are orthogonal if: $\boxed{x^T y = 0}$
  • This is the dot product = x₁y₁ + x₂y₂ + ... + xₙyₙ = 0

Where does this come from? (Pythagoras!)

  • For a right triangle with sides x, y and hypotenuse x+y: $\|x\|^2 + \|y\|^2 = \|x+y\|^2$
  • Expanding the right side:$(x + y)^T (x + y) = x^T x + x^T y + y^T x + y^T y$
  • Since $x^T y = y^T x \quad \text{for real vectors:}$ $\|x + y\|^2 = \|x\|^2 + 2x^T y + \|y\|^2$
  • $\text{For Pythagoras: } 2x^T y = 0 \Rightarrow x^T y = 0$
  • Length squared of a vector: $\|x\|^2 = x^T x = x_1^2 + x_2^2 + \ldots + x_n^2$

Example:

x = [1, 2, 3]
y = [1, -2, 1]

x·y = (1)(1) + (2)(-2) + (3)(1) = 1 - 4 + 3 = 0 ✅ ORTHOGONAL!

Check Pythagoras: x+y = [2, 0, 4]

||x+y||² = 4 + 0 + 16 = 20

||x||² + ||y||² = 14 + 6 = 20 ✅

Special note:

The zero vector is orthogonal to EVERY vector (0·y = 0 always)

2️⃣ Orthogonal Subspaces

Definition: Subspace S is orthogonal to subspace T means: $\boxed{\text{Every vector in S is perpendicular to every vector in T}}$ 

Common Mistake — Wall and Floor:

  • The blackboard (a plane) and the floor (another plane) look perpendicular — but they are NOT orthogonal subspaces!
  • Why? Because the line where they meet (the bottom of the board) is in BOTH subspaces.

A vector can't be perpendicular to itself (unless it's zero).

Key Rule: If two subspaces share any non-zero vector, they CANNOT be orthogonal

When ARE two subspaces orthogonal?

Two subspaces $S_1$ and $S_2$ are orthogonal if every vector $u \in S_1$ is orthogonal (perpendicular) to every vector $v \in S_2$. This means their dot product (or inner product) is zero, $u \cdot v = 0$ (or $u^T v = 0$) for all pairs of vectors. They share only the zero vector in common, i.e., $S_1 \cap S_2 = \{0\}$.

In 2D (the plane), possible subspaces are:

  • The zero vector
  • A line through origin
  • The whole plane

Two lines through origin are orthogonal when they meet at exactly 90°. They only share the zero vector — that's what makes it work!

3️⃣ The Big Result: Row Space ⊥ Null Space

Statement: $\text{Row space of } A \perp \text{Null space of } A$

Proof (simple!): Take any vector x in the null space → Ax = 0

Write this out row by row:

[row 1 of A] · x = 0
[row 2 of A] · x = 0
      ⋮
[row m of A] · x = 0
  • Each row is perpendicular to x!
  • Now take any combination of rows: c₁(row 1) + c₂(row 2) + ... — that's any vector in the row space.

Is it perpendicular to x?

Now take any linear combination of rows:
\[
c_1(\text{row}_1 . x) + c_2(\text{row}_2 . x) + \ldots = c1​(0)+c2​(0)+…=0✓
\]

Therefore: Every vector in row space ⊥ every vector in null space ✅

Similarly (same proof for Aᵀ): $\boxed{\text{Column space of } A \perp \text{Left null space of } A}$

4️⃣ Orthogonal Complements

The null space doesn't just contain SOME vectors perpendicular to the row space — it contains ALL of them.

This is called being orthogonal complements:

PairSpaceDimensions
Row space & Null spaceRⁿr + (n−r) = n
Column space & Left null spaceRᵐr + (m−r) = m

Together they perfectly fill the entire space — no gaps, no overlaps (except at zero)

Visual:

        Rⁿ
   ┌─────────────────┐
   │   Row Space     │  dim = r
   │   (dim r)       │
   ├─────────────────┤  ← 90° between them
   │   Null Space    │  dim = n-r
   │   (dim n-r)     │
   └─────────────────┘
   r + (n-r) = n ✅

5️⃣ The Problem This Leads To

Real life gives us too many equations with noise:

Example — Satellite tracking:

  • 1000 measurements (equations)
  • Only 6 unknowns (position parameters)
  • Each measurement has noise

So Ax = b has NO exact solution because b is contaminated with noise.

What do we do?

  • Can't ignore equations (wasteful)
  • Can't solve exactly (impossible)
  • → Find the BEST POSSIBLE solution

The key equation that saves us: $\boxed{A^TA\hat{x} = A^Tb}$

Properties of AᵀA:

  • Square: (n×m)(m×n) = n×n ✅
  • Symmetric: (AᵀA)ᵀ = AᵀA ✅
  • Invertible when: columns of A are independent ✅
  • Rank of AᵀA = Rank of A (always!)

Some Important Points :

  • AX=b → asks for exact solution
  • $A^T A \hat{x} = A^T b$ → gives best possible approximation
  • We use it when: 👉 AX=b has NO solution
  • This happens when:b is not in the column space of A
  • We find $\hat{x}$ such that: $A\hat{x} \approx b$ i.e., as close as possible
  • This becomes a "best fit" problem
  • We minimize error: $\|A\hat{x} - b\|^2$

This is called: 👉 Least Squares Problem

WHY does this work?

  • Let’s define error: $e = b - A\hat{x}$
  • Key idea: We force error to be perpendicular to column space of A
  • That means: $A^T e = 0$
  • Substitute e: $A^T (b - A\hat{x}) = 0$, $A^T b = A^T A \hat{x}$

✅ That’s how the equation comes!

PROJECTIONS

🎯 Why Do We Project?

The core problem:

Ax = b often has NO solution because b is not in the column space of A

The solution:

Change b to the closest vector that IS in the column space → call it p Then solve Ax̂ = p instead

The closest point in the column space = the projection of b

6️⃣ Projection onto a Line (1D)

Setup:

  • Line through vector a (a 1D subspace)
  • Vector b (probably not on the line)
  • Find p = closest point on the line to b

The Key Geometric Fact: The error vector e = b − p must be perpendicular to a

        b
       /|
      / |  e = b - p
     /  |  (error, perpendicular to line)
    /   |
   /    ↓
  o-----p--------→ a
  
  p is on the line, e ⊥ a

Finding the Formula: Since p is on the line: p = xa (for some scalar x)

The perpendicularity condition: aᵀ(b − xa) = 0

Expanding: $a^T b - x\, a^T a = 0 \Rightarrow x\, a^T a = a^T b $

$\boxed{x = \frac{a^T b}{a^T a}}$

Therefore the projection: $\boxed{p = xa = \frac{a^Tb}{a^Ta} \cdot a}$

The Projection Matrix:

  • We want a matrix P such that p = Pb
  • From the formula: $p = a \cdot \frac{a^Tb}{a^Ta} = \frac{aa^T}{a^Ta} \cdot b$
  • Therefore: $\boxed{P = \frac{aa^T}{a^Ta}}$

Understanding the formula:

     aa^T          ← (n×1)(1×n) = n×n MATRIX
P = ──────
     a^Ta          ← (1×n)(n×1) = scalar NUMBER

Numerator = column × row = a full matrix Denominator = row × column = just a number Result = a matrix!

7️⃣ Properties of Projection Matrix P

Property 1 — Symmetric: $P^T = P$

Why? $(aa^T)^T = (a^T)^T a^T = aa^T$ ✅ The denominator is a scalar (unchanged by transpose) ✅

Property 2 — P² = P (project twice = same as once): If you project a vector onto a line, then project again — you stay in the same place!

$P^2 = \frac{aa^T}{a^T a}\cdot\frac{aa^T}{a^T a} = \frac{a(a^Ta)a^T}{(a^Ta)^2} = \frac{aa^T}{a^Ta} = P$

Property 3 — Rank 1: Column space of P = line through a (just 1 direction) → rank = 1

Quick checks:

What changesEffect on p
Double b → 2bp doubles too (2p)
Double a → 2ap stays the same! (still same line)
Replace a with −ap stays the same! (still same line)

8️⃣ Projection onto a Subspace (Higher Dimensions)

Setup:

  • Subspace spanned by columns a₁, a₂, ..., aₙ
  • Put them as columns of matrix A
  • Vector b (probably not in column space)
  • Find p = projection of b onto column space of A

The Key Geometric Fact: Error e = b − p must be perpendicular to the entire subspace. This means e ⊥ a₁ AND e ⊥ a₂ AND ... e ⊥ aₙ

Written as equations:

a₁ᵀ(b − Ax̂) = 0
a₂ᵀ(b − Ax̂) = 0
       ⋮
aₙᵀ(b − Ax̂) = 0

Combined as one matrix equation:

$A^T(b - A\hat{x}) = 0 \Rightarrow A^T A \hat{x} = A^T b$

This is the Normal Equation — the most important equation in this chapter!

9️⃣ The Three Key Formulas

Formula 1 — Best solution x̂: $\boxed{\hat{x} = (A^T A)^{-1} A^T b}$

Formula 2 — Projection vector p: $\boxed{p = A\hat{x} = A(A^T A)^{-1} A^T b}$

Formula 3 — Projection Matrix P: $\boxed{P = A(A^T A)^{-1} A^T}$

Properties of this P:

  • Symmetric: Pᵀ = P ✅
  • P² = P: Project twice = same result ✅
  • Column space of P = column space of A ✅

⚠️ Note: You CANNOT simplify A(AᵀA)⁻¹Aᵀ = I unless A is square! If A is not square, it has no inverse — leave the formula as is!

Special case — if A is square invertible: Column space = all of Rⁿ → projection = identity P = A(AᵀA)⁻¹Aᵀ = AA⁻¹(Aᵀ)⁻¹Aᵀ = I ✅

🎯 The Projection Formula: $\boxed{P = A(A^TA)^{-1}A^T}$

This matrix takes any vector b and projects it to the nearest point in the column space of A.

🔢 Two Extreme Cases

Case 1 — b is ALREADY in the column space: If b is in the column space → b = Ax for some x

$Pb = A(A^TA)^{-1}A^T \cdot Ax = A(A^TA)^{-1}(A^TA)x = Ax = b$

Result: Pb = b — projection leaves it unchanged ✅

Case 2 — b is PERPENDICULAR to the column space: If b ⊥ column space → b is in the null space of Aᵀ → Aᵀb = 0

$Pb = A(A^TA)^{-1}\underbrace{A^Tb}_{=0} = 0$

Result: Pb = 0 — projection kills it completely ✅

General Case (any b): Every vector b splits into two perpendicular parts: $\boxed{b = p + e}$

PartLives inFormula
p = projectionColumn space of Ap = Pb
e = errorLeft null space of A (⊥ to col space)e = (I−P)b

🔑 I − P is Also a Projection!

If P projects onto the column space, then (I − P) projects onto the perpendicular complement:

PropertyPI − P
Symmetric✅ Pᵀ = P✅ (I−P)ᵀ = I−P
Idempotent✅ P² = P✅ (I−P)² = I−P

Algebra confirms what geometry already tells you!

LEAST SQUARES: FITTING A LINE

🎯 The Problem

Given 3 data points:

tb
11
22
32

Find the best line: b = C + Dt

No line passes through all 3 points → find the best possible line.

🔢 Setting Up the Equations

For a perfect fit, we'd need:

C + D(1) = 1    →  C +  D = 1
C + D(2) = 2    →  C + 2D = 2
C + D(3) = 2    →  C + 3D = 2

Matrix form Ax = b:

$\underbrace{\begin{pmatrix}1 & 1 \\ 1 & 2 \\ 1 & 3\end{pmatrix}}_{A}
\underbrace{\begin{pmatrix}C \\ D\end{pmatrix}}_{x}
=
\underbrace{\begin{pmatrix}1 \\ 2 \\ 2\end{pmatrix}}_{b}$

3 equations, 2 unknowns → NO exact solution

🔢 What Does "Best" Mean?

Each equation gives an error:

e1 = (C + D)  − 1
e2 = (C + 2D) − 2
e3 = (C + 3D) − 2

Minimize the total squared error:

Minimize $ \|e\|^2 = e_1^2 + e_2^2 + e_3^2$. This is called Least Squares (also called Linear Regression in statistics)

⚠️ Note on outliers: Squaring amplifies large errors. One bad measurement (outlier) can distort the whole solution. Real statisticians handle this carefully!

🔢 Solving Using Normal Equations

The key equation: $A^T A \hat{x} = A^T b$

Step 1 — Compute $A^T A$: $A^T A =
\begin{pmatrix}
1 & 1 & 1 \\
1 & 2 & 3
\end{pmatrix}
\begin{pmatrix}
1 & 1 \\
1 & 2 \\
1 & 3
\end{pmatrix}
=
\begin{pmatrix}
3 & 6 \\
6 & 14
\end{pmatrix}$

Step 2 — Compute $A^T b$: $A^T b =
\begin{pmatrix}
1 & 1 & 1 \\
1 & 2 & 3
\end{pmatrix}
\begin{pmatrix}
1 \\
2 \\
2
\end{pmatrix}
=
\begin{pmatrix}
5 \\
11
\end{pmatrix}$

Step 3 — Solve the normal equations: $\begin{pmatrix}
3 & 6 \\
6 & 14
\end{pmatrix}
\begin{pmatrix}
C \\
D
\end{pmatrix}
=
\begin{pmatrix}
5 \\
11
\end{pmatrix}$

Using elimination:  $6C + 12D = 10$ , $6C + 14D = 11$

Subtracting: $2D = 1 \Rightarrow D = \frac{1}{2}$

Substitute back: $3C + 6\left(\frac{1}{2}\right) = 5 \Rightarrow 3C + 3 = 5 \Rightarrow C = \frac{2}{3}$

Best fit line: $b = \frac{2}{3} + \frac{1}{2} t$

🔢 Computing the Projection and Error

Values on the best line (projection p):

P1 = 2/3 + 1/2(1) = 7/6
P2 = 2/3 + 1/2(2) = 5/3
P3 = 2/3 + 1/2(3) = 13/6

$p = \begin{pmatrix}7/6\\5/3\\13/6\end{pmatrix}$ Error vector e = b − p: $e = \begin{pmatrix}1\\2\\2\end{pmatrix} - \begin{pmatrix}7/6\\5/3\\13/6\end{pmatrix} = \begin{pmatrix}-1/6\\2/6\\-1/6\end{pmatrix}$

Verification — e ⊥ p: $p \cdot e = \frac{7}{6}\left(-\frac{1}{6}\right) + \frac{5}{3}\left(\frac{2}{6}\right) + \frac{13}{6}\left(-\frac{1}{6}\right)$

✅ Verification — e ⊥ entire column space: e must be perpendicular to every vector in the column space, not just p!

e · [1,1,1] = -1/6 + 2/6 - 1/6 = 0 ✅
e · [1,2,3] = -1/6 + 4/6 - 3/6 = 0 ✅

This confirms e is in the Left Null Space of A — perpendicular to the entire column space ✅

📐 Two Pictures of the Same Problem

Picture 1 (geometric)Picture 2 (vector)
3 points on a graphVector b in R³
Best fit lineProjection p in column space
Vertical distances e1, e2, e3Error vector e
Line parameters C, DCombination coefficients

Same math — two different ways to see it!

WHY AᵀA IS INVERTIBLE?

🎯 Key Theorem: $\boxed{A^T A \text{ is invertible} \iff \text{columns of } A \text{ are independent}}$

Goal: Show that if AᵀAx = 0, then x = 0

Step 1: Multiply both sides on left by xᵀ: $x^T A^T A x = 0$

Step 2: Rewrite using parentheses: $Ax)^T(Ax) = 0$

Step 3: This equals ‖Ax‖² = 0, so: Ax=0

Step 4: But columns of A are independent → null space of A = {0}: x=0✓

Therefore AᵀA has no non-zero null space → AᵀA is invertible

ORTHONORMAL VECTORS & MATRICES

🎯 What Does Orthonormal Mean?

Vectors q₁, q₂, ..., qₙ are orthonormal when they are:

PropertyMathMeaning
Orthogonalqᵢᵀqⱼ = 0 (i ≠ j)Every pair is perpendicular
Normalqᵢᵀqᵢ = 1Every vector has length 1

Combined into one neat condition: $ q_i^T q_j = \begin{cases} 1 & \text{if } i = j \\ 0 & \text{if } i \ne j \end{cases} $

Use the letter Q whenever columns are orthonormal — it's a visual reminder!

🔢 The Magic: QᵀQ = I

Put orthonormal vectors as columns of matrix Q. Then compute QᵀQ:

Qᵀ has these vectors as ROWS
Q  has these vectors as COLUMNS

(QᵀQ)ᵢⱼ = (row i of Qᵀ) · (col j of Q)
         = qᵢᵀ · qⱼ
         = 0 (if i≠j) or 1 (if i=j)
$\boxed{Q^TQ = I}$

Rows times columns = all those dot products = identity!

🔑 Square vs Rectangular Q

CasePropertyResult
Q is squareQᵀ = Q⁻¹Called an orthogonal matrix
Q is rectangularOnly QᵀQ = I (not QQᵀ)Called matrix with orthonormal columns

By convention: only square Q with orthonormal columns is called an orthogonal matrix

📝 Examples of Orthogonal Matrices

Example 1 — Permutation matrix: $Q = \begin{pmatrix}0&0&1\\1&0&0\\0&1&0\end{pmatrix}$

Each column = a standard basis vector → unit vectors, perpendicular → orthogonal! ✅

Example 2 — Rotation matrix: $Q = \begin{pmatrix}\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta\end{pmatrix}$

Both columns have length 1, dot product = 0 → orthogonal! ✅

WHY ORTHONORMAL COLUMNS MAKE LIFE EASY?

🎯 Projection Matrix Simplifies!

General projection matrix onto column space of A: 

$P = A(A^T A)^{-1}A^T \;\leftarrow\; \text{messy, requires inversion}$

When A = Q (orthonormal columns):

$P = Q(Q^TQ)^{-1}Q^T = Q \cdot I \cdot Q^T = QQ^T$

$\boxed{P = QQ^T}\ \leftarrow\ \text{no inversion is needed}$

Verify the two projection properties:

  • Symmetric? $(QQ^T)^T = (Q^T)^T Q^T = QQ^T \;\checkmark$
  • P² = P? $(QQ^T)(QQ^T) = Q(\underbrace{Q^T Q}_{= I})Q^T = QQ^T \;\checkmark$

Special case — Q is square:

  • Column space = all of Rⁿ → projection = identity
  • $P = QQ^T = I \quad \text{(when $Q$ is square)}$

🎯 Normal Equations Simplify!

General normal equation: $A^T A \hat{x} = A^T b \quad \leftarrow \text{must solve a system}$

When A = Q: $Q^T Q \hat{x} = Q^T b \;\Rightarrow\; I\hat{x} = Q^T b \;\Rightarrow\; \boxed{\hat{x} = Q^T b}$

No matrix to invert — just compute dot products!

Each component of x̂: $\hat{x}_i = q_i^T b$

The i-th component = projection of b onto the i-th basis vector This is one of the most important formulas in mathematics!

GRAM-SCHMIDT PROCESS

🎯 The Problem

Given: Independent vectors a, b (and possibly c, d, ...)

Goal: Produce orthonormal vectors q₁, q₂, ...

Why: Orthonormal bases make all calculations simple

🔢 Step-by-Step: Two Vectors

Step 1 — First vector (easy): Just take a as is. The direction is fine! $\boxed{A = a}$

Step 2 — Second vector (the key idea): b has a component along A and a component perpendicular to A.

We want the perpendicular part → subtract off the A-component!

b = (component along A) + (component ⊥ to A)
            ↓                      ↓
       (projection)            (what we want!)
$\boxed{B = b - \frac{A^T b}{A^T A}\, A}$

This is exactly the error vector from the projection chapter!

Verify B ⊥ A: $$A^T B = A^T\!\left(b - \frac{A^T b}{A^T A}\,A\right)
= A^T b - \frac{A^T b}{A^T A}(A^T A)
= A^T b - A^T b
= 0 \;\checkmark$$

Step 3 — Normalize to get unit vectors: $\boxed{q_1 = \frac{A}{\|A\|}, \quad q_2 = \frac{B}{\|B\|}}$

⚠️ Square roots almost always appear here — unavoidable!

Three Vectors: Adding a Third

Given: A, B already orthogonal. Need C ⊥ A and C ⊥ B.

$\boxed{C = c - \frac{A^T c}{A^T A}\,A - \frac{B^T c}{B^T B}\,B}$

Logic: Start with c. Remove its A-component AND its B-component. What's left is perpendicular to both!

Then normalize:$\boxed{q_3 = \frac{C}{\|C\|}}$

📝 Numerical Example

Given:

a = [1, 1, 1]
b = [1, 0, 2]

Step 1 — A: $\begin{pmatrix}1 \\ 1 \\ 1\end{pmatrix}$

Step 2 — B: Compute:

  • $A^T b = (1)(1) + (1)(0) + (1)(2) = 3$
  • $A^T A = (1)(1) + (1)(1) + (1)(1) = 3$

\[
B = b - \frac{3}{3} A
= \begin{pmatrix}1 \\ 0 \\ 2\end{pmatrix}
- \begin{pmatrix}1 \\ 1 \\ 1\end{pmatrix}
= \begin{pmatrix}0 \\ -1 \\ 1\end{pmatrix}
\]

Check: \[
A^T B = (1)(0) + (1)(-1) + (1)(1) = 0 \;\checkmark
\]

Step 3 — Normalize:

\[
q_1 = \frac{A}{\|A\|} = \frac{1}{\sqrt{3}}
\begin{pmatrix}1 \\ 1 \\ 1\end{pmatrix},
\quad
q_2 = \frac{B}{\|B\|} = \frac{1}{\sqrt{2}}
\begin{pmatrix}0 \\ -1 \\ 1\end{pmatrix}
\]

Result: \[
Q =
\begin{pmatrix}
\frac{1}{\sqrt{3}} & 0 \\
\frac{1}{\sqrt{3}} & -\frac{1}{\sqrt{2}} \\
\frac{1}{\sqrt{3}} & \frac{1}{\sqrt{2}}
\end{pmatrix}
\]

Key observation:

  • Column space of Q = same as column space of A
  • Gram-Schmidt doesn't change the space — just rotates the basis to be orthonormal!

A = QR FACTORIZATION

🎯 Matrix Form of Gram-Schmidt

Just like elimination gave A = LU, Gram-Schmidt gives: $\boxed{A = QR}$

MatrixWhat it is
QOrthonormal columns (from Gram-Schmidt)
RUpper triangular matrix

Why is R upper triangular?

The entries of R are inner products: $R =
\begin{pmatrix}
a_1^T q_1 & 0 \\
a_2^T q_1 & a_2^T q_2
\end{pmatrix}$

The entry $a_1^Tq_2 = 0$ because Gram-Schmidt constructs q₂ to be perpendicular to a₁!  → Each later q is perpendicular to all earlier a's → zeros below diagonal → upper triangular!

General pattern of R:

R = | a₁ᵀq₁   a₂ᵀq₁   a₃ᵀq₁  ... |
    |   0     a₂ᵀq₂   a₃ᵀq₂  ... |
    |   0       0     a₃ᵀq₃  ... |
    |   ⋮       ⋮       ⋮         |

📊 Big Picture: Matrix Factorizations

ProcessFactorizationWhat it does
EliminationA = LUMakes matrix triangular
Gram-SchmidtA = QRMakes matrix orthonormal
1,601
1,601 views

Linear Algebra – Lecture 1

Topic: Solving Systems of Linear Equations

GOAL: Solve a system of n equations with n unknowns → written as Ax = b

👁️ Three Ways to Look at the Same Problem

1️⃣ Row Picture

  • Look at one equation at a time
  • Each equation = a line (2D) or a plane (3D)
  • The solution = the point where all lines/planes meet
  • Easy to see in 2D, gets harder in 3D and beyond

2️⃣ Column Picture ⭐ (Most Important)

  • Look at one column at a time
  • The question becomes: what combination of columns gives us b?
  • This is called a Linear Combination
  • Ax = b means → x₁(col1) + x₂(col2) + ... = b

3️⃣ Matrix Form

  • Write everything as Ax = b
  • A = coefficient matrix, x = unknowns vector, b = right-hand side

When Does a Solution Exist?

  • Columns are independent -> Solution exists for every b
  • Columns lie in the same plane -> Only some b are reachable ❌
  • A good matrix = invertible = non-singular = solution always exists
  • A bad matrix = singular = columns are dependent = no solution for some b

How to Multiply a Matrix by a Vector?

Two ways:

  • By columns ⭐ → take a linear combination of columns (Prof. Strang's favourite)
  • By rows → dot product of each row with x

Example:

$$ A = \begin{bmatrix}
2 & 1 \\
5 & 3
\end{bmatrix} x = \begin{bmatrix}
1 \\
2
\end{bmatrix} $$
$$ \[
Ax =
\begin{bmatrix}
2 & 1 \\
5 & 3
\end{bmatrix}
\begin{bmatrix}
1 \\
2
\end{bmatrix}
=
\begin{bmatrix}
4 \\
11
\end{bmatrix}
\] $$

Way 1️⃣ — By COLUMNS ⭐ (Prof. Strang's Favourite)

Take 1 of column 1 + 2 of column 2

1 × [2]  +  2 × [5]  =  [2+10]  =  [12]
   [1]        [3]      [1+6]      [7]

Think of it as → linear combination of columns.

Way 2️⃣ — By ROWS (Dot Product)

Multiply each row with vector x separately

Row 1 → [2, 5] · [1, 2] = (2×1) + (5×2) = 2 + 10 = 12 

Row 2 → [1, 3] · [1, 2] = (1×1) + (3×2) = 1 + 6 = 7

Think of it as → dot product of each row with x

Linear Algebra – Lecture 2

Topic: Elimination, Back Substitution & Matrices

GOAL: Solve Ax = b using a method called Elimination → used by every software/computer

Step 1: Forward Elimination

Convert matrix A → U (Upper Triangular matrix)

When Does Elimination Fail?

  • 0 in pivot position but non-zero below -> Row exchange → continue ✅
  • 0 in pivot position AND zeros below -> Complete failure ❌ → matrix not invertible

 Step 2: Back Substitution

Solve the equations bottom to top (reverse order).

Augmented Matrix

Carry the right-hand side b along as an extra column during elimination.

[A | b]  →  [U | c]
  • A becomes U
  • b becomes c
  • Then do back substitution on Ux = c

Elimination in Matrix Language

Each elimination step = multiplying by an Elementary Matrix E

Example — Subtract 3×(row1) from row2:

E₂₁ = | 1   0  0 |
       |-3   1  0 |
       | 0   0  1 |

  • Identity rows for rows that don't change
  • -3 in position (2,1) to do the subtraction

Full Elimination: E₃₂ · E₂₁ · A = U

Permutation Matrix (P): Used to exchange rows when a 0 appears in the pivot position. Found by swapping rows of the Identity matrix.

Linear Algebra – Lecture 3

Topic: Matrix Multiplication & Inverses

Matrix Multiplication — 5 Ways

  • All 5 ways give the same answer — just different perspectives!

Way 1️⃣ — Entry by Entry (Standard)

Each entry C(i,j) = dot product of row i of A × column j of B

C(3,4) = A(3,1)×B(1,4) + A(3,2)×B(2,4) + ...
Sum along the row of A and down the column of B

Way 2️⃣ — Column by Column ⭐

  • Each column of C = A × (column of B)
  • Columns of C are combinations of columns of A

 Way 3️⃣ — Row by Row

  • Each row of C = (row of A) × B
  • Rows of C are combinations of rows of B

Way 4️⃣ — Columns × Rows

A × B = (col1 of A × row1 of B) + (col2 of A × row2 of B) + ...

  • Each piece gives a full-sized matrix
  • Add them all up to get C

Way 5️⃣ — Block Multiplication

  • Chop matrices into blocks
  • Multiply blocks just like entries
C(block) = A1×B1 + A2×B3

Inverses

What is A⁻¹?

A⁻¹ is the matrix such that A⁻¹ × A = A × A⁻¹ = I

  • Only square matrices can have inverses
  • Left inverse = Right inverse (for square matrices)

When Does NO Inverse Exist? (Singular Matrix)

A matrix has no inverse if:

ReasonExplanation
Determinant = 0Quick check
Columns are dependentAll columns point same direction → can't reach all of space
Ax = 0 has a non-zero solutionMost important reason ⭐
 

 💡Proof: If Ax = 0 for some x ≠ 0, then A⁻¹ cannot exist Because: A⁻¹(Ax) = x → but A⁻¹(0) = 0 → contradiction!

Gauss-Jordan Method to Find A⁻¹

Idea: Solve for all columns of A⁻¹ at the same time!

Steps:

1. Set up the augmented matrix → [ A | I ]

2. Do elimination on the left side until it becomes I

3. The right side automatically becomes A⁻¹

Start:   | 1  3 | 1  0 |
         | 2  7 | 0  1 |

Step 1 (subtract 2×row1 from row2):
         | 1  3 | 1   0 |
         | 0  1 |-2   1 |

Step 2 (subtract 3×row2 from row1):
         | 1  0 | 7  -3 |
         | 0  1 |-2   1 |

A⁻¹ =   | 7  -3 |
         |-2   1 |

Why Does Gauss-Jordan Work?

  • All elimination steps together = one big matrix E => E × A = I → E must be A⁻¹

  • So when E is applied to the right side (which started as I): E × I = A⁻¹ ✅

Linear Algebra – Lecture 4 & 5

Topic: LU Factorization

What is LU Decomposition?

Split matrix A into two triangular matrices: A = L x U

MatrixMeaning
AOriginal matrix
LLower triangular (multipliers go here)
UUpper triangular (pivots on diagonal)

2×2 Example:

A = |2  1|      L = |1  0|      U = |2  1|
    |8  7|          |4  1|          |0  3|

  • L has 1s on diagonal
  • L has the multipliers below diagonal (with + sign)
  • U has the pivots on diagonal

Why Use LU Instead of Just Gaussian Elimination? -> 

  • LU Decomposition : Compute L and U once → solve for any b cheaply ✅
  • LU decomposition is independent of b (the right-hand side)!
  • If matrix A can be reduced to row echelon form without swapping rows → LU exists

How to Solve Ax = b Using LU?

Step 1: Replace A with LU : 

LUx = b

Step 2: Let y = Ux → Solve Ly = b using forward substitution

L is lower triangular → solve top to bottom

Step 3: Solve Ux = y using back substitution 

U is upper triangular → solve bottom to top

Linear Algebra – Lecture 6

Topic: Vector Spaces, Column Space & Null Space

What is a Vector Space?

A set of vectors where you can:

  • Add any two vectors → result stays in the space
  • Multiply by any scalar → result stays in the space

Combined: All linear combinations stay inside the space

Subspaces

A subspace = a vector space living inside a larger vector space

Rules every subspace must follow:

  1. Must contain the zero vector
  2. Closed under addition
  3. Closed under scalar multiplication

Examples in R³:

SetSubspace?
Whole R³✅ Yes
Plane through origin✅ Yes
Line through origin✅ Yes
Plane NOT through origin❌ No

🔗 Union vs Intersection of Subspaces

OperationSubspace?Why
S ∪ T (union)❌ Usually NOAdding a vector from S and one from T can land outside both
S ∩ T (intersection)✅ Always YESIf v,w are in both S and T → v+w is in both → still a subspace

Column Space C(A)

Column space = all linear combinations of the columns of A

  • For an m × n matrix → column space is a subspace of Rᵐ
  • It's the smallest subspace that contains all columns

Key Connection to Ax = b:

Ax=b has a solution⟺b is in the column space of A​

  • If b = combination of columns → solution exists
  • If b is NOT in column space → no solution

 Example (4×3 matrix):

  • 3 columns in R⁴ → cannot fill all of R⁴
  • Column 3 = Column 1 + Column 2 → dependent, adds nothing new
  • Column space = 2D subspace of R⁴

Null Space N(A)

Null space = all vectors x that satisfy Ax = 0

  • For an m × n matrix → null space is a subspace of Rⁿ
  • Always contains the zero vector

Why is it a subspace? ✅

If Av = 0 and Aw = 0, then:

A(v + w) = Av + Aw = 0 + 0 = 0 ✅
A(12v) = 12(Av) = 12(0) = 0 ✅
EquationSolutions form a subspace?
Ax = 0✅ YES → Null space
Ax = b (b ≠ 0)❌ NO → zero vector not a solution

Solutions to Ax = b look like a shifted line or plane — doesn't pass through origin → NOT a subspace

Column space tells us which b's are reachable; null space tells us all x's that map to zero — both are fundamental subspaces of a matrix. 

Linear Algebra – Lecture 7

Topic: Computing the Null Space — Elimination & Free Variables

GOAL: Find all solutions to Ax = 0 using a clear algorithm

Key point: Elimination does not change the null space ✅ (But it does change the column space!)

Step 1: Do Elimination on A

  • Proceed column by column
  • If a pivot position has zero and nothing below → skip that column (it's a free column)
  • Continue until you reach echelon form U

Step 2: Identify Pivot vs Free Columns

TypeDescription
Pivot columnsColumns that contain a pivot
Free columnsColumns with no pivot → variables can be anything

Step 3: Count Everything

Rank=r=number of pivots ; Free variables=n−r

Step 4: Find Special Solutions

  • For each free variable → set it to 1, all other free variables to 0
  • Solve for pivot variables using back substitution
  • Each free variable gives one special solution

Step 5: Write the Full Null Space

Null space=c1(solution 1)+c2(solution 2)+…

All combinations of special solutions = entire null space ✅

Worked Example

Matrix A (3×4):

A = |1  2  2  2|
    |2  4  6  8|
    |3  6  8  10|

After elimination → U:

U = |1  2  2  2|
    |0  0  2  4|
    |0  0  0  0|
  • Rank r = 2 (two pivots)
  • Pivot columns: 1 and 3
  • Free columns: 2 and 4
  • Free variables: n − r = 4 − 2 = 2

Special Solution 1 (x₂=1, x₄=0):

x = [-2, 1, 0, 0]

Special Solution 2 (x₂=0, x₄=1):

x = [2, 0, -2, 1]

Full Null Space:

x = c₁[-2, 1, 0, 0] + c₂[2, 0, -2, 1]

→ A 2D subspace (plane) in R⁴

Reduced Row Echelon Form (RREF)

Go one step further than U:

  • Make all pivots = 1
  • Get zeros above AND below every pivot
R = |1  2  0  -2|
    |0  0  1   2|
    |0  0  0   0|

Structure of R:

R = | I  F |
    | 0  0 |

Reading Special Solutions Directly from R:

Special solutions = combine identity (free part) with −F (pivot part)

💡 No need for back substitution — just read off the numbers from R!'

Linear Algebra – Lecture 8

Topic: Complete Solution to Ax = b

GOAL: Find all solutions to Ax = 0 

Step 0: Check Solvability First

Ax = b has a solution only if b is in the column space of A

During elimination, if a row of zeros appears on the left → the same combination of entries of b must also give zero

Example: If row3 = row1 + row2, then we need b3 = b1 + b2

If this condition fails → no solution exists

Algorithm: Complete Solution

Step 1 — Find ONE Particular Solution (xₚ)

  • Set all free variables = 0
  • Solve for pivot variables using back substitution
  • This gives xₚ (the particular solution)

Step 2 — Find the Null Space (xₙ)

  • Solve Ax = 0 
  • Find all special solutions (one per free variable)
  • xₙ = any combination of special solutions

Step 3 — Write Complete Solution

xcomplete=xp+xn

Why does this work?

A·xp = b    (particular solution gives b)
A·xn = 0    (null space gives 0)
─────────────────────
A·(xp + xn) = b ✅

The Big Picture — Rank Tells Everything

For an m × n matrix with rank r:

CaseConditionNull spaceSolutions to Ax=b
Square invertibler = m = nOnly {0}Exactly 1 solution
Full column rankr = n < mOnly {0}0 or 1 solution
Full row rankr = m < nn−r free variablesAlways exists (∞ solutions)
Rank deficientr < m, r < nn−r free variables0 or ∞ solutions

What the Solution Looks Like Geometrically

  • xₙ (null space) = a subspace through the origin
  • xₚ (particular) = a shifted point away from origin
  • Complete solution = the null space shifted to pass through xₚ
  • It is NOT a subspace (doesn't pass through origin)

Case Deep Dives

Full Column Rank (r = n)

  • No free variables → null space = {0} only
  • Ax = b has at most one solution
  • Matrix is tall and thin (more rows than columns)
  • RREF looks like: I on top, zeros below

Full Row Rank (r = m)

  • Every row has a pivot → no zero rows appear
  • Ax = b is always solvable for any b ✅
  • Matrix is short and wide (more columns than rows)
  • RREF looks like: [I | F]
  • Always infinitely many solutions (n−m free variables)

Square Invertible (r = m = n)

  • RREF = Identity matrix I
  • Null space = {0} only
  • Exactly one solution for every b ✅

Linear Algebra – Lecture 9

Topic: Independence, Spanning, Basis & Dimension

Four Key Definitions:

1️⃣ Linear Independence

Vectors v₁, v₂, ..., vₙ are independent if:

The only combination that gives zero is the all-zero combination

c1v1+c2v2+…+cnvn=0  ⟹  c1=c2=…=cn=0

Quick checks:

SituationIndependent?
v and 2v❌ Dependent (one is multiple of other)
Any set containing zero vector❌ Always dependent
Two vectors pointing different directions✅ Independent
3 vectors in a 2D plane❌ Always dependent

Connection to matrices:

  • Put vectors as columns of matrix A
  • Columns are independent ↔ null space of A = {0} only
  • Columns are dependent ↔ something non-zero exists in null space

Key fact: If n > m (more unknowns than equations) → columns are always dependent (free variables must exist)

2️⃣ Spanning

Vectors v₁, v₂, ..., vₗ span a space if:

The space consists of all linear combinations of those vectors

  • Columns of A span the column space of A
  • Adding extra dependent vectors → still spans, but no longer a basis

3️⃣ Basis

A basis for a space = a set of vectors that is:

  1. Independent
  2. Spans the space

Think of it as "just right" — not too many, not too few vectors

Example — Bases for R³: 

Standard basis:    Any invertible 3×3 matrix
[1,0,0]           columns also form a basis
[0,1,0]
[0,0,1]

Key rules:

  • Basis is not unique — infinitely many bases exist
  • But all bases for the same space have the same number of vectors
  • For Rⁿ → every basis has exactly n vectors
  • For a square matrix: columns form a basis ↔ matrix is invertible

4️⃣ Dimension

Dimension of a space = number of vectors in any basis

All bases for the same space always have the same count → that count = dimension

🔑 Key Theorems

Dimension of Column Space: dim⁡(C(A))=rank(A)=r.The pivot columns of A form the most natural basis for C(A)

Dimension of Null Space: dim⁡(N(A))=n−r.The special solutions form a basis for N(A) (one special solution per free variable)

SpaceBasisDimension
Column space C(A)Pivot columnsr
Null space N(A)Special solutionsn − r

Example: Matrix A (3×4) with rank r = 2:

A = |1  1  2  0|
    |2  1  3  0|
    |3  2  5  0|

  • Rank = 2
  • Dim of column space = 2 → basis = columns 1 & 2
  • Dim of null space = 4 − 2 = 2 → basis = 2 special solutions
  • Null space tells us: in what ways the columns are dependent
  • Rank of A = dim of C(A)

Example — Dimension of a Solution Space

The System

3 equations, 5 unknowns → Ax = 0

After Gauss-Jordan Elimination, the RREF matrix shows:

ColumnVariableType
1x₁Pivot (leading variable)
2x₂Pivot (leading variable)
3x₃Free variable = s
4x₄Pivot (leading variable)
5x₅Free variable = t

Step 1 — Assign Free Variables

x₃ = s    (any number)
x₅ = t    (any number)

Step 2 — Solve for Pivot Variables

From the RREF rows:

Row 1 → x₁ = s + 4t
Row 2 → x₂ = -9t
Row 3 → x₄ = 2t

Step 3 — Write the Solution Vector

$$ x = \begin{bmatrix}
x_1 \\ x_2 \\ x_3 \\ x_4 \\ x_5
\end{bmatrix} =
\begin{bmatrix}
s + 4t \\ -9t \\ s \\ 2t \\ t
\end{bmatrix} $$

Step 4 — Split into Two Vectors

$$ x =
s \begin{bmatrix}
1 \\ 0 \\ 1 \\ 0 \\ 0
\end{bmatrix}
+
t \begin{bmatrix}
4 \\ -9 \\ 0 \\ 2 \\ 1
\end{bmatrix} $$

Step 5 — Check if They Form a Basis

CheckResult
Do v₁ and v₂ span the solution space?✅ Yes — every solution is a combo of these two
Are v₁ and v₂ independent?✅ Yes — neither is a multiple of the other

{v₁, v₂} is a BASIS for the solution space

Final Answer: Dimension of solution space=2​

Because there are 2 free variables2 special solutions2 basis vectors

💡 General rule: Gauss-Jordan elimination always gives you a ready-made basis — no extra work needed!

Linear Algebra – Lecture 10

Topic: The Four Fundamental Subspaces

The Four Fundamental Subspaces of Matrix A (m×n)
 
SubspaceNotationLives inDimension
Column spaceC(A)Rᵐr
Null spaceN(A)Rⁿn − r
Row spaceC(Aᵀ)Rⁿr
Left null spaceN(Aᵀ)Rᵐm − r

1️⃣ Column Space C(A)

  • All combinations of columns of A
  • Basis = pivot columns of original A
  • Dimension = r

2️⃣ Null Space N(A)

  • All x such that Ax = 0
  • Basis = special solutions (one per free variable)
  • Dimension = n − r

 3️⃣ Row Space C(Aᵀ)

  • All combinations of rows of A
  • Written as column space of Aᵀ (to keep column vector convention)
  • Basis = first r rows of R (the RREF form, NOT of A!)
  • Dimension = r

Key fact:

Row operations preserve the row space but change the column space → Use rows of R (not A) for the basis!

Beautiful result: dim⁡(Column space)=dim⁡(Row space)=r

4️⃣ Left Null Space N(Aᵀ)

  • All y such that Aᵀy = 0
  • Called "left" null space because: yᵀA = 0 (y sits on the left of A)
  • Basis = last m−r rows of matrix E (found via Gauss-Jordan on [A|I])
  • Dimension = m − r

How to find it: Set up [A | I] → row reduce → get [R | E] The last m−r rows of E give the basis for the left null space.

To see more, click for the full list of questions or popular tags.