Cholesky decomposition

From HandWiki
Short description: Matrix decomposition method

In linear algebra, the Cholesky decomposition or Cholesky factorization (pronounced /ʃəˈlɛski/ shə-LES-kee) is a decomposition of a Hermitian, positive-definite matrix into the product of a lower triangular matrix and its conjugate transpose, which is useful for efficient numerical solutions, e.g., Monte Carlo simulations. It was discovered by André-Louis Cholesky for real matrices, and posthumously published in 1924.[1] When it is applicable, the Cholesky decomposition is roughly twice as efficient as the LU decomposition for solving systems of linear equations.[2]

Statement

The Cholesky decomposition of a Hermitian positive-definite matrix A, is a decomposition of the form

[math]\displaystyle{ \mathbf{A} = \mathbf{L L}^{*}, }[/math]

where L is a lower triangular matrix with real and positive diagonal entries, and L* denotes the conjugate transpose of L. Every Hermitian positive-definite matrix (and thus also every real-valued symmetric positive-definite matrix) has a unique Cholesky decomposition.[3]

The converse holds trivially: if A can be written as LL* for some invertible L, lower triangular or otherwise, then A is Hermitian and positive definite.

When A is a real matrix (hence symmetric positive-definite), the factorization may be written

[math]\displaystyle{ \mathbf{A} = \mathbf{L L}^\mathsf{T}, }[/math]

where L is a real lower triangular matrix with positive diagonal entries.[4][5][6]

Positive semidefinite matrices

If a Hermitian matrix A is only positive semidefinite, instead of positive definite, then it still has a decomposition of the form A = LL* where the diagonal entries of L are allowed to be zero.[7] The decomposition need not be unique, for example:

[math]\displaystyle{ \begin{bmatrix}0 & 0 \\0 & 1\end{bmatrix} = \mathbf L \mathbf L^*, \quad \quad \mathbf L=\begin{bmatrix}0 & 0\\ \cos \theta & \sin\theta\end{bmatrix}. }[/math]

However, if the rank of A is r, then there is a unique lower triangular L with exactly r positive diagonal elements and nr columns containing all zeroes.[8]

Alternatively, the decomposition can be made unique when a pivoting choice is fixed. Formally, if A is an n × n positive semidefinite matrix of rank r, then there is at least one permutation matrix P such that P A PT has a unique decomposition of the form P A PT = L L* with [math]\displaystyle{ \mathbf L = \begin{bmatrix} \mathbf L_1 & 0 \\ \mathbf L_2 & 0\end{bmatrix} }[/math], where L1 is an r × r lower triangular matrix with positive diagonal.[9]

LDL decomposition

A closely related variant of the classical Cholesky decomposition is the LDL decomposition,

[math]\displaystyle{ \mathbf{A} = \mathbf{L D L}^*, }[/math]

where L is a lower unit triangular (unitriangular) matrix, and D is a diagonal matrix. That is, the diagonal elements of L are required to be 1 at the cost of introducing an additional diagonal matrix D in the decomposition. The main advantage is that the LDL decomposition can be computed and used with essentially the same algorithms, but avoids extracting square roots.[10]

For this reason, the LDL decomposition is often called the square-root-free Cholesky decomposition. For real matrices, the factorization has the form A = LDLT and is often referred to as LDLT decomposition (or LDLT decomposition, or LDL′). It is reminiscent of the eigendecomposition of real symmetric matrices, A = QΛQT, but is quite different in practice because Λ and D are not similar matrices.

The LDL decomposition is related to the classical Cholesky decomposition of the form LL* as follows:

[math]\displaystyle{ \mathbf{A} = \mathbf{L D L}^* = \mathbf L \mathbf D^{1/2} \left(\mathbf D^{1/2} \right)^* \mathbf L^* = \mathbf L \mathbf D^{1/2} \left(\mathbf L \mathbf D^{1/2}\right)^*. }[/math]

Conversely, given the classical Cholesky decomposition [math]\displaystyle{ \mathbf A = \mathbf C \mathbf C^* }[/math] of a positive definite matrix, if S is a diagonal matrix that contains the main diagonal of [math]\displaystyle{ \mathbf C }[/math], then A can be decomposed as [math]\displaystyle{ \mathbf L \mathbf D \mathbf L^* }[/math] where

[math]\displaystyle{ \mathbf L = \mathbf C \mathbf S^{-1} }[/math] (this rescales each column to make diagonal elements 1),
[math]\displaystyle{ \mathbf D = \mathbf S^2. }[/math]

If A is positive definite then the diagonal elements of D are all positive. For positive semidefinite A, an [math]\displaystyle{ \mathbf L \mathbf D \mathbf L^* }[/math] decomposition exists where the number of non-zero elements on the diagonal D is exactly the rank of A.[11] Some indefinite matrices for which no Cholesky decomposition exists have an LDL decomposition with negative entries in D: it suffices that the first n−1 leading principal minors of A are non-singular.[12]

Example

Here is the Cholesky decomposition of a symmetric real matrix:

[math]\displaystyle{ \begin{align} \begin{pmatrix} 4 & 12 & -16 \\ 12 & 37 & -43 \\ -16 & -43 & 98 \\ \end{pmatrix} = \begin{pmatrix} 2 & 0 & 0 \\ 6 & 1 & 0 \\ -8 & 5 & 3 \\ \end{pmatrix} \begin{pmatrix} 2 & 6 & -8 \\ 0 & 1 & 5 \\ 0 & 0 & 3 \\ \end{pmatrix}. \end{align} }[/math]

And here is its LDLT decomposition:

[math]\displaystyle{ \begin{align} \begin{pmatrix} 4 & 12 & -16 \\ 12 & 37 & -43 \\ -16 & -43 & 98 \\ \end{pmatrix} & = \begin{pmatrix} 1 & 0 & 0 \\ 3 & 1 & 0 \\ -4 & 5 & 1 \\ \end{pmatrix} \begin{pmatrix} 4 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 9 \\ \end{pmatrix} \begin{pmatrix} 1 & 3 & -4 \\ 0 & 1 & 5 \\ 0 & 0 & 1 \\ \end{pmatrix}. \end{align} }[/math]

