Template:Short description Template:CS1 config In linear algebra, the Cholesky decomposition or Cholesky factorization (pronounced Template:IPAc-en Template:Respell) 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.<ref name="Bulletin">Template:Cite journal</ref> When it is applicable, the Cholesky decomposition is roughly twice as efficient as the LU decomposition for solving systems of linear equations.<ref name="NR">Template:Cite book</ref>
StatementEdit
The Cholesky decomposition of a Hermitian positive-definite matrix Template:Math, is a decomposition of the form
<math display=block>\mathbf{A} = \mathbf{L L}^{*},</math>
where Template:Math is a lower triangular matrix with real and positive diagonal entries, and Template:Math* denotes the conjugate transpose of Template:Math. Every Hermitian positive-definite matrix (and thus also every real-valued symmetric positive-definite matrix) has a unique Cholesky decomposition.<ref>Template:Harvtxt, Template:Harvtxt, Template:Harvtxt.</ref>
The converse holds trivially: if Template:Math can be written as Template:Math for some invertible Template:Math, lower triangular or otherwise, then Template:Math is Hermitian and positive definite.
When Template:Math is a real matrix (hence symmetric positive-definite), the factorization may be written <math display=block>\mathbf{A} = \mathbf{L L}^\mathsf{T},</math> where Template:Math is a real lower triangular matrix with positive diagonal entries.<ref>Template:Harvtxt.</ref><ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref><ref>Template:Cite journal</ref>
Positive semidefinite matricesEdit
If a Hermitian matrix Template:Math is only positive semidefinite, instead of positive definite, then it still has a decomposition of the form Template:Math where the diagonal entries of Template:Math are allowed to be zero.<ref>Template:Harvtxt.</ref> The decomposition need not be unique, for example: <math display=block>\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> for any Template:Mvar. However, if the rank of Template:Math is Template:Mvar, then there is a unique lower triangular Template:Math with exactly Template:Mvar positive diagonal elements and Template:Math columns containing all zeroes.<ref> Template:Cite book</ref>
Alternatively, the decomposition can be made unique when a pivoting choice is fixed. Formally, if Template:Math is an Template:Math positive semidefinite matrix of rank Template:Mvar, then there is at least one permutation matrix Template:Math such that Template:Math has a unique decomposition of the form Template:Math with <math display=inline> \mathbf L = \begin{bmatrix} \mathbf L_1 & 0 \\ \mathbf L_2 & 0\end{bmatrix} </math>, where Template:Math is an Template:Math lower triangular matrix with positive diagonal.<ref>Template:Cite book</ref>
LDL decompositionEdit
A closely related variant of the classical Cholesky decomposition is the LDL decomposition,
<math display=block>\mathbf{A} = \mathbf{L D L}^*,</math>
where Template:Math is a lower unit triangular (unitriangular) matrix, and Template:Math is a diagonal matrix. That is, the diagonal elements of Template:Math are required to be 1 at the cost of introducing an additional diagonal matrix Template:Math 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.<ref name="kri">Template:Cite conference</ref>
For this reason, the LDL decomposition is often called the square-root-free Cholesky decomposition. For real matrices, the factorization has the form Template:Math and is often referred to as Template:Math decomposition (or Template:Math decomposition, or LDL′). It is reminiscent of the eigendecomposition of real symmetric matrices, Template:Math, but is quite different in practice because Template:Math and Template:Math are not similar matrices.
The LDL decomposition is related to the classical Cholesky decomposition of the form Template:Math as follows:
<math display=block>\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 display=inline>\mathbf A = \mathbf C \mathbf C^*</math> of a positive definite matrix, if Template:Math is a diagonal matrix that contains the main diagonal of <math display=inline>\mathbf C</math>, then Template:Math can be decomposed as <math display=inline>\mathbf L \mathbf D \mathbf L^*</math> where <math display=block> \mathbf L = \mathbf C \mathbf S^{-1} </math> (this rescales each column to make diagonal elements 1), <math display="block"> \mathbf D = \mathbf S\mathbf S^*. </math>
If Template:Math is positive definite then the diagonal elements of Template:Math are all positive. For positive semidefinite Template:Math, an <math display=inline>\mathbf L \mathbf D \mathbf L^*</math> decomposition exists where the number of non-zero elements on the diagonal Template:Math is exactly the rank of Template:Math.<ref>Template:Cite thesis</ref> Some indefinite matrices for which no Cholesky decomposition exists have an LDL decomposition with negative entries in Template:Math: it suffices that the first Template:Math leading principal minors of Template:Math are non-singular.<ref>Template:Harvtxt</ref>
ExampleEdit
Here is the Cholesky decomposition of a symmetric real matrix:
<math display=block>\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 display=block>\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 interpretationEdit
The Cholesky decomposition is equivalent to a particular choice of conjugate axes of an ellipsoid.<ref>Pope, Stephen B. "Algorithms for ellipsoids." Cornell University Report No. FDA (2008): 08-01.</ref> In detail, let the ellipsoid be defined as <math display=inline>y^TAy = 1</math>, then by definition, a set of vectors <math display=inline>v_1, ..., v_n</math> are conjugate axes of the ellipsoid iff <math display=inline>v_i^T A v_j = \delta_{ij}</math>. Then, the ellipsoid is precisely<math display="block">\left\{ \sum_i x_i v_i : x^T x = 1 \right\} = f(\mathbb S^n)</math>where <math display=inline>f</math> maps the basis vector <math display=inline>e_i \mapsto v_i</math>, and <math display=inline>\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 display=inline>V := [v_1 | v_2 | \cdots | v_n]</math>, then <math display=inline>v_i^T A v_j = \delta_{ij}</math> is equivalent to <math display=inline>V^TAV = I</math>. Different choices of the conjugate axes correspond to different decompositions.
The Cholesky decomposition corresponds to choosing <math display=inline>v_1</math> to be parallel to the first axis, <math display=inline>v_2</math> to be within the plane spanned by the first two axes, and so on. This makes <math display=inline>V</math> an upper-triangular matrix. Then, there is <math display=inline>A = LL^T</math>, where <math display=inline>L = (V^{-1})^T</math> is lower-triangular.
Similarly, principal component analysis corresponds to choosing <math display=inline>v_1, ..., v_n</math> to be perpendicular. Then, let <math display=inline>\lambda = 1/\|v_i\|^2</math> and <math display=inline>\Sigma = \mathrm{diag}(\lambda_1, ..., \lambda_n)</math>, and there is <math display=inline>V = U\Sigma^{-1/2}</math> where <math display=inline>U</math> is an orthogonal matrix. This then yields <math display=inline>A = U\Sigma U^T</math>.
ApplicationsEdit
Numerical solution of system of linear equationsEdit
The Cholesky decomposition is mainly used for the numerical solution of linear equations <math display=inline>\mathbf{Ax} = \mathbf{b}</math>. If Template:Math is symmetric and positive definite, then <math display=inline>\mathbf{Ax} = \mathbf{b}</math> can be solved by first computing the Cholesky decomposition <math display=inline>\mathbf{A} = \mathbf{LL}^\mathrm{*}</math>, then solving <math display=inline>\mathbf{Ly} = \mathbf{b}</math> for Template:Math by forward substitution, and finally solving <math display=inline>\mathbf{L^*x} = \mathbf{y}</math> for Template:Math by back substitution.
An alternative way to eliminate taking square roots in the <math display=inline>\mathbf{LL}^\mathrm{*}</math> decomposition is to compute the LDL decomposition <math display=inline>\mathbf{A} = \mathbf{LDL}^\mathrm{*}</math>, then solving <math display=inline>\mathbf{Ly} = \mathbf{b}</math> for Template:Math, and finally solving <math display=inline>\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.<ref name="NR"/>
Linear least squaresEdit
In linear least squares problem one seeks a solution Template:Math of an over-determined system Template:Math, such that quadratic norm of the residual vector Template:Math is minimum. This may be accomplished by solving by Cholesky decomposition normal equations <math>\mathbf{Nx}=\mathbf{A}^\mathsf{T}\mathbf{l}</math>, where <math>\mathbf{N}=\mathbf{A}^\mathsf{T}\mathbf{A}</math> is symmetric positive definite. Symmetric equation matrix may also come from an energy functional, which must be positive from physical considerations; this happens frequently in the numerical solution of partial differential equations.
Such method is economic and works well in many applications, however it fails for near singular Template:Math. This is best illustrated in pathological case of square <math>\mathbf{A}</math>, where determinant of Template:Math is square of that of the original system Template:Math. Then it is best to apply SVD or QR decomposition. Givens QR has the advantage that similarly to normal equations there is no need to keep the whole matrix Template:Math as it is possible to update Cholesky factor with consecutive rows of Template:Math.
Non-linear optimizationEdit
Non-linear least squares are a particular case of nonlinear optimization. Let <math display=inline>\mathbf{f}(\mathbf{x})=\mathbf{l}</math> be an over-determined system of equations with a non-linear function <math>\mathbf{f}</math> returning vector results. The aim is to minimize square norm of residuals <math display=inline>\mathbf{v}=\mathbf{f}(\mathbf{x})-\mathbf{l}</math>. An approximate Newton's method solution is obtained by expanding <math>\mathbf{f}</math> into curtailed Taylor series <math>\bf f(x_{\rm 0}+\delta x)\approx f(x_{\rm 0})+(\partial f/\partial x)\delta x</math> yielding linear least squares problem for <math>\bf\delta x</math>
- <math>{\bf(\partial f/\partial x)\delta x=l-f(x_{\rm 0})=v,\;\;\min_{\delta x}=\|v\|^2}.</math>
Of course because of neglect of higher Taylor terms such solution is only approximate, if it ever exists. Now one could update expansion point to <math>\bf x_{\rm n+1}=x_{\rm n}+\delta x</math> and repeat the whole procedure, hoping that (i) iterations converge to a solution and (ii) that the solution is the one needed. Unfortunately neither is guaranteed and must be verified.
Non-linear least squares may be also applied to the linear least squares problem by setting <math>\bf x_{\rm 0}=0</math> and <math>\bf f(x_{\rm 0})=Ax</math>. This may be useful if Cholesky decomposition yields an inaccurate inverse <math>\bf R^{\rm -1}</math> for the triangle matrix where <math>\bf R^{\rm T}R=N</math>, because of rounding errors. Such a procedure is called a differential correction of the solution. As long as iterations converge, by virtue of the Banach fixed-point theorem they yield the solution with a precision that is only limited by the precision of the calculated residuals <math>\bf v=Ax-l</math>. The precision is independent rounding errors in <math>\bf R^{\rm -1}</math>. Poor <math>\bf R^{\rm -1}</math> may restrict region of initial <math>\bf x_{\rm 0}</math> yielding convergence or altogether preventing it. Usually convergence is slower e.g. linear so that <math>\bf\|\delta x_{\rm n+1}\|\approx\|=\alpha\delta x_{\rm n}\|</math> where constant <math>\alpha<1</math>. Such slow convergence may be sped by Aitken <math>\delta^2</math> method. If calculation of <math>\bf R^{\rm -1}</math> is very costly, it is possible to use it from previous iterations as long as convergence is maintained. Such Cholesky procedure may work even for Hilbert matrices, notoriously difficult to invert.<ref>Template:Cite journal</ref>
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 display=inline> p_k </math> defined by solving <math display=inline> B_k p_k = -g_k </math> for <math display=inline> p_k </math>, where <math display=inline> p_k </math> is the step direction, <math display=inline> g_k </math> is the gradient, and <math display=inline> 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.<ref>Template:Cite book</ref>
Monte Carlo simulationEdit
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 Template:Math. Applying this to a vector of uncorrelated observations in a sample Template:Math produces a sample vector Lu with the covariance properties of the system being modeled.<ref name="Matlab documentation">Matlab randn documentation. mathworks.com.</ref>
The following simplified example shows the economy one gets from the Cholesky decomposition: suppose the goal is to generate two correlated normal variables <math display=inline>x_1</math> and <math display=inline>x_2</math> with given correlation coefficient <math display=inline>\rho</math>. To accomplish that, it is necessary to first generate two uncorrelated Gaussian random variables <math display=inline>z_1</math> and <math display=inline>z_2</math> (for example, via a Box–Muller transform). Given the required correlation coefficient <math display=inline>\rho</math>, the correlated normal variables can be obtained via the transformations <math display=inline>x_1 = z_1</math> and <math display="inline">x_2 = \rho z_1 + \sqrt{1 - \rho^2} z_2</math>.
Kalman filtersEdit
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 Template:Math of length Template:Mvar and covariance as an Template:Math matrix Template:Math. The matrix Template:Math is always positive semi-definite and can be decomposed into LLT. The columns of Template:Math can be added and subtracted from the mean Template:Math to form a set of Template:Math vectors called sigma points. These sigma points completely capture the mean and covariance of the system state.
Matrix inversionEdit
The explicit inverse of a Hermitian matrix can be computed by Cholesky decomposition, in a manner similar to solving linear systems, using <math display=inline>n^3</math> operations (<math display=inline>\tfrac{1}{2} n^3</math> multiplications).<ref name="kri"/> The entire inversion can even be efficiently performed in-place.
A non-Hermitian matrix Template:Math can also be inverted using the following identity, where BB* will always be Hermitian:
<math display=block>\mathbf{B}^{-1} = \mathbf{B}^* (\mathbf{B B}^*)^{-1}.</math>
ComputationEdit
There are various methods for calculating the Cholesky decomposition. The computational complexity of commonly used algorithms is Template:Math in general.Template:Citation needed The algorithms described below all involve about Template:Math FLOPs (Template:Math multiplications and the same number of additions) for real flavors and Template:Math FLOPs for complex flavors,<ref>?potrf Intel® Math Kernel Library [1]</ref> where Template:Mvar is the size of the matrix Template:Math. Hence, they have half the cost of the LU decomposition, which uses Template:Math 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 decomposition was shown to be numerically stable without need for pivoting.<ref>Template:Cite journal</ref>
The Cholesky algorithmEdit
The Cholesky algorithm, used to calculate the decomposition matrix Template:Math, is a modified version of Gaussian elimination.
The recursive algorithm starts with Template:Math and
At step Template:Mvar, the matrix Template:Math has the following form: <math display=block>\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 Template:Math denotes the identity matrix of dimension Template:Math.
If the matrix Template:Math is defined by <math display=block>\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 Template:Math since Template:Math is positive definite), then Template:Math can be written as <math display=block>\mathbf{A}^{(i)} = \mathbf{L}_{i} \mathbf{A}^{(i+1)} \mathbf{L}_{i}^{*}</math> where <math display=block>\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 Template:Math is an outer product, therefore this algorithm is called the outer-product version in (Golub & Van Loan).
This is repeated for Template:Mvar from 1 to Template:Mvar. After Template:Mvar steps, Template:Math is obtained, and hence, the lower triangular matrix Template:Mvar sought for is calculated as
<math display=block>\mathbf{L} := \mathbf{L}_{1} \mathbf{L}_{2} \dots \mathbf{L}_{n}.</math>
The Cholesky–Banachiewicz and Cholesky–Crout algorithmsEdit
If the equation <math display=block>\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 display=block>\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 Template:Math:
<math display=block> L_{j,j} = (\pm)\sqrt{ A_{j,j} - \sum_{k=1}^{j-1} L_{j,k}^2 }, </math> <math display=block> 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>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 Template:Math is real and positive-definite.
For complex Hermitian matrix, the following formula applies:
<math display=block> L_{j,j} = \sqrt{ A_{j,j} - \sum_{k=1}^{j-1} L_{j,k}^*L_{j,k} }, </math> <math display=block> 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>j. </math>
So it now is possible to compute the Template:Math 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 Template:Mvar and proceeds to calculate the matrix row by row.
<syntaxhighlight lang="C"> 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)); }
} </syntaxhighlight> 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, <syntaxhighlight lang="Fortran"> 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
</syntaxhighlight>
where conjg
refers to complex conjugate of the elements.
- The Cholesky–Crout algorithm starts from the upper left corner of the matrix Template:Mvar and proceeds to calculate the matrix column by column. <syntaxhighlight lang="C">
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)); }
} </syntaxhighlight> 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, <syntaxhighlight lang="Fortran"> 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
</syntaxhighlight>
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 computationEdit
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 Template:Math, and Template:Math denotes the computed solution, then Template:Math solves the perturbed system (Template:Math, where <math display=block> \|\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 Template:Mvar, and Template:Mvar 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.<ref>Template:Cite journal</ref> 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 decompositionEdit
An alternative form, eliminating the need to take square roots when Template:Math is symmetric, is the symmetric indefinite factorization<ref>Template:Cite book</ref> <math display=block> \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 Template:Math and Template:Math: <math display=block> D_j = A_{jj} - \sum_{k=1}^{j-1} L_{jk}^2 D_k, </math> <math display=block> 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>j. </math>
This works as long as the generated diagonal elements in Template:Math stay non-zero. The decomposition is then unique. Template:Math and Template:Math are real if Template:Math is real.
For complex Hermitian matrix Template:Math, the following formula applies:
<math display=block> D_{j} = A_{jj} - \sum_{k=1}^{j-1} L_{jk}L_{jk}^* D_k, </math> <math display=block> 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>j. </math>
Again, the pattern of access allows the entire computation to be performed in-place if desired.
Block variantEdit
When used on indefinite matrices, the LDL* factorization is known to be unstable without careful pivoting;<ref>Template:Cite book</ref> specifically, the elements of the factorization can grow arbitrarily. A possible improvement is to perform the factorization on block sub-matrices, commonly 2 × 2:<ref>Template:Cite journal</ref>
<math display=block>\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 display=block>\mathbf D_j = \mathbf A_{jj} - \sum_{k=1}^{j-1} \mathbf L_{jk} \mathbf D_k \mathbf L_{jk}^\mathrm T,</math> <math display=block>\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 decompositionEdit
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 display=inline>\mathbf{A} = \mathbf{L}\mathbf{L}^*</math> of some matrix <math display=inline>\mathbf{A}</math>, then one changes the matrix <math display=inline>\mathbf{A}</math> in some way into another matrix, say <math display=inline> \tilde{\mathbf{A}} </math>, and one wants to compute the Cholesky decomposition of the updated matrix: <math display=inline> \tilde{\mathbf{A}} = \tilde{\mathbf{L}} \tilde{\mathbf{L}}^* </math>. The question is now whether one can use the Cholesky decomposition of <math display=inline>\mathbf{A}</math> that was computed before to compute the Cholesky decomposition of <math display=inline> \tilde{\mathbf{A}} </math>.
Rank-one updateEdit
The specific case, where the updated matrix <math display=inline> \tilde{\mathbf{A}} </math> is related to the matrix <math display=inline>\mathbf{A}</math> by <math display=inline> \tilde{\mathbf{A}} = \mathbf{A} + \mathbf{x} \mathbf{x}^* </math>, is known as a rank-one update.
Here is a function<ref>Based on: Template:Cite book</ref> written in Matlab syntax that realizes a rank-one update: <syntaxhighlight lang="matlab"> 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 </syntaxhighlight> A rank-n update is one where for a matrix <math display=inline>\mathbf{M}</math> one updates the decomposition such that <math display=inline> \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 display=inline>\mathbf{M}</math>.
Rank-one downdateEdit
A rank-one downdate is similar to a rank-one update, except that the addition is replaced by subtraction: <math display=inline> \tilde{\mathbf{A}} = \mathbf{A} - \mathbf{x} \mathbf{x}^* </math>. This only works if the new matrix <math display=inline> \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 columnsEdit
If a symmetric and positive definite matrix <math display=inline> \mathbf A </math> is represented in block form as
<math display=block> \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 display=block> \mathbf{L} = \begin{pmatrix}
\mathbf L_{11} & \mathbf L_{13} \\ 0 & \mathbf L_{33} \\
\end{pmatrix}, </math>
then for a new matrix <math display=inline> \tilde{\mathbf{A}} </math>, which is the same as <math display=inline> \mathbf A </math> but with the insertion of new rows and columns, <math display=block>\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 display=inline> \tilde{\mathbf{A}} </math>, which can be called <math display=inline> \tilde{\mathbf S} </math>, without directly computing the entire decomposition. <math display=block>\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 display=inline> \mathbf A \setminus \mathbf{b}</math> for the solution of <math display=inline> \mathbf A \mathbf x = \mathbf b</math>, which can be found easily for triangular matrices, and <math display=inline> \text{chol} (\mathbf M)</math> for the Cholesky decomposition of <math display=inline> \mathbf M </math>, the following relations can be found: <math display=block>\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 display=block>\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 display=block>\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 display=block>\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 display=inline> \mathbf A </math> with rows and columns removed, <math display=block>\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 display=block>\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 display=inline> \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.<ref>Osborne, M. (2010), Appendix B.</ref>
Proof for positive semi-definite matricesEdit
Proof by limiting argumentEdit
The above algorithms show that every positive definite matrix <math display=inline> \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 display=inline> \mathbf{A} </math> is an <math display=inline> n \times n </math> positive semi-definite matrix, then the sequence <math display="inline"> \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 display=block> \mathbf{A}_k \rightarrow \mathbf{A} \quad \text{for} \quad k \rightarrow \infty </math> in operator norm. From the positive definite case, each <math display=inline> \mathbf{A}_k </math> has Cholesky decomposition <math display=inline> \mathbf{A}_k = \mathbf{L}_k\mathbf{L}_k^* </math>. By property of the operator norm,
<math display=block>\| \mathbf{L}_k \|^2 \leq \| \mathbf{L}_k \mathbf{L}_k^* \| = \| \mathbf{A}_k \| \,.</math>
The <math display=inline>\leq</math> holds because <math display=inline>M_n(\mathbb{C})</math> equipped with the operator norm is a C* algebra. So <math display=inline> \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 display=inline> \left( \mathbf{L}_k \right)_k</math>, with limit <math display=inline> \mathbf{L}</math>. It can be easily checked that this <math display=inline> \mathbf{L}</math> has the desired properties, i.e. <math display=inline> \mathbf{A} = \mathbf{L}\mathbf{L}^* </math>, and <math display=inline> \mathbf{L}</math> is lower triangular with non-negative diagonal entries: for all <math display=inline> x</math> and <math display=inline> y</math>,
<math display=block> \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 display=inline> \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 display=inline> \left( \mathbf{L}_k \right)_k</math> tends to <math display=inline> \mathbf{L}</math> in norm means <math display=inline> \left( \mathbf{L}_k \right)_k</math> tends to <math display=inline> \mathbf{L}</math> entrywise. This in turn implies that, since each <math display=inline> \mathbf{L}_k</math> is lower triangular with non-negative diagonal entries, <math display=inline> \mathbf{L}</math> is also.
Proof by QR decompositionEdit
Let <math display=inline>\mathbf{A}</math> be a positive semi-definite Hermitian matrix. Then it can be written as a product of its square root matrix, <math display=inline>\mathbf{A} = \mathbf{B} \mathbf{B}^*</math>. Now QR decomposition can be applied to <math display=inline>\mathbf{B}^*</math>, resulting in <math display=inline>\mathbf{B}^* = \mathbf{Q}\mathbf{R}</math> , where <math display=inline>\mathbf{Q}</math> is unitary and <math display=inline>\mathbf{R}</math> is upper triangular. Inserting the decomposition into the original equality yields <math display=inline>A = \mathbf{B} \mathbf{B}^* = (\mathbf{QR})^*\mathbf{QR} = \mathbf{R}^*\mathbf{Q}^*\mathbf{QR} = \mathbf{R}^*\mathbf{R}</math>. Setting <math display=inline>\mathbf{L} = \mathbf{R}^*</math> completes the proof.
GeneralizationEdit
The Cholesky factorization can be generalized Template:Citation needed to (not necessarily finite) matrices with operator entries. Let <math display=inline>\{\mathcal{H}_n \}</math> be a sequence of Hilbert spaces. Consider the operator matrix
<math display=block> \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 display=block>\mathcal{H} = \bigoplus_n \mathcal{H}_n,</math>
where each
<math display=block>\mathbf{A}_{ij} : \mathcal{H}_j \rightarrow \mathcal{H} _i</math>
is a bounded operator. If Template:Math is positive (semidefinite) in the sense that for all finite Template:Mvar and for any
<math display=block>h \in \bigoplus_{n = 1}^k \mathcal{H}_k ,</math>
there is <math display=inline>\langle h, \mathbf{A} h\rangle \ge 0</math>, then there exists a lower triangular operator matrix Template:Math such that Template:Math. One can also take the diagonal entries of Template:Math to be positive.
Implementations in programming librariesEdit
- 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 thenumpy.linalg
module performs Cholesky decomposition. - In Matlab, the
chol
function gives the Cholesky decomposition. Note thatchol
uses the upper triangular factor of the input matrix by default, i.e. it computes <math display=inline>A = R^* R</math> where <math display=inline>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 theLinearAlgebra
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.
- The Armadillo (C++ library) supplies the command
- In Analytica, the function
Decompose
gives the Cholesky decomposition. - The Apache Commons Math library has an implementation which can be used in Java, Scala and any other JVM language.
See alsoEdit
- Cycle rank
- Incomplete Cholesky factorization
- Matrix decomposition
- Minimum degree algorithm
- Square root of a matrix
- Sylvester's law of inertia
- Symbolic Cholesky decomposition
NotesEdit
ReferencesEdit
- Template:Cite conference
- Template:Cite book
- Template:Cite book
- S. J. Julier and J. K. Uhlmann. "A General Method for Approximating Nonlinear Transformations of ProbabilityDistributions".
- S. J. Julier and J. K. Uhlmann, "A new extension of the Kalman filter to nonlinear systems", in Proc. AeroSense: 11th Int. Symp. Aerospace/Defence Sensing, Simulation and Controls, 1997, pp. 182–193.
- Template:Cite book
- Template:Cite thesis
- Ruschel, João Paulo Tarasconi, Bachelor degree "Parallel Implementations of the Cholesky Decomposition on CPUs and GPUs" Universidade Federal Do Rio Grande Do Sul, Instituto De Informatica, 2016, pp. 29-30.
External linksEdit
History of scienceEdit
- Sur la résolution numérique des systèmes d'équations linéaires, Cholesky's 1910 manuscript, online and analyzed on BibNum Template:In lang [for English, click 'A télécharger']
InformationEdit
- Template:Springer
- Cholesky Decomposition, The Data Analysis BriefBook
- Cholesky Decomposition on www.math-linux.com
- Cholesky Decomposition Made Simple on Science Meanderthal
Computer codeEdit
- LAPACK is a collection of FORTRAN subroutines for solving dense linear algebra problems (DPOTRF, DPOTRF2, details performance)
- ALGLIB includes a partial port of the LAPACK to C++, C#, Delphi, Visual Basic, etc. (spdmatrixcholesky, hpdmatrixcholesky)
- libflame is a C library with LAPACK functionality.
- Notes and video on high-performance implementation of Cholesky factorization at The University of Texas at Austin.
- Cholesky : TBB + Threads + SSE is a book explaining the implementation of the CF with TBB, threads and SSE (in Spanish).
- library "Ceres Solver" by Google.
- LDL decomposition routines in Matlab.
- Armadillo is a C++ linear algebra package
- Rosetta Code is a programming chrestomathy site. on page topic.
- AlgoWiki is an open encyclopedia of algorithms’ properties and features of their implementations on page topic
- Intel® oneAPI Math Kernel Library Intel-Optimized Math Library for Numerical Computing ?potrf, ?potrs
Use of the matrix in simulationEdit
Online calculatorsEdit
- Online Matrix Calculator Performs Cholesky decomposition of matrices online.