In linear algebra, the Cholesky decomposition or Cholesky factorization (pronounced) 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]
The Cholesky decomposition of a Hermitian positive-definite matrix A, is a decomposition of the form
A=LL*,
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
A=LLT,
If a Hermitian matrix A is only positive semidefinite, instead of positive definite, then it still has a decomposition of the form where the diagonal entries of L are allowed to be zero.[7] The decomposition need not be unique, for example:
\begin{bmatrix}0&0\\0&1\end{bmatrix}=LL*, L=\begin{bmatrix}0&0\ \cos\theta&\sin\theta\end{bmatrix},
Alternatively, the decomposition can be made unique when a pivoting choice is fixed. Formally, if A is an positive semidefinite matrix of rank r, then there is at least one permutation matrix P such that has a unique decomposition of the form with
L=\begin{bmatrix}L1&0\ L2&0\end{bmatrix}
A closely related variant of the classical Cholesky decomposition is the LDL decomposition,
A=LDL*,
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 and is often referred to as LDLT decomposition (or LDLT decomposition, or LDL′). It is reminiscent of the eigendecomposition of real symmetric matrices,, 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:
A=LDL*=LD1/2\left(D1/2\right)*L*= LD1/2\left(LD1/2\right)*.
Conversely, given the classical Cholesky decomposition
A=CC*
C
LDL*
L=CS-1
D=S2.
If A is positive definite then the diagonal elements of D are all positive.For positive semidefinite A, an
LDL*
Here is the Cholesky decomposition of a symmetric real matrix:
\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}
And here is its LDLT decomposition:
\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}
See also: Whitening transformation. The Cholesky decomposition is equivalent to a particular choice of conjugate axes of an ellipsoid.[12] In detail, let the ellipsoid be defined as
yTAy=1
v1,...,vn
T | |
v | |
i |
Avj=\deltaij
f
ei\mapstovi
Sn
Define the matrix
V:=[v1|v2| … |vn]
T | |
v | |
i |
Avj=\deltaij
VTAV=I
The Cholesky decomposition corresponds to choosing
v1
v2
V
A=LLT
L=(V-1)T
Similarly, principal component analysis corresponds to choosing
v1,...,vn
λ=
2 | |
1/\|v | |
i\| |
\Sigma=diag(λ1,...,λn)
V=U\Sigma-1/2
U
A=U\SigmaUT
Ax=b
Ax=b
A=LL*
Ly=b
L*x |
=y
An alternative way to eliminate taking square roots in the
LL*
A=LDL*
Ly=b
DL*x=y
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]
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 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
pk
Bkpk=-gk
pk
pk
gk
Bk
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 observations in a sample u produces a sample vector Lu with the covariance properties of the system being modeled.[14]
The following simplified example shows the economy one gets from the Cholesky decomposition: suppose the goal is to generate two correlated normal variables
x1
x2
\rho
z1
z2
\rho
x1=z1
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.
The explicit inverse of a Hermitian matrix can be computed by Cholesky decomposition, in a manner similar to solving linear systems, using
n3
\tfrac{1}{2}n3
A non-Hermitian matrix B can also be inverted using the following identity, where BB* will always be Hermitian:
B-1=B*(BB*)-1.
There are various methods for calculating the Cholesky decomposition. The computational complexity of commonly used algorithms is O(n3) in general. 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,[15] 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, 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:
A(i)= \begin{pmatrix} Ii-1&0&0\\ 0&ai,i&
* | |
b | |
i |
\\ 0&bi&B(i)\end{pmatrix},
If the matrix Li is defined by
Li:= \begin{pmatrix} Ii-1&0&0\\ 0&\sqrt{ai,i
A(i)=LiA(i+1)
* | |
L | |
i |
A(i+1)= \begin{pmatrix} Ii-1&0&0\\ 0&1&0\\ 0&0&B(i)-
1 | |
ai,i |
bi
* | |
b | |
i |
\end{pmatrix}.
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
L:=L1L2...Ln.
If the equation
\begin{align} A=LLT&= \begin{pmatrix}L11&0&0\\ L21&L22&0\\ L31&L32&L33\\ \end{pmatrix} \begin{pmatrix}L11&L21&L31\\ 0&L22&L32\\ 0&0&L33\end{pmatrix}\\[8pt] &= \begin{pmatrix}
2 | |
L | |
11 |
&&(symmetric)\\ L21L11&
2 | |
L | |
21 |
+
2& | |
L | |
22 |
\\ L31L11&L31L21+L32L22&
2 | |
L | |
31 |
+
2 \end{pmatrix}, \end{align} | |
L | |
33 |
is written out, the following is obtained:
\begin{align} L=\begin{pmatrix}\sqrt{A11
and therefore the following formulas for the entries of L:
Lj,j=(\pm)\sqrt{Aj,j-
j-1 | |
\sum | |
k=1 |
2 | |
L | |
j,k |
},
Li,j=
1 | |
Lj,j |
\left(Ai,j-
j-1 | |
\sum | |
k=1 |
Li,kLj,k\right) fori>j.
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:
Lj,j=\sqrt{Aj,j-
j-1 | |
\sum | |
k=1 |
*L | |
L | |
j,k |
},
Li,j=
1 | |
Lj,j |
\left(Ai,j-
j-1 | |
\sum | |
k=1 |
* | |
L | |
j,k |
Li,k\right) fori>j.
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:
conjg
refers to complex conjugate of the elements.
for (j = 0; j < dimensionSize; j++) 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,conjg
refers to complex conjugate of the elements.
Either pattern of access allows the entire computation to be performed in-place if desired.
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
\|E\|2\lecn\varepsilon\|A\|2.
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.[16] 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.
An alternative form, eliminating the need to take square roots when A is symmetric, is the symmetric indefinite factorization[17]
\begin{align} A=LDLT&= \begin{pmatrix}1&0&0\\ L21&1&0\\ L31&L32&1\\ \end{pmatrix} \begin{pmatrix}D1&0&0\\ 0&D2&0\\ 0&0&D3\\ \end{pmatrix} \begin{pmatrix}1&L21&L31\\ 0&1&L32\\ 0&0&1\\ \end{pmatrix}\\[8pt] &=\begin{pmatrix}D1&&(symmetric)\\ L21D1&
2D | |
L | |
1 |
+D2&\\ L31D1&L31L21D1+L32D2&
2D | |
L | |
1 |
+
2D | |
L | |
2+D |
3. \end{pmatrix}. \end{align}
The following recursive relations apply for the entries of D and L:
Dj=Ajj-
j-1 | |
\sum | |
k=1 |
2 | |
L | |
jk |
Dk,
Lij=
1 | |
Dj |
\left(Aij-
j-1 | |
\sum | |
k=1 |
LikLjkDk\right) fori>j.
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:
Dj=Ajj-
j-1 | |
\sum | |
k=1 |
Ljk
* | |
L | |
jk |
Dk,
Lij=
1 | |
Dj |
\left(Aij-
j-1 | |
\sum | |
k=1 |
Lik
* | |
L | |
jk |
Dk\right) fori>j.
Again, the pattern of access allows the entire computation to be performed in-place if desired.
When used on indefinite matrices, the LDL* factorization is known to be unstable without careful pivoting;[18] specifically, the elements of the factorization can grow arbitrarily. A possible improvement is to perform the factorization on block sub-matrices, commonly 2 × 2:[19]
\begin{align} A=LDLT&= \begin{pmatrix} I&0&0\\ L21&I&0\\ L31&L32&I\\ \end{pmatrix} \begin{pmatrix} D1&0&0\\ 0&D2&0\\ 0&0&D3\\ \end{pmatrix} \begin{pmatrix} I&
T& | |
L | |
21 |
T\\ | |
L | |
31 |
0&I&
T\\ | |
L | |
32 |
0&0&I\\ \end{pmatrix}\\[8pt] &=\begin{pmatrix} D1&&(symmetric)\\ L21D1&L21D1
T+ | |
L | |
21 |
D2&\\ L31D1&L31D1
T+ | |
L | |
21 |
L32D2&L31D1
T+ | |
L | |
31 |
L32D2
T+ | |
L | |
32 |
D3 \end{pmatrix}, \end{align}
where every element in the matrices above is a square submatrix. From this, these analogous recursive relations follow:
Dj=Ajj-
j-1 | |
\sum | |
k=1 |
LjkDk
T, | |
L | |
jk |
Lij=\left(Aij-
j-1 | |
\sum | |
k=1 |
LikDk
-1 | |
L | |
j |
.
This involves matrix products and explicit inversion, thus limiting the practical block size.
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
A=LL*
A
A
\tilde{A
\tilde{A
A
\tilde{A
The specific case, where the updated matrix
\tilde{A
A
\tilde{A
Here is a function[20] written in Matlab syntax that realizes a rank-one update:
M
\tilde{A
M
A rank-one downdate is similar to a rank-one update, except that the addition is replaced by subtraction:
\tilde{A
\tilde{A
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.
If a symmetric and positive definite matrix
A
A=\begin{pmatrix} A11&A13\\
T | |
A | |
13 |
&A33\\ \end{pmatrix}
and its upper Cholesky factor
L=\begin{pmatrix} L11&L13\\ 0&L33\\ \end{pmatrix},
then for a new matrix
\tilde{A
A
\begin{align} \tilde{A
Now there is an interest in finding the Cholesky factorization of
\tilde{A
\tilde{S}
\begin{align} \tilde{S
Writing
A\setminusb
Ax=b
chol(M)
M
\begin{align} S11&=L11,\\ S12&=
T | |
L | |
11 |
\setminusA12,\\ S13&=L13,\\ S22&=chol\left(A22-
T | |
S | |
12 |
S12\right),\\ S23&=
T | |
S | |
22 |
\setminus\left(A23-
T | |
S | |
12 |
S13\right),\\ S33&=chol
T | |
\left(L | |
33 |
L33-
T | |
S | |
23 |
S23\right). \end{align}
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,
\begin{align} \tilde{A
\begin{align} \tilde{S
and the desire to determine the Cholesky factor
\begin{align} L&=\begin{pmatrix} L11&L13\\ 0&L33\\ \end{pmatrix} \end{align}
of the matrix
A
\begin{align} A&=\begin{pmatrix} A11&A13\\
T | |
A | |
13 |
&A33\\ \end{pmatrix}, \end{align}
yields the following rules:
\begin{align} L11&=S11,\\ L13&=S13,\\ L33&=chol
T | |
\left(S | |
33 |
S33+
T | |
S | |
23 |
S23\right). \end{align}
Notice that the equations above that involve finding the Cholesky decomposition of a new matrix are all of the form
\tilde{A
The above algorithms show that every positive definite matrix
A
If
A
n x n
Ak → A for k → infty
Ak
Ak=LkL
* | |
k |
\|Lk\|2\leq\|Lk
* | |
L | |
k |
\|=\|Ak\|.
The
\leq
Mn(C)
\left(Lk\right)k
\left(Lk\right)k
L
L
A=LL*
L
x
y
\langleAx,y\rangle=\left\langle\limAkx,y\right\rangle=\langle\limLk
* | |
L | |
k |
x,y\rangle=\langleLL*x,y\rangle.
Therefore,
A=LL*
\left(Lk\right)k
L
\left(Lk\right)k
L
Lk
L
Let
A
A=BB*
B*
B*=QR
Q
R
A=BB*=(QR)*QR=R*Q*QR=R*R
L=R*
The Cholesky factorization can be generalized to (not necessarily finite) matrices with operator entries. Let
\{l{H}n\}
A= \begin{bmatrix} A11&A12&A13&
* | |
\\ A | |
12 |
&A22&A23& \\ A
* | |
13 |
&
* | |
A | |
23 |
&A33& \\ & & &\ddots \end{bmatrix}
acting on the direct sum
l{H}=oplusnl{H}n,
where each
Aij:l{H}j → l{H}i
is a bounded operator. If A is positive (semidefinite) in the sense that for all finite k and for any
h\in
k | |
oplus | |
n=1 |
l{H}k,
there is
\langleh,Ah\rangle\ge0
cholesky
computes Cholesky decomposition.cholesky
from the numpy.linalg
module performs Cholesky decomposition.chol
function gives the Cholesky decomposition. Note that chol
uses the upper triangular factor of the input matrix by default, i.e. it computesA=R*R
R
chol
function gives the Cholesky decomposition.cholesky
function from the LinearAlgebra
standard library gives the Cholesky decomposition.CholeskyDecomposition
" can be applied to a matrix.chol
to perform Cholesky decomposition.TDecompChol
class is available.Decompose
gives the Cholesky decomposition.