Geometric interpretation

The ellipse is a linear image of the unit circle. The two vectors [math]\displaystyle{ v_1, v_2 }[/math] are conjugate axes of the ellipse chosen such that [math]\displaystyle{ v_1 }[/math] to be parallel to the first axis, [math]\displaystyle{ v_2 }[/math] to be within the plane spanned by the first two axes.

The Cholesky decomposition is equivalent to a particular choice of conjugate axes of an ellipsoid.[13] In detail, let the ellipsoid be defined as [math]\displaystyle{ y^TAy = 1 }[/math], then by definition, a set of vectors [math]\displaystyle{ v_1, ..., v_n }[/math] are conjugate axes of the ellipsoid iff [math]\displaystyle{ v_i^T A v_j = \delta_{ij} }[/math]. Then, the ellipsoid is precisely[math]\displaystyle{ \left\{ \sum_i x_i v_i : x^T x = 1 \right\} = f(\mathbb S^n) }[/math]where [math]\displaystyle{ f }[/math] maps the basis vector [math]\displaystyle{ e_i \mapsto v_i }[/math], and [math]\displaystyle{ \mathbb S^n }[/math] is the unit sphere in n dimensions. That is, the ellipsoid is a linear image of the unit sphere.

Define the matrix [math]\displaystyle{ V := [v_1 | v_2 | \cdots | v_n] }[/math], then [math]\displaystyle{ v_i^T A v_j = \delta_{ij} }[/math] is equivalent to [math]\displaystyle{ V^TAV = I }[/math]. Different choices of the conjugate axes correspond to different decompositions.

The Cholesky decomposition corresponds to choosing [math]\displaystyle{ v_1 }[/math] to be parallel to the first axis, [math]\displaystyle{ v_2 }[/math] to be within the plane spanned by the first two axes, and so on. This makes [math]\displaystyle{ V }[/math] an upper-triangular matrix. Then, there is [math]\displaystyle{ A = LL^T }[/math], where [math]\displaystyle{ L = (V^{-1})^T }[/math] is lower-triangular.

Similarly, principal component analysis corresponds to choosing [math]\displaystyle{ v_1, ..., v_n }[/math] to be perpendicular. Then, let [math]\displaystyle{ \lambda = 1/\|v_i\|^2 }[/math] and [math]\displaystyle{ \Sigma = \mathrm{diag}(\lambda_1, ..., \lambda_n) }[/math], and there is [math]\displaystyle{ V = U\Sigma^{-1/2} }[/math] where [math]\displaystyle{ U }[/math] is an orthogonal matrix. This then yields [math]\displaystyle{ A = U\Sigma U^T }[/math].

Applications

Numerical solution of system of linear equations

The Cholesky decomposition is mainly used for the numerical solution of linear equations [math]\displaystyle{ \mathbf{Ax} = \mathbf{b} }[/math]. If A is symmetric and positive definite, then [math]\displaystyle{ \mathbf{Ax} = \mathbf{b} }[/math] can be solved by first computing the Cholesky decomposition [math]\displaystyle{ \mathbf{A} = \mathbf{LL}^\mathrm{*} }[/math], then solving [math]\displaystyle{ \mathbf{Ly} = \mathbf{b} }[/math] for y by forward substitution, and finally solving [math]\displaystyle{ \mathbf{L^*x} = \mathbf{y} }[/math] for x by back substitution.

An alternative way to eliminate taking square roots in the [math]\displaystyle{ \mathbf{LL}^\mathrm{*} }[/math] decomposition is to compute the LDL decomposition [math]\displaystyle{ \mathbf{A} = \mathbf{LDL}^\mathrm{*} }[/math], then solving [math]\displaystyle{ \mathbf{Ly} = \mathbf{b} }[/math] for y, and finally solving [math]\displaystyle{ \mathbf{DL}^\mathrm{*}\mathbf{x} = \mathbf{y} }[/math].

For linear systems that can be put into symmetric form, the Cholesky decomposition (or its LDL variant) is the method of choice, for superior efficiency and numerical stability. Compared to the LU decomposition, it is roughly twice as efficient.[2]

Linear least squares

Systems of the form Ax = b with A symmetric and positive definite arise quite often in applications. For instance, the normal equations in linear least squares problems are of this form. It may also happen that matrix A comes from an energy functional, which must be positive from physical considerations; this happens frequently in the numerical solution of partial differential equations.

Non-linear optimization

Non-linear multi-variate functions may be minimized over their parameters using variants of Newton's method called quasi-Newton methods. At iteration k, the search steps in a direction [math]\displaystyle{ p_k }[/math] defined by solving [math]\displaystyle{ B_k p_k = -g_k }[/math] for [math]\displaystyle{ p_k }[/math], where [math]\displaystyle{ p_k }[/math] is the step direction, [math]\displaystyle{ g_k }[/math] is the gradient, and [math]\displaystyle{ B_k }[/math] is an approximation to the Hessian matrix formed by repeating rank-1 updates at each iteration. Two well-known update formulas are called Davidon–Fletcher–Powell (DFP) and Broyden–Fletcher–Goldfarb–Shanno (BFGS). Loss of the positive-definite condition through round-off error is avoided if rather than updating an approximation to the inverse of the Hessian, one updates the Cholesky decomposition of an approximation of the Hessian matrix itself.[14]

Monte Carlo simulation

The Cholesky decomposition is commonly used in the Monte Carlo method for simulating systems with multiple correlated variables. The covariance matrix is decomposed to give the lower-triangular L. Applying this to a vector of uncorrelated samples u produces a sample vector Lu with the covariance properties of the system being modeled.[15]

