Skip to the lesson
FixTheRobot Explore Robotics / Linear Algebra / M6 Eigenvalues, Eigenvectors and SVD / M6-T5

Linear Algebra · Theory · M6

M6-T5 — Singular Value Decomposition

Every matrix, square or not, is a rotation, then a stretch along axes, then another rotation. The SVD finds them all.

  • Lesson 5 of 8
  • Module 6: Eigenvalues, Eigenvectors and SVD
  • Eigen and SVD
  • About 9 minutes to read

Eigen-decomposition needs a square (and ideally symmetric) matrix. The singular value decomposition works for every matrix of any shape and tells you its rank, its stretch factors, its four fundamental subspaces and how close it is to being singular. It is the workhorse behind pseudoinverses, PCA, point-cloud registration and stable least squares.

Learning objectives

After this lesson, you should be able to:

  • State the SVD A = UΣVᵀ for any m × n matrix and name the shapes and properties of U, Σ and V.
  • Derive the SVD from the eigen-decomposition of AᵀA.
  • Interpret the singular values geometrically as the semi-axes of the image of the unit sphere.
  • Read the rank, the norm and the condition number from Σ, and relate the SVD to the four fundamental subspaces.

Introduction and motivation

A robot arm Jacobian is rectangular. A point-cloud cross-covariance matrix is not symmetric. A camera matrix has no eigenvectors worth looking at. Yet all of them can be understood with the same picture: an ellipse. The SVD computes that ellipse for any matrix and is the numerically safest way to answer the questions of Modules 3, 5 and 8: what is the rank, is the problem well conditioned, which directions are weak, and what is the best low-rank or least-squares answer.

The intuition

Take the unit circle of inputs and push it through the matrix. You always get an ellipse (possibly flattened to a line). The longest axis of that ellipse is the biggest stretch the matrix can produce; the input direction that produces it is v₁, the output direction is u₁ and the stretch is σ₁. The next axis, perpendicular to the first, is the second biggest stretch, and so on. Those axes are the SVD.

The SVD as rotate, stretch, rotateAny matrix maps the unit circle to an ellipse. The right singular vectors are the circle directions that become the ellipse axes, the singular values are the axis lengths and the left singular vectors are the axis directions in the output.A = U Σ Vᵀ Vᵀrotate/flip the inputright singular vectors vᵢ → Σstretch axis i by σᵢ ≥ 0σ₁ ≥ σ₂ ≥ … ≥ 0 → Urotate/flip the outputleft singular vectors uᵢ A vᵢ = σᵢ uᵢ (the SVD analogue of A v = λ v)
The SVD: rotate with Vᵀ, stretch by the singular values in Σ, rotate with U.

Interactive figure. The unit circle mapped by a two by two matrix is an ellipse. The readout lists the singular values, the rank and the condition number. Making the columns parallel flattens the ellipse to a line and drives the smaller singular value to zero. This figure needs JavaScript to be interactive.

Drag the two column handles or edit the entries. The unit circle becomes an ellipse whose semi-axes have lengths σ₁ and σ₂, with directions u₁ and u₂. Flatten the ellipse (make the columns parallel) and σ₂ falls to zero: the matrix has become singular.

Geometric and physical interpretation

Geometric view. The columns of V are an orthonormal basis of input space chosen so that A maps it to perpendicular outputs; the columns of U are those outputs, normalised; the singular values are the lengths. For a wide or tall matrix, some right singular vectors map to zero (the null space) and some left singular vectors are never reached (the left null space). Physical view. For a Jacobian, the SVD lists the directions in which the hand can move easily (large σ) and with difficulty (small σ); the ellipse is the manipulability ellipse of Module 8.

The mathematics

A
an m × n real matrix, any shape.
U
m × m orthogonal; columns uᵢ are the left singular vectors.
V
n × n orthogonal; columns vᵢ are the right singular vectors.
Σ
m × n diagonal (rectangular) with σ₁ ≥ σ₂ ≥ … ≥ 0 on the diagonal: the singular values.
r
the rank: the number of non-zero singular values.

The decomposition

A = U Σ Vᵀ = σ₁ u₁v₁ᵀ + σ₂ u₂v₂ᵀ + ... + σᵣ uᵣvᵣᵀ

What it means. Every matrix is a sum of r rank-one pieces, ordered by importance. A vᵢ = σᵢ uᵢ: A sends the input axis vᵢ to the output axis uᵢ, scaled by σᵢ.

Connection to eigenvalues

AᵀA = V Σᵀ Σ Vᵀ,     A Aᵀ = U Σ Σᵀ Uᵀ,     σᵢ² = eigenvalues of AᵀA

What it means. The right singular vectors are the eigenvectors of AᵀA and the left ones those of AAᵀ; the squares of the singular values are their (shared, non-negative) eigenvalues. This is both a derivation and a (numerically inferior) way to compute the SVD.

