Skip to content

Linear Transformations and Geometry

Linear algebra is not just about numbers in tables—it’s about transformations of space. Matrices can be seen as functions that transform vectors, stretching, rotating, reflecting, or projecting them. Understanding these transformations geometrically is essential for intuition in machine learning.


A function T:RnRmT: \mathbb{R}^n \to \mathbb{R}^m is a linear transformation if it satisfies:

  1. Additivity: T(x+y)=T(x)+T(y)T(x + y) = T(x) + T(y)
  2. Homogeneity: T(cx)=cT(x)T(cx) = cT(x) for scalar cc

Every linear transformation can be represented as a matrix multiplication:

T(x)=AxT(x) = A x

for some matrix AA.


  1. Scaling – Multiply vectors by a scalar.
    Example: [2003]\begin{bmatrix}2 & 0 \\ 0 & 3\end{bmatrix} scales xx by 2 and yy by 3.

  2. Rotation – Preserve length but rotate direction.
    Example (2D rotation by θ\theta):

    R(θ)=[cosθsinθsinθcosθ]R(\theta) = \begin{bmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{bmatrix}
  3. Reflection – Flip across a line or plane.

  4. Projection – Collapse vectors onto a subspace.
    Example: Project onto xx-axis in 2D:

    P=[1000]P = \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix}

  • Stretching:

    A=[2001]A = \begin{bmatrix} 2 & 0 \\ 0 & 1 \end{bmatrix}

    doubles the xx-axis component while leaving yy unchanged.

  • Rotation by 90°:

    R=[0110]R = \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}

    rotates any vector counterclockwise by 90°.

  • Projection:

    P=[1000]P = \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix}

    projects vectors onto the xx-axis.


::: code-group

import numpy as np
v = np.array([1, 2])
# Scaling
A = np.array([[2, 0], [0, 3]])
scaled = A.dot(v)
# Rotation (90 degrees)
R = np.array([[0, -1], [1, 0]])
rotated = R.dot(v)
# Projection onto x-axis
P = np.array([[1, 0], [0, 0]])
projected = P.dot(v)
print("Original vector:", v)
print("Scaled:", scaled)
print("Rotated:", rotated)
print("Projected:", projected)
use ndarray::{array, Array1, Array2};
fn main() {
let v: Array1<f64> = array![1.0, 2.0];
// Scaling
let a: Array2<f64> = array![[2.0, 0.0], [0.0, 3.0]];
let scaled = a.dot(&v);
// Rotation (90 degrees)
let r: Array2<f64> = array![[0.0, -1.0], [1.0, 0.0]];
let rotated = r.dot(&v);
// Projection onto x-axis
let p: Array2<f64> = array![[1.0, 0.0], [0.0, 0.0]];
let projected = p.dot(&v);
println!("Original vector: {:?}", v);
println!("Scaled: {:?}", scaled);
println!("Rotated: {:?}", rotated);
println!("Projected: {:?}", projected);
}

:::


  • Scaling → standardization of features.
  • Rotation → PCA rotates data into new basis.
  • Projection → dimensionality reduction (projecting onto lower-dimensional subspaces).
  • Reflections & symmetries → used in data augmentation and transformations.

Continue to Subspaces and Basis.