The following simplified example shows the economy one gets from the Cholesky decomposition: suppose the goal is to generate two correlated normal variables [math]\displaystyle{ x_1 }[/math] and [math]\displaystyle{ x_2 }[/math] with given correlation coefficient [math]\displaystyle{ \rho }[/math]. To accomplish that, it is necessary to first generate two uncorrelated Gaussian random variables [math]\displaystyle{ z_1 }[/math] and [math]\displaystyle{ z_2 }[/math], which can be done using a Box–Muller transform. Given the required correlation coefficient [math]\displaystyle{ \rho }[/math], the correlated normal variables can be obtained via the transformations [math]\displaystyle{ x_1 = z_1 }[/math] and [math]\displaystyle{ x_2 = \rho z_1 + \sqrt{1 - \rho^2} z_2 }[/math].

Kalman filters

Unscented Kalman filters commonly use the Cholesky decomposition to choose a set of so-called sigma points. The Kalman filter tracks the average state of a system as a vector x of length N and covariance as an N × N matrix P. The matrix P is always positive semi-definite and can be decomposed into LLT. The columns of L can be added and subtracted from the mean x to form a set of 2N vectors called sigma points. These sigma points completely capture the mean and covariance of the system state.

Matrix inversion

The explicit inverse of a Hermitian matrix can be computed by Cholesky decomposition, in a manner similar to solving linear systems, using [math]\displaystyle{ n^3 }[/math] operations ([math]\displaystyle{ \tfrac{1}{2} n^3 }[/math] multiplications).[10] The entire inversion can even be efficiently performed in-place.

A non-Hermitian matrix B can also be inverted using the following identity, where BB* will always be Hermitian:

[math]\displaystyle{ \mathbf{B}^{-1} = \mathbf{B}^* (\mathbf{B B}^*)^{-1}. }[/math]

Computation

There are various methods for calculating the Cholesky decomposition. The computational complexity of commonly used algorithms is O(n3) in general.[citation needed] The algorithms described below all involve about (1/3)n3 FLOPs (n3/6 multiplications and the same number of additions) for real flavors and (4/3)n3 FLOPs for complex flavors,[16] where n is the size of the matrix A. Hence, they have half the cost of the LU decomposition, which uses 2n3/3 FLOPs (see Trefethen and Bau 1997).

Which of the algorithms below is faster depends on the details of the implementation. Generally, the first algorithm will be slightly slower because it accesses the data in a less regular manner.

The Cholesky algorithm

The Cholesky algorithm, used to calculate the decomposition matrix L, is a modified version of Gaussian elimination.

The recursive algorithm starts with i := 1 and

A(1) := A.

At step i, the matrix A(i) has the following form:

[math]\displaystyle{ \mathbf{A}^{(i)}= \begin{pmatrix} \mathbf{I}_{i-1} & 0 & 0 \\ 0 & a_{i,i} & \mathbf{b}_{i}^{*} \\ 0 & \mathbf{b}_{i} & \mathbf{B}^{(i)} \end{pmatrix}, }[/math]

where Ii−1 denotes the identity matrix of dimension i − 1.

If the matrix Li is defined by

[math]\displaystyle{ \mathbf{L}_{i}:= \begin{pmatrix} \mathbf{I}_{i-1} & 0 & 0 \\ 0 & \sqrt{a_{i,i}} & 0 \\ 0 & \frac{1}{\sqrt{a_{i,i}}} \mathbf{b}_{i} & \mathbf{I}_{n-i} \end{pmatrix}, }[/math]

(note that ai,i > 0 since A(i) is positive definite), then A(i) can be written as

[math]\displaystyle{ \mathbf{A}^{(i)} = \mathbf{L}_{i} \mathbf{A}^{(i+1)} \mathbf{L}_{i}^{*} }[/math]

where

[math]\displaystyle{ \mathbf{A}^{(i+1)}= \begin{pmatrix} \mathbf{I}_{i-1} & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & \mathbf{B}^{(i)} - \frac{1}{a_{i,i}} \mathbf{b}_{i} \mathbf{b}_{i}^{*} \end{pmatrix}. }[/math]

Note that bi b*i is an outer product, therefore this algorithm is called the outer-product version in (Golub & Van Loan).

This is repeated for i from 1 to n. After n steps, A(n+1) = I is obtained, and hence, the lower triangular matrix L sought for is calculated as

[math]\displaystyle{ \mathbf{L} := \mathbf{L}_{1} \mathbf{L}_{2} \dots \mathbf{L}_{n}. }[/math]

The Cholesky–Banachiewicz and Cholesky–Crout algorithms

Access pattern (white) and writing pattern (yellow) for the in-place Cholesky—Banachiewicz algorithm on a 5×5 matrix

If the equation

[math]\displaystyle{ \begin{align} \mathbf{A} = \mathbf{LL}^T & = \begin{pmatrix} L_{11} & 0 & 0 \\ L_{21} & L_{22} & 0 \\ L_{31} & L_{32} & L_{33}\\ \end{pmatrix} \begin{pmatrix} L_{11} & L_{21} & L_{31} \\ 0 & L_{22} & L_{32} \\ 0 & 0 & L_{33} \end{pmatrix} \\[8pt] & = \begin{pmatrix} L_{11}^2 & &(\text{symmetric}) \\ L_{21}L_{11} & L_{21}^2 + L_{22}^2& \\ L_{31}L_{11} & L_{31}L_{21}+L_{32}L_{22} & L_{31}^2 + L_{32}^2+L_{33}^2 \end{pmatrix}, \end{align} }[/math]

is written out, the following is obtained:

[math]\displaystyle{ \begin{align} \mathbf{L} = \begin{pmatrix} \sqrt{A_{11}} & 0 & 0 \\ A_{21}/L_{11} & \sqrt{A_{22} - L_{21}^2} & 0 \\ A_{31}/L_{11} & \left( A_{32} - L_{31}L_{21} \right) /L_{22} &\sqrt{A_{33}- L_{31}^2 - L_{32}^2} \end{pmatrix} \end{align} }[/math]

