Loading content...
Singular Value Decomposition (SVD) is one of the most powerful and versatile factorization techniques in linear algebra and numerical computing. It decomposes any matrix into a product of three matrices that reveal the matrix's fundamental geometric structure: how it rotates, scales, and rotates again when applied as a linear transformation.
For a 2×2 matrix A, the SVD expresses it as:
$$A = U \cdot \Sigma \cdot V$$
Where:
The singular values represent the scaling factors applied to each principal direction. For this problem, we return s as a 1D array [σ₁, σ₂] rather than the full diagonal matrix.
Mathematical Foundation:
The SVD can be computed by finding the eigenvalue decomposition of AᵀA and AAᵀ:
Geometric Interpretation:
Any linear transformation represented by matrix A can be understood as:
Your Task:
Write a Python function that computes the SVD of a 2×2 matrix. The function should:
Important Constraints:
numpy.linalg.svd or other built-in SVD functionsa = [[-10.0, 8.0], [10.0, -1.0]]U = [[-0.8, 0.6], [0.6, 0.8]]
s = [15.6525, 4.4721]
V = [[0.8944, -0.4472], [0.4472, 0.8944]]For the matrix A = [[-10, 8], [10, -1]], we compute:
Verification: U @ diag(s) @ V ≈ [[-10, 8], [10, -1]] ✓
The larger singular value (15.6525) indicates the primary stretching direction, while the smaller value (4.4721) represents the secondary direction.
a = [[1.0, 0.0], [0.0, 1.0]]U = [[1.0, 0.0], [0.0, 1.0]]
s = [1.0, 1.0]
V = [[1.0, 0.0], [0.0, 1.0]]The identity matrix is a special case where:
This represents a transformation that preserves all vectors exactly as they are — no rotation, no scaling.
a = [[3.0, 4.0], [0.0, 5.0]]U = [[0.7071, -0.7071], [0.7071, 0.7071]]
s = [6.7082, 2.2361]
V = [[0.3162, 0.9487], [-0.9487, 0.3162]]For this upper triangular matrix:
This decomposition reveals that the matrix stretches vectors by about 6.7× in its primary direction.
Constraints