Norm, rank and conditioning

‖A‖₂ = σ₁      rank(A) = #{σᵢ > 0}      cond(A) = σ₁ / σᵣ

What it means. The largest singular value is the biggest stretch (the 2-norm). The rank counts the non-zero ones. The ratio of the largest to smallest non-zero one is the condition number, the sensitivity of solving Ax = b.

Every matrix = rotate, stretch by σ₁ ≥ σ₂ ≥ … ≥ 0, rotate. The σᵢ² are the eigenvalues of AᵀA; the number of non-zero σᵢ is the rank.

Step-by-step derivation: building the SVD from AᵀA

  1. AᵀA is symmetric and positive semi-definite (xᵀAᵀAx = ‖Ax‖² ≥ 0), so by the spectral theorem AᵀA = V Λ Vᵀ with orthonormal eigenvectors vᵢ and eigenvalues λᵢ ≥ 0.
  2. Define the singular values σᵢ = √λᵢ, sorted from large to small. Then ‖A vᵢ‖² = vᵢᵀAᵀA vᵢ = λᵢ = σᵢ², so A vᵢ has length σᵢ.
  3. For every σᵢ > 0, define uᵢ = A vᵢ / σᵢ, a unit vector.
  4. The uᵢ are orthogonal: uᵢᵀuⱼ = vᵢᵀAᵀA vⱼ/(σᵢσⱼ) = λⱼ vᵢᵀvⱼ/(σᵢσⱼ) = 0 for i ≠ j.
  5. Collecting A vᵢ = σᵢ uᵢ for all i gives A V = U Σ (complete U with extra orthonormal vectors for the zero singular values). Since V⁻¹ = Vᵀ, A = U Σ Vᵀ.

Consequences. If σᵢ = 0 then ‖A vᵢ‖ = 0, so vᵢ is in the null space; the right singular vectors with σᵢ = 0 span the null space and those with σᵢ > 0 span the row space. The left singular vectors with σᵢ > 0 span the column space and the remaining ones the left null space. The SVD is therefore an orthonormal basis for all four fundamental subspaces of Module 3 at once.

Best low-rank approximation. Keeping the first k terms, Aₖ = Σᵢ≤ₖ σᵢ uᵢvᵢᵀ, gives the closest rank-k matrix to A in the 2-norm and the Frobenius norm (Eckart-Young theorem), with error σₖ₊₁ in the 2-norm. This is the principle behind PCA and data compression.

Uniqueness. The singular values are unique. Each pair (uᵢ, vᵢ) is unique up to a joint sign flip, unless singular values repeat, in which case any orthonormal basis of the corresponding subspace may be used.

A worked example: the SVD of a 2 × 2 matrix

Let A = [[3, 0], [4, 5]].

  • Form AᵀA. AᵀA = [[9 + 16, 0 + 20], [20, 25]] = [[25, 20], [20, 25]].
  • Eigen-decompose it. Trace 50, determinant 625 − 400 = 225, so λ² − 50λ + 225 = 0, giving λ = 45 and 5. Eigenvectors: (1, 1)/√2 for 45 and (1, −1)/√2 for 5.
  • Singular values. σ₁ = √45 = 6.708, σ₂ = √5 = 2.236. Check: their product 6.708 × 2.236 = 15 = |det A| ✓, and σ₁² + σ₂² = 50 = ‖A‖²F = 9 + 0 + 16 + 25 ✓.
  • Left vectors. u₁ = A v₁/σ₁ = (3, 9)/√2 / 6.708 = (0.3162, 0.9487); u₂ = A v₂/σ₂ = (3, −1)/√2 / 2.236 = (0.9487, −0.3162). They are perpendicular ✓ (up to the sign convention a library picks).
  • Condition number. σ₁/σ₂ = 6.708/2.236 = 3.0: the matrix stretches three times more in one direction than the other, a well-conditioned map.
  • Rebuild. σ₁u₁v₁ᵀ + σ₂u₂v₂ᵀ returns A; the rank-one truncation σ₁u₁v₁ᵀ = [[1.5, 1.5], [4.5, 4.5]] is the best rank-one approximation, with error σ₂ = 2.236.

Robotics application

Point-cloud registration (ICP). The optimal rotation aligning two clouds comes from the SVD of the 3 × 3 cross-covariance matrix H = Σ pᵢ qᵢᵀ: R = V diag(1, 1, det(VUᵀ)) Uᵀ (Kabsch/Umeyama). See ICP fundamentals and scan registration.

Manipulators. The singular values of the Jacobian give the speed the hand can reach in each direction; a vanishing σ marks a singularity. Module 8 uses this directly.

Plane and normal estimation from LiDAR. The right singular vector for the smallest singular value of the centred point matrix is the surface normal (next lessons on rank and PCA).

Stable least squares. Solving Ax ≈ b through the SVD never squares the condition number and handles rank deficiency, unlike the normal equations. UAV sensor calibration and camera calibration (homography, essential matrix) all use the SVD to obtain null vectors; see extrinsic calibration.