and therefore the following formulas for the entries of L:

[math]\displaystyle{ L_{j,j} = (\pm)\sqrt{ A_{j,j} - \sum_{k=1}^{j-1} L_{j,k}^2 }, }[/math]
[math]\displaystyle{ L_{i,j} = \frac{1}{L_{j,j}} \left( A_{i,j} - \sum_{k=1}^{j-1} L_{i,k} L_{j,k} \right) \quad \text{for } i\gt j. }[/math]

For complex and real matrices, inconsequential arbitrary sign changes of diagonal and associated off-diagonal elements are allowed. The expression under the square root is always positive if A is real and positive-definite.

For complex Hermitian matrix, the following formula applies:

[math]\displaystyle{ L_{j,j} = \sqrt{ A_{j,j} - \sum_{k=1}^{j-1} L_{j,k}^*L_{j,k} }, }[/math]
[math]\displaystyle{ L_{i,j} = \frac{1}{L_{j,j}} \left( A_{i,j} - \sum_{k=1}^{j-1} L_{j,k}^* L_{i,k} \right) \quad \text{for } i\gt j. }[/math]

So it now is possible to compute the (i, j) entry if the entries to the left and above are known. The computation is usually arranged in either of the following orders:

  • The Cholesky–Banachiewicz algorithm starts from the upper left corner of the matrix L and proceeds to calculate the matrix row by row.
for (i = 0; i < dimensionSize; i++) {
    for (j = 0; j <= i; j++) {
        float sum = 0;
        for (k = 0; k < j; k++)
            sum += L[i][k] * L[j][k];

        if (i == j)
            L[i][j] = sqrt(A[i][i] - sum);
        else
            L[i][j] = (1.0 / L[j][j] * (A[i][j] - sum));
    }
}

The above algorithm can be succinctly expressed as combining a dot product and matrix multiplication in vectorized programming languages such as Fortran as the following,

do i = 1, size(A,1)
    L(i,i) = sqrt(A(i,i) - dot_product(L(i,1:i-1), L(i,1:i-1)))
    L(i+1:,i) = (A(i+1:,i) - matmul(conjg(L(i,1:i-1)), L(i+1:,1:i-1))) / L(i,i)
end do

where conjg refers to complex conjugate of the elements.

  • The Cholesky–Crout algorithm starts from the upper left corner of the matrix L and proceeds to calculate the matrix column by column.
    for (j = 0; j < dimensionSize; j++) {
   float sum = 0;
   for (k = 0; k < j; k++) {
       sum += L[j][k] * L[j][k];
   }
   L[j][j] = sqrt(A[j][j] - sum);
   for (i = j + 1; i < dimensionSize; i++) {
       sum = 0;
       for (k = 0; k < j; k++) {
           sum += L[i][k] * L[j][k];
       }
       L[i][j] = (1.0 / L[j][j] * (A[i][j] - sum));
   }

}

The above algorithm can be succinctly expressed as combining a dot product and matrix multiplication in vectorized programming languages such as Fortran as the following,

do i = 1, size(A,1)
    L(i,i) = sqrt(A(i,i) - dot_product(L(1:i-1,i), L(1:i-1,i)))
    L(i,i+1:) = (A(i,i+1:) - matmul(conjg(L(1:i-1,i)), L(1:i-1,i+1:))) / L(i,i)
end do

where conjg refers to complex conjugate of the elements.

Either pattern of access allows the entire computation to be performed in-place if desired.

Stability of the computation

Suppose that there is a desire to solve a well-conditioned system of linear equations. If the LU decomposition is used, then the algorithm is unstable unless some sort of pivoting strategy is used. In the latter case, the error depends on the so-called growth factor of the matrix, which is usually (but not always) small.

Now, suppose that the Cholesky decomposition is applicable. As mentioned above, the algorithm will be twice as fast. Furthermore, no pivoting is necessary, and the error will always be small. Specifically, if Ax = b, and y denotes the computed solution, then y solves the perturbed system (A + E)y = b, where

[math]\displaystyle{ \|\mathbf{E}\|_2 \le c_n \varepsilon \|\mathbf{A}\|_2. }[/math]

Here ||·||2 is the matrix 2-norm, cn is a small constant depending on n, and ε denotes the unit round-off.

One concern with the Cholesky decomposition to be aware of is the use of square roots. If the matrix being factorized is positive definite as required, the numbers under the square roots are always positive in exact arithmetic. Unfortunately, the numbers can become negative because of round-off errors, in which case the algorithm cannot continue. However, this can only happen if the matrix is very ill-conditioned. One way to address this is to add a diagonal correction matrix to the matrix being decomposed in an attempt to promote the positive-definiteness.[17] While this might lessen the accuracy of the decomposition, it can be very favorable for other reasons; for example, when performing Newton's method in optimization, adding a diagonal matrix can improve stability when far from the optimum.

LDL decomposition

An alternative form, eliminating the need to take square roots when A is symmetric, is the symmetric indefinite factorization[18]

[math]\displaystyle{ \begin{align} \mathbf{A} = \mathbf{LDL}^\mathrm{T} & = \begin{pmatrix} 1 & 0 & 0 \\ L_{21} & 1 & 0 \\ L_{31} & L_{32} & 1\\ \end{pmatrix} \begin{pmatrix} D_1 & 0 & 0 \\ 0 & D_2 & 0 \\ 0 & 0 & D_3\\ \end{pmatrix} \begin{pmatrix} 1 & L_{21} & L_{31} \\ 0 & 1 & L_{32} \\ 0 & 0 & 1\\ \end{pmatrix} \\[8pt] & = \begin{pmatrix} D_1 & &(\mathrm{symmetric}) \\ L_{21}D_1 & L_{21}^2D_1 + D_2& \\ L_{31}D_1 & L_{31}L_{21}D_{1}+L_{32}D_2 & L_{31}^2D_1 + L_{32}^2D_2+D_3. \end{pmatrix}. \end{align} }[/math]

