NLA-lib Explorer

Singular-value decomposition

Construct singular values and left and right singular vectors.

Definition

Definition (Singular-value decomposition). A singular-value decomposition is \mathbf{A}=\mathbf{U}\mathbf\Sigma\mathbf{V}^{\mathsf{H}}, with unitary factors \mathbf{U},\mathbf{V} and a rectangular diagonal matrix \mathbf\Sigma containing nonnegative singular values in decreasing order. Retaining the leading k singular components defines a rank-at-most-k truncation. The decomposition and its truncation are mathematical objects; concrete SVD algorithms have separate execution and accuracy questions.

Copy link

Mathematical guarantees

Theorem (Optimal rank truncation). For every comparison matrix \mathbf{B} with rank at most k,

\|\mathbf{A}-[\mathbf{A}]_k\|_{\mathrm{F}}\le\|\mathbf{A}-\mathbf{B}\|_{\mathrm{F}}.

Thus retaining the leading singular components gives a best rank-at-most-k approximation in Frobenius norm. A separate checked result gives the spectral-norm optimum.

Lean statement and details
NLAlib.frobNorm_sub_truncatedSVD_le_of_rank_le.{u_1, u_2, u_3} {π•œ : Type u_1} [RCLike π•œ]
  {m : Type u_2} {n : Type u_3} [Fintype m] [Fintype n] (A : Matrix m n π•œ) {B : Matrix m n π•œ}
  {k : β„•} (hB : B.rank ≀ k) : frobNorm (A - truncatedSVD A k) ≀ frobNorm (A - B)

Full source on GitHub

Copy link

Further results

Theorem (Eckart–Young in the spectral norm).

, as a least element: \sigma_k(\mathbf{A}) is the smallest spectral distance \|\mathbf{A} - \mathbf{B}\|_2 from \mathbf{A} to a matrix \mathbf{B} of rank at most k.

Lean statement and details
NLAlib.isLeast_specNorm_sub_of_rank_le.{u_1, u_2, u_3} {π•œ : Type u_1} [RCLike π•œ] {m : Type u_2}
  {n : Type u_3} [Fintype m] [Fintype n] (A : Matrix m n π•œ) (k : β„•) :
  IsLeast ((fun B ↦ specNorm (A - B)) '' {B | B.rank ≀ k}) (singularValues A k)

Full source on GitHub

Copy link

Theorem (Existence of the singular value decomposition).

For every k between the rank of \mathbf{A} and its smaller dimension, \mathbf{A} = \mathbf{U} \operatorname{diag}\bigl(\sigma_0(\mathbf{A}), \dots, \sigma_{k-1}(\mathbf{A})\bigr) \mathbf{V}^{\mathsf{H}} with \mathbf{U}, \mathbf{V} having k orthonormal columns. With k = \operatorname{rank} \mathbf{A} this is the compact SVD and with k = \min(\lvert m \rvert, \lvert n \rvert) the thin SVD. [HornJohnson2013, Theorem 2.6.3]; [GolubVanLoan2013, Theorem 2.4.1].

General form: sizes are index types

Lean statement and details
NLAlib.exists_isSVD.{u_1, u_3, u_4} {π•œ : Type u_1} [RCLike π•œ] {m : Type u_3} {n : Type u_4}
  [Fintype m] [Fintype n] (A : Matrix m n π•œ) {k : β„•} (hk : A.rank ≀ k) (hkm : k ≀ Fintype.card m)
  (hkn : k ≀ Fintype.card n) : βˆƒ U V, IsSVD A U (fun i ↦ singularValues A ↑i) V

Full source on GitHub

Copy link

Theorem (Uniqueness of the singular values).

In an SVD with columns indexed by Fin k and \boldsymbol{\sigma} non-increasing, \boldsymbol{\sigma} is the sequence of singular values: \sigma_i(\mathbf{A}) = \boldsymbol{\sigma}_i for i < k.

Lean statement and details
NLAlib.IsSVD.singularValues_eq.{u_1, u_3, u_4} {π•œ : Type u_1} [RCLike π•œ] {m : Type u_3}
  {n : Type u_4} [Fintype m] [Fintype n] {A : Matrix m n π•œ} {k : β„•} {U : Matrix m (Fin k) π•œ}
  {Οƒ : Fin k β†’ ℝ} {V : Matrix n (Fin k) π•œ} (h : IsSVD A U Οƒ V) (hΟƒ : Antitone Οƒ) (i : Fin k) :
  singularValues A ↑i = Οƒ i

Full source on GitHub

Copy link

Mathematical background

Appears under these tasks

Family