Engineering implications and limitations

Practical rules

  • Use numpy.linalg.svd, never AᵀA, for accuracy. Squaring A squares the condition number and destroys small singular values. Compute the SVD of A itself.
  • Choose full_matrices=False for tall matrices. The economy SVD returns only the first n columns of U; it is far cheaper and enough for least squares and PCA.
  • Singular values are non-negative and sorted. Signs live in U and V; never expect a “negative singular value”.
  • Pair signs consistently. If you flip uᵢ you must flip vᵢ. Do not compare vectors between runs without fixing a sign convention.
  • Cost. A dense SVD is O(mn²) for m ≥ n; for a 3 × 3 or 6 × 6 matrix inside a real-time loop this is trivial, for big matrices consider truncated or randomised SVD.
  • Determinant sign. A rotation recovered by U Vᵀ may have determinant −1 (a reflection); correct it as in the registration formula above.

Limits

The SVD describes a linear map. For a nonlinear system it describes only the local Jacobian, valid in a small neighbourhood. It also does not respect physical weighting: if components have different units, scale them first (Module 5, weighted least squares), otherwise the singular values compare metres with radians.

Common misconceptions

“Singular values are the absolute values of the eigenvalues.”

Only for symmetric (and normal) matrices. For a general matrix the singular and eigenvalues can differ completely: [[1, 100], [0, 1]] has eigenvalues 1, 1 but singular values about 100 and 0.01.

“The SVD needs a square matrix.”

It exists for any m × n matrix; Σ is rectangular, and the number of non-zero entries is the rank.

“U and V are unique.”

Only up to simultaneous sign flips and, for repeated singular values, rotation within the subspace. The singular values are unique.

“Compute the SVD via eigenvalues of AᵀA in code.”

That squares the condition number: small singular values below about 1e-8·σ₁ are lost. Use a dedicated SVD routine.

Engineering takeaways

  1. Every matrix factors as A = UΣVᵀ: rotate, stretch along perpendicular axes by σ₁ ≥ σ₂ ≥ … ≥ 0, rotate.
  2. The σᵢ² are the eigenvalues of AᵀA and AAᵀ; A vᵢ = σᵢ uᵢ.
  3. σ₁ = ‖A‖₂, rank = number of non-zero σ, condition number = σ₁/σᵣ.
  4. The SVD gives orthonormal bases of all four fundamental subspaces and the best rank-k approximation.
  5. It underlies ICP alignment, manipulability, PCA, pseudoinverses and stable least squares; compute it from A, not AᵀA.

References and further reading

Primary papers and authoritative documentation.

Knowledge check

Three conceptual questions. Write an answer, then reveal the explanation. Your answers stay in your browser.

Question 1

Find the singular values of A = [[2, 0], [0, −3]] and a matching pair of singular vectors. Why is a singular value never negative?

Explanation

AᵀA = diag(4, 9), so σ = 3 and 2 (sorted). A maps e₂ to −3e₂: σ₁ = 3 with v₁ = e₂ and u₁ = −e₂ (the sign goes into U). σ₂ = 2 with v₂ = u₂ = e₁. A singular value is the length ‖Avᵢ‖, which cannot be negative; direction flips are carried by U or V.

Question 2

A has singular values 10, 2 and 0.001. What are its 2-norm, its condition number and its numerical rank if the tolerance is 0.01?

Explanation

2-norm = 10, condition number = 10/0.001 = 10 000. With tolerance 0.01 the third singular value is treated as zero, so the numerical rank is 2.

Question 3

Why does solving least squares through AᵀA lose accuracy compared to using the SVD of A?

Explanation

The singular values of AᵀA are the squares σᵢ², so cond(AᵀA) = cond(A)². A matrix with cond = 1e8 gives 1e16, beyond double-precision resolution; the small singular values are lost. The SVD of A works with cond(A) itself.

What’s next

The singular values contain the answer to two practical questions at once: how many independent directions does the data really have, and how close to singular is the problem. The next lesson turns them into the numerical rank and the condition number.

Practice this lesson

Point Cloud PCA

Find the surface normal and principal axes of a point cloud with the SVD, and tell planes, edges and volumes apart.

Next lesson

M6-T6 — Rank and Condition Number

Read the numerical rank and the condition number from the singular values.

Nothing below is required to finish this lesson.

  • Before
    M6-T4: Positive Definite Matrices

    Test whether a symmetric matrix is positive definite and explain why covariance matrices must be.

  • Before
    M4-T5: Orthogonal Matrices

    State the properties of an orthogonal matrix, including that it preserves lengths and angles, and relate them to rotations and reflections.

  • Lab
    M6-L1: Point Cloud PCA

    Find the surface normal and principal axes of a point cloud with the SVD, and tell planes, edges and volumes apart.