The following recursive relations apply for the entries of D and L:

[math]\displaystyle{ D_j = A_{jj} - \sum_{k=1}^{j-1} L_{jk}^2 D_k, }[/math]
[math]\displaystyle{ L_{ij} = \frac{1}{D_j} \left( A_{ij} - \sum_{k=1}^{j-1} L_{ik} L_{jk} D_k \right) \quad \text{for } i\gt j. }[/math]

This works as long as the generated diagonal elements in D stay non-zero. The decomposition is then unique. D and L are real if A is real.

For complex Hermitian matrix A, the following formula applies:

[math]\displaystyle{ D_{j} = A_{jj} - \sum_{k=1}^{j-1} L_{jk}L_{jk}^* D_k, }[/math]
[math]\displaystyle{ L_{ij} = \frac{1}{D_j} \left( A_{ij} - \sum_{k=1}^{j-1} L_{ik} L_{jk}^* D_k \right) \quad \text{for } i\gt j. }[/math]

Again, the pattern of access allows the entire computation to be performed in-place if desired.

Block variant

When used on indefinite matrices, the LDL* factorization is known to be unstable without careful pivoting;[19] specifically, the elements of the factorization can grow arbitrarily. A possible improvement is to perform the factorization on block sub-matrices, commonly 2 × 2:[20]

[math]\displaystyle{ \begin{align} \mathbf{A} = \mathbf{LDL}^\mathrm{T} & = \begin{pmatrix} \mathbf I & 0 & 0 \\ \mathbf L_{21} & \mathbf I & 0 \\ \mathbf L_{31} & \mathbf L_{32} & \mathbf I\\ \end{pmatrix} \begin{pmatrix} \mathbf D_1 & 0 & 0 \\ 0 & \mathbf D_2 & 0 \\ 0 & 0 & \mathbf D_3\\ \end{pmatrix} \begin{pmatrix} \mathbf I & \mathbf L_{21}^\mathrm T & \mathbf L_{31}^\mathrm T \\ 0 & \mathbf I & \mathbf L_{32}^\mathrm T \\ 0 & 0 & \mathbf I\\ \end{pmatrix} \\[8pt] & = \begin{pmatrix} \mathbf D_1 & &(\mathrm{symmetric}) \\ \mathbf L_{21} \mathbf D_1 & \mathbf L_{21} \mathbf D_1 \mathbf L_{21}^\mathrm T + \mathbf D_2& \\ \mathbf L_{31} \mathbf D_1 & \mathbf L_{31} \mathbf D_{1} \mathbf L_{21}^\mathrm T + \mathbf L_{32} \mathbf D_2 & \mathbf L_{31} \mathbf D_1 \mathbf L_{31}^\mathrm T + \mathbf L_{32} \mathbf D_2 \mathbf L_{32}^\mathrm T + \mathbf D_3 \end{pmatrix}, \end{align} }[/math]

where every element in the matrices above is a square submatrix. From this, these analogous recursive relations follow:

[math]\displaystyle{ \mathbf D_j = \mathbf A_{jj} - \sum_{k=1}^{j-1} \mathbf L_{jk} \mathbf D_k \mathbf L_{jk}^\mathrm T, }[/math]
[math]\displaystyle{ \mathbf L_{ij} = \left(\mathbf A_{ij} - \sum_{k=1}^{j-1} \mathbf L_{ik} \mathbf D_k \mathbf L_{jk}^\mathrm T\right) \mathbf D_j^{-1}. }[/math]

This involves matrix products and explicit inversion, thus limiting the practical block size.

Updating the decomposition

A task that often arises in practice is that one needs to update a Cholesky decomposition. In more details, one has already computed the Cholesky decomposition [math]\displaystyle{ \mathbf{A} = \mathbf{L}\mathbf{L}^* }[/math] of some matrix [math]\displaystyle{ \mathbf{A} }[/math], then one changes the matrix [math]\displaystyle{ \mathbf{A} }[/math] in some way into another matrix, say [math]\displaystyle{ \tilde{\mathbf{A}} }[/math], and one wants to compute the Cholesky decomposition of the updated matrix: [math]\displaystyle{ \tilde{\mathbf{A}} = \tilde{\mathbf{L}} \tilde{\mathbf{L}}^* }[/math]. The question is now whether one can use the Cholesky decomposition of [math]\displaystyle{ \mathbf{A} }[/math] that was computed before to compute the Cholesky decomposition of [math]\displaystyle{ \tilde{\mathbf{A}} }[/math].

Rank-one update

The specific case, where the updated matrix [math]\displaystyle{ \tilde{\mathbf{A}} }[/math] is related to the matrix [math]\displaystyle{ \mathbf{A} }[/math] by [math]\displaystyle{ \tilde{\mathbf{A}} = \mathbf{A} + \mathbf{x} \mathbf{x}^* }[/math], is known as a rank-one update.

Here is a function[21] written in Matlab syntax that realizes a rank-one update:

function [L] = cholupdate(L, x)
    n = length(x);
    for k = 1:n
        r = sqrt(L(k, k)^2 + x(k)^2);
        c = r / L(k, k);
        s = x(k) / L(k, k);
        L(k, k) = r;
        if k < n
            L((k+1):n, k) = (L((k+1):n, k) + s * x((k+1):n)) / c;
            x((k+1):n) = c * x((k+1):n) - s * L((k+1):n, k);
        end
    end
end

A rank-n update is one where for a matrix [math]\displaystyle{ \mathbf{M} }[/math] one updates the decomposition such that [math]\displaystyle{ \tilde{\mathbf{A}} = \mathbf{A} + \mathbf{M} \mathbf{M}^* }[/math]. This can be achieved by successively performing rank-one updates for each of the columns of [math]\displaystyle{ \mathbf{M} }[/math].

Rank-one downdate

A rank-one downdate is similar to a rank-one update, except that the addition is replaced by subtraction: [math]\displaystyle{ \tilde{\mathbf{A}} = \mathbf{A} - \mathbf{x} \mathbf{x}^* }[/math]. This only works if the new matrix [math]\displaystyle{ \tilde{\mathbf{A}} }[/math] is still positive definite.

The code for the rank-one update shown above can easily be adapted to do a rank-one downdate: one merely needs to replace the two additions in the assignment to r and L((k+1):n, k) by subtractions.

Adding and removing rows and columns

If a symmetric and positive definite matrix [math]\displaystyle{ \mathbf A }[/math] is represented in block form as

[math]\displaystyle{ \mathbf{A} = \begin{pmatrix} \mathbf A_{11} & \mathbf A_{13} \\ \mathbf A_{13}^{\mathrm{T}} & \mathbf A_{33} \\ \end{pmatrix} }[/math]

and its upper Cholesky factor

[math]\displaystyle{ \mathbf{L} = \begin{pmatrix} \mathbf L_{11} & \mathbf L_{13} \\ 0 & \mathbf L_{33} \\ \end{pmatrix}, }[/math]

then for a new matrix [math]\displaystyle{ \tilde{\mathbf{A}} }[/math], which is the same as [math]\displaystyle{ \mathbf A }[/math] but with the insertion of new rows and columns,

[math]\displaystyle{ \begin{align} \tilde{\mathbf{A}} &= \begin{pmatrix} \mathbf A_{11} & \mathbf A_{12} & \mathbf A_{13} \\ \mathbf A_{12}^{\mathrm{T}} & \mathbf A_{22} & \mathbf A_{23} \\ \mathbf A_{13}^{\mathrm{T}} & \mathbf A_{23}^{\mathrm{T}} & \mathbf A_{33} \\ \end{pmatrix} \end{align} }[/math]

Now there is an interest in finding the Cholesky factorization of [math]\displaystyle{ \tilde{\mathbf{A}} }[/math], which can be called [math]\displaystyle{ \tilde{\mathbf S} }[/math], without directly computing the entire decomposition.

[math]\displaystyle{ \begin{align} \tilde{\mathbf{S}} &= \begin{pmatrix} \mathbf S_{11} & \mathbf S_{12} & \mathbf S_{13} \\ 0 & \mathbf S_{22} & \mathbf S_{23} \\ 0 & 0 & \mathbf S_{33} \\ \end{pmatrix}. \end{align} }[/math]

Writing [math]\displaystyle{ \mathbf A \setminus \mathbf{b} }[/math] for the solution of [math]\displaystyle{ \mathbf A \mathbf x = \mathbf b }[/math], which can be found easily for triangular matrices, and [math]\displaystyle{ \text{chol} (\mathbf M) }[/math] for the Cholesky decomposition of [math]\displaystyle{ \mathbf M }[/math], the following relations can be found:

[math]\displaystyle{ \begin{align} \mathbf S_{11} &= \mathbf L_{11}, \\ \mathbf S_{12} &= \mathbf L_{11}^{\mathrm{T}} \setminus \mathbf A_{12}, \\ \mathbf S_{13} &= \mathbf L_{13}, \\ \mathbf S_{22} &= \mathrm{chol} \left(\mathbf A_{22} - \mathbf S_{12}^{\mathrm{T}} \mathbf S_{12}\right), \\ \mathbf S_{23} &= \mathbf S_{22}^{\mathrm{T}} \setminus \left(\mathbf A_{23} - \mathbf S_{12}^{\mathrm{T}} \mathbf S_{13}\right), \\ \mathbf S_{33} &= \mathrm{chol} \left(\mathbf L_{33}^{\mathrm{T}} \mathbf L_{33} - \mathbf S_{23}^{\mathrm{T}} \mathbf S_{23}\right). \end{align} }[/math]

These formulas may be used to determine the Cholesky factor after the insertion of rows or columns in any position, if the row and column dimensions are appropriately set (including to zero). The inverse problem,

[math]\displaystyle{ \begin{align} \tilde{\mathbf{A}} &= \begin{pmatrix} \mathbf A_{11} & \mathbf A_{12} & \mathbf A_{13} \\ \mathbf A_{12}^{\mathrm{T}} & \mathbf A_{22} & \mathbf A_{23} \\ \mathbf A_{13}^{\mathrm{T}} & \mathbf A_{23}^{\mathrm{T}} & \mathbf A_{33} \\ \end{pmatrix} \end{align} }[/math]

with known Cholesky decomposition

[math]\displaystyle{ \begin{align} \tilde{\mathbf{S}} &= \begin{pmatrix} \mathbf S_{11} & \mathbf S_{12} & \mathbf S_{13} \\ 0 & \mathbf S_{22} & \mathbf S_{23} \\ 0 & 0 & \mathbf S_{33} \\ \end{pmatrix} \end{align} }[/math]

and the desire to determine the Cholesky factor

[math]\displaystyle{ \begin{align} \mathbf{L} &= \begin{pmatrix} \mathbf L_{11} & \mathbf L_{13} \\ 0 & \mathbf L_{33} \\ \end{pmatrix} \end{align} }[/math]

of the matrix [math]\displaystyle{ \mathbf A }[/math] with rows and columns removed,

[math]\displaystyle{ \begin{align} \mathbf{A} &= \begin{pmatrix} \mathbf A_{11} & \mathbf A_{13} \\ \mathbf A_{13}^{\mathrm{T}} & \mathbf A_{33} \\ \end{pmatrix}, \end{align} }[/math]

yields the following rules:

[math]\displaystyle{ \begin{align} \mathbf L_{11} &= \mathbf S_{11}, \\ \mathbf L_{13} &= \mathbf S_{13}, \\ \mathbf L_{33} &= \mathrm{chol} \left(\mathbf S_{33}^{\mathrm{T}} \mathbf S_{33} + \mathbf S_{23}^{\mathrm{T}} \mathbf S_{23}\right). \end{align} }[/math]

Notice that the equations above that involve finding the Cholesky decomposition of a new matrix are all of the form [math]\displaystyle{ \tilde{\mathbf{A}} = \mathbf{A} \pm \mathbf{x} \mathbf{x}^* }[/math], which allows them to be efficiently calculated using the update and downdate procedures detailed in the previous section.[22]

Proof for positive semi-definite matrices

Proof by limiting argument

The above algorithms show that every positive definite matrix [math]\displaystyle{ \mathbf{A} }[/math] has a Cholesky decomposition. This result can be extended to the positive semi-definite case by a limiting argument. The argument is not fully constructive, i.e., it gives no explicit numerical algorithms for computing Cholesky factors.

If [math]\displaystyle{ \mathbf{A} }[/math] is an [math]\displaystyle{ n \times n }[/math] positive semi-definite matrix, then the sequence [math]\displaystyle{ \left(\mathbf{A}_k\right)_k := \left(\mathbf{A} + \frac{1}{k} \mathbf{I}_n\right)_k }[/math] consists of positive definite matrices. (This is an immediate consequence of, for example, the spectral mapping theorem for the polynomial functional calculus.) Also,

[math]\displaystyle{ \mathbf{A}_k \rightarrow \mathbf{A} \quad \text{for} \quad k \rightarrow \infty }[/math]

in operator norm. From the positive definite case, each [math]\displaystyle{ \mathbf{A}_k }[/math] has Cholesky decomposition [math]\displaystyle{ \mathbf{A}_k = \mathbf{L}_k\mathbf{L}_k^* }[/math]. By property of the operator norm,

[math]\displaystyle{ \| \mathbf{L}_k \|^2 \leq \| \mathbf{L}_k \mathbf{L}_k^* \| = \| \mathbf{A}_k \| \,. }[/math]

The [math]\displaystyle{ \leq }[/math] holds because [math]\displaystyle{ M_n(\mathbb{C}) }[/math] equipped with the operator norm is a C* algebra. So [math]\displaystyle{ \left(\mathbf{L}_k \right)_k }[/math] is a bounded set in the Banach space of operators, therefore relatively compact (because the underlying vector space is finite-dimensional). Consequently, it has a convergent subsequence, also denoted by [math]\displaystyle{ \left( \mathbf{L}_k \right)_k }[/math], with limit [math]\displaystyle{ \mathbf{L} }[/math]. It can be easily checked that this [math]\displaystyle{ \mathbf{L} }[/math] has the desired properties, i.e. [math]\displaystyle{ \mathbf{A} = \mathbf{L}\mathbf{L}^* }[/math], and [math]\displaystyle{ \mathbf{L} }[/math] is lower triangular with non-negative diagonal entries: for all [math]\displaystyle{ x }[/math] and [math]\displaystyle{ y }[/math],

[math]\displaystyle{ \langle \mathbf{A} x, y \rangle = \left\langle \lim \mathbf{A}_k x, y \right\rangle = \langle \lim \mathbf{L}_k \mathbf{L}_k^* x, y \rangle = \langle \mathbf{L} \mathbf{L}^*x, y \rangle \,. }[/math]

Therefore, [math]\displaystyle{ \mathbf{A} = \mathbf{L}\mathbf{L}^* }[/math]. Because the underlying vector space is finite-dimensional, all topologies on the space of operators are equivalent. So [math]\displaystyle{ \left( \mathbf{L}_k \right)_k }[/math] tends to [math]\displaystyle{ \mathbf{L} }[/math] in norm means [math]\displaystyle{ \left( \mathbf{L}_k \right)_k }[/math] tends to [math]\displaystyle{ \mathbf{L} }[/math] entrywise. This in turn implies that, since each [math]\displaystyle{ \mathbf{L}_k }[/math] is lower triangular with non-negative diagonal entries, [math]\displaystyle{ \mathbf{L} }[/math] is also.

Proof by QR decomposition

Let [math]\displaystyle{ \mathbf{A} }[/math] be a positive semi-definite Hermitian matrix. Then it can be written as a product of its square root matrix, [math]\displaystyle{ \mathbf{A} = \mathbf{B} \mathbf{B}^* }[/math]. Now QR decomposition can be applied to [math]\displaystyle{ \mathbf{B}^* }[/math], resulting in [math]\displaystyle{ \mathbf{B}^* = \mathbf{Q}\mathbf{R} }[/math] , where [math]\displaystyle{ \mathbf{Q} }[/math] is unitary and [math]\displaystyle{ \mathbf{R} }[/math] is upper triangular. Inserting the decomposition into the original equality yields [math]\displaystyle{ A = \mathbf{B} \mathbf{B}^* = (\mathbf{QR})^*\mathbf{QR} = \mathbf{R}^*\mathbf{Q}^*\mathbf{QR} = \mathbf{R}^*\mathbf{R} }[/math]. Setting [math]\displaystyle{ \mathbf{L} = \mathbf{R}^* }[/math] completes the proof.

Generalization

The Cholesky factorization can be generalized[citation needed] to (not necessarily finite) matrices with operator entries. Let [math]\displaystyle{ \{\mathcal{H}_n \} }[/math] be a sequence of Hilbert spaces. Consider the operator matrix

[math]\displaystyle{ \mathbf{A} = \begin{bmatrix} \mathbf{A}_{11} & \mathbf{A}_{12} & \mathbf{A}_{13} & \; \\ \mathbf{A}_{12}^* & \mathbf{A}_{22} & \mathbf{A}_{23} & \; \\ \mathbf{A} _{13}^* & \mathbf{A}_{23}^* & \mathbf{A}_{33} & \; \\ \; & \; & \; & \ddots \end{bmatrix} }[/math]

acting on the direct sum

[math]\displaystyle{ \mathcal{H} = \bigoplus_n \mathcal{H}_n, }[/math]

where each

[math]\displaystyle{ \mathbf{A}_{ij} : \mathcal{H}_j \rightarrow \mathcal{H} _i }[/math]

is a bounded operator. If A is positive (semidefinite) in the sense that for all finite k and for any

[math]\displaystyle{ h \in \bigoplus_{n = 1}^k \mathcal{H}_k , }[/math]

there is [math]\displaystyle{ \langle h, \mathbf{A} h\rangle \ge 0 }[/math], then there exists a lower triangular operator matrix L such that A = LL*. One can also take the diagonal entries of L to be positive.

Implementations in programming libraries

  • C programming language: the GNU Scientific Library provides several implementations of Cholesky decomposition.
  • Maxima computer algebra system: function cholesky computes Cholesky decomposition.
  • GNU Octave numerical computations system provides several functions to calculate, update, and apply a Cholesky decomposition.
  • The LAPACK library provides a high performance implementation of the Cholesky decomposition that can be accessed from Fortran, C and most languages.
  • In Python, the function cholesky from the numpy.linalg module performs Cholesky decomposition.
  • In Matlab, the chol function gives the Cholesky decomposition. Note that chol uses the upper triangular factor of the input matrix by default, i.e. it computes [math]\displaystyle{ A = R^* R }[/math] where [math]\displaystyle{ R }[/math] is upper triangular. A flag can be passed to use the lower triangular factor instead.
  • In R, the chol function gives the Cholesky decomposition.
  • In Julia, the cholesky function from the LinearAlgebra standard library gives the Cholesky decomposition.
  • In Mathematica, the function "CholeskyDecomposition" can be applied to a matrix.
  • In C++, multiple linear algebra libraries support this decomposition:
    • The Armadillo (C++ library) supplies the command chol to perform Cholesky decomposition.
    • The Eigen library supplies Cholesky factorizations for both sparse and dense matrices.
    • In the ROOT package, the TDecompChol class is available.

See also

Notes

  1. Benoit (1924). "Note sur une méthode de résolution des équations normales provenant de l'application de la méthode des moindres carrés à un système d'équations linéaires en nombre inférieur à celui des inconnues (Procédé du Commandant Cholesky)" (in fr). Bulletin Géodésique 2: 66–67. doi:10.1007/BF03031308. 
  2. 2.0 2.1 Press, William H.; Saul A. Teukolsky; William T. Vetterling; Brian P. Flannery (1992). Numerical Recipes in C: The Art of Scientific Computing (second ed.). Cambridge University England EPress. p. 994. ISBN 0-521-43108-5. https://archive.org/details/numericalrecipes0865unse/page/994. Retrieved 2009-01-28. 
  3. (Golub Van Loan), (Horn Johnson), (Trefethen Bau).
  4. (Horn Johnson).
  5. "matrices - Diagonalizing a Complex Symmetric Matrix". https://mathoverflow.net/questions/125960/diagonalizing-a-complex-symmetric-matrix. 
  6. Schabauer, Hannes; Pacher, Christoph; Sunderland, Andrew G.; Gansterer, Wilfried N. (2010-05-01). "Toward a parallel solver for generalized complex symmetric eigenvalue problems" (in en). Procedia Computer Science. ICCS 2010 1 (1): 437–445. doi:10.1016/j.procs.2010.04.047. ISSN 1877-0509. 
  7. (Golub Van Loan).
  8. Gentle, James E. (1998) (in en). Numerical Linear Algebra for Applications in Statistics. Springer. p. 94. ISBN 978-1-4612-0623-1. 
  9. Higham, Nicholas J. (1990). "Analysis of the Cholesky Decomposition of a Semi-definite Matrix". in Cox, M. G. (in en). Reliable Numerical Computation. Oxford, UK: Oxford University Press. pp. 161–185. ISBN 978-0-19-853564-5. http://eprints.maths.manchester.ac.uk/1193/. 
  10. 10.0 10.1 Krishnamoorthy, Aravindh; Menon, Deepak (2011). Matrix Inversion Using Cholesky Decomposition. 1111. p. 4144. Bibcode2011arXiv1111.4144K. 
  11. So, Anthony Man-Cho (2007). A Semidefinite Programming Approach to the Graph Realization Problem: Theory, Applications and Extensions (PDF) (PhD). Theorem 2.2.6.
  12. (Golub Van Loan)
  13. Pope, Stephen B. "Algorithms for ellipsoids." Cornell University Report No. FDA (2008): 08-01.
  14. Arora, Jasbir Singh (2004-06-02) (in en). Introduction to Optimum Design. Elsevier. ISBN 978-0-08-047025-2. https://books.google.com/books?id=9FbwVe577xwC&pg=PA327. 
  15. Matlab randn documentation. mathworks.com.
  16. ?potrf Intel® Math Kernel Library [1]
  17. Fang, Haw-ren; O'Leary, Dianne P. (8 August 2006). Modified Cholesky Algorithms: A Catalog with New Approaches. http://www.cs.umd.edu/~oleary/tr/tr4807.pdf. 
  18. Watkins, D. (1991). Fundamentals of Matrix Computations. New York: Wiley. p. 84. ISBN 0-471-61414-9. https://archive.org/details/fundamentalsofma0000watk. 
  19. Nocedal, Jorge (2000). Numerical Optimization. Springer. 
  20. Fang, Haw-ren (24 August 2007). Analysis of Block LDLT Factorizations for Symmetric Indefinite Matrices. 
  21. Based on: Stewart, G. W. (1998). Basic decompositions. Philadelphia: Soc. for Industrial and Applied Mathematics. ISBN 0-89871-414-1. 
  22. Osborne, M. (2010), Appendix B.

References

External links

History of science

  • Sur la résolution numérique des systèmes d'équations linéaires, Cholesky's 1910 manuscript, online and analyzed on BibNum (in French and English) [for English, click 'A télécharger']

Information

Computer code

Use of the matrix in simulation

Online calculators