whereL is alower triangular matrix with real and positive diagonal entries, andL* denotes theconjugate transpose ofL. Every Hermitian positive-definite matrix (and thus also every real symmetric positive-definite matrix) has a Cholesky decomposition and the lower triangular matrix is unique if we impose the diagonal to be strictly positive.[3]
The converse holds trivially: ifA can be written asLL* for some invertibleL, lower triangular or otherwise, thenA is Hermitian and positive definite.
WhenA is a real matrix (hence symmetric positive-definite), the factorization may be writtenwhereL is a real lower triangular matrix with positive diagonal entries.[4][5][6]
If a Hermitian matrixA is only positive semidefinite, instead of positive definite, then it still has a decomposition of the formA =LL* where the diagonal entries ofL are allowed to be zero.[7]The decomposition need not be unique, for example:for anyθ. However, if the rank ofA isr, then there is a unique lower triangularL with exactlyr positive diagonal elements andn −r columns containing all zeroes.[8]
Alternatively, the decomposition can be made unique when a pivoting choice is fixed. Formally, ifA is ann ×n positive semidefinite matrix of rankr, then there is at least one permutation matrixP such thatP A PT has a unique decomposition of the formP A PT =L L* with,whereL1 is anr ×r lower triangular matrix with positive diagonal.[9]
A closely related variant of the classical Cholesky decomposition is the LDL decomposition,
whereL is alower unit triangular (unitriangular) matrix, andD is adiagonal matrix. That is, the diagonal elements ofL are required to be 1 at the cost of introducing an additional diagonal matrixD 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 thesquare-root-free Cholesky decomposition. For real matrices, the factorization has the formA =LDLT and is often referred to asLDLT decomposition (orLDLT decomposition, orLDL′). It is reminiscent of theeigendecomposition of real symmetric matrices,A =QΛQT, but is quite different in practice becauseΛ andD are notsimilar matrices.
The LDL decomposition is related to the classical Cholesky decomposition of the formLL* as follows:
Conversely, given the classical Cholesky decomposition of a positive definite matrix, ifS is a diagonal matrix that contains themain diagonal of, thenA can be decomposed as where (this rescales each column to make diagonal elements 1),
IfA is positive definite then the diagonal elements ofD are all positive.For positive semidefiniteA, an decomposition exists where the number of non-zero elements on the diagonalD is exactly the rank ofA.[11]Some indefinite matrices for which no Cholesky decomposition exists have an LDL decomposition with negative entries inD: it suffices that the firstn − 1leading principal minors ofA are non-singular.[12]
The ellipse is a linear image of the unit circle. The two vectors are conjugate axes of the ellipse chosen such that is parallel to the first axis and is within the plane spanned by the first two axes.
The Cholesky decomposition is equivalent to a particular choice ofconjugate axes of anellipsoid.[13] In detail, let the ellipsoid be defined as, then by definition, a set of vectors are conjugate axes of the ellipsoid iff. Then, the ellipsoid is preciselywhere maps the basis vector, and is theunit sphere in n dimensions. That is, the ellipsoid is a linear image of the unit sphere.
Define the matrix, then is equivalent to. Different choices of the conjugate axes correspond to different decompositions.
The Cholesky decomposition corresponds to choosing to be parallel to the first axis, to be within the plane spanned by the first two axes, and so on. This makes an upper-triangular matrix. Then, there is, where is lower-triangular.
The Cholesky decomposition is mainly used for the numerical solution oflinear equations. IfA is symmetric and positive definite, then can be solved by first computing the Cholesky decomposition, then solving fory byforward substitution, and finally solving forx byback substitution.
An alternative way to eliminate taking square roots in the decomposition is to compute the LDL decomposition, then solving fory, and finally solving.
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 andnumerical stability. Compared to theLU decomposition, it is roughly twice as efficient.[2]
Inlinear least squares problem one seeks a solutionx of an over-determined systemAx =l, such that quadratic norm of the residual vectorAx-l is minimum. This may be accomplished by solving by Cholesky decompositionnormal equations, where is symmetric positive definite. Symmetric equation matrixmay also come from an energy functional, which must be positive from physical considerations; this happens frequently in the numerical solution ofpartial differential equations.
Such method is economic and works well in many applications, however it fails for near singularN. This is best illustrated in pathological case of square,where determinant ofN is square of that of the original systemAx =l.Then it is best to apply SVD or QR decomposition. Givens QR has the advantage that similarlyto normal equations there is no need to keep the whole matrixA as it ispossible to update Cholesky factor with consecutive rows ofA.
Non-linear least squares are a particular case of nonlinear optimization. Let be an over-determined system of equations with a non-linear function returning vector results. The aim is to minimize square norm of residuals. An approximateNewton's method solution is obtained by expanding into curtailed Taylor series yieldinglinear least squares problem for
Of course because of neglect of higher Taylor terms such solution is only approximate, if it ever exists. Now one could update expansion point toand repeat the whole procedure, hoping that (i) iterations converge to a solutionand (ii) that the solution is the one needed. Unfortunately neither is guaranteed andmust be verified.
Non-linear least squares may be also applied to the linear least squares problem by setting and. This may be useful if Cholesky decomposition yields an inaccurate inverse for the triangle matrix where, because of rounding errors. Such a procedure is called adifferential correction of the solution. As long as iterations converge, by virtue of theBanach fixed-point theorem they yield the solution with a precision that is only limited by the precision of the calculated residuals. The precision is independent rounding errors in. Poor may restrict region of initialyielding convergence or altogether preventing it. Usually convergence is slower e.g. linearso that where constant. Such slow convergence may be sped byAitken method.If calculation of 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.[14]
Non-linear multi-variate functions may be minimized over their parameters using variants ofNewton's method calledquasi-Newton methods. At iteration k, the search steps in a direction defined by solving for, where is the step direction, is thegradient, and is an approximation to theHessian matrix formed by repeating rank-1 updates at each iteration. Two well-known update formulas are calledDavidon–Fletcher–Powell (DFP) andBroyden–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.[15]
The Cholesky decomposition is commonly used in theMonte Carlo method for simulating systems with multiple correlated variables. Thecovariance matrix is decomposed to give the lower-triangularL. Applying this to a vector of uncorrelated observations in a sampleu produces a sample vectorLu with the covariance properties of the system being modeled.[16]
The following simplified example shows the economy one gets from the Cholesky decomposition: suppose the goal is to generate two correlated normal variables and with given correlation coefficient. To accomplish that, it is necessary to first generate two uncorrelated Gaussian random variables and (for example, via aBox–Muller transform). Given the required correlation coefficient, the correlated normal variables can be obtained via the transformations and.
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 vectorx of lengthN and covariance as anN ×N matrixP. The matrixP is always positive semi-definite and can be decomposed intoLLT. The columns ofL can be added and subtracted from the meanx to form a set of2N vectors calledsigma points. These sigma points completely capture the mean and covariance of the system state.
The explicitinverse of a Hermitian matrix can be computed by Cholesky decomposition, in a manner similar to solving linear systems, using operations ( multiplications).[10] The entire inversion can even be efficiently performed in-place.
A non-Hermitian matrixB can also be inverted using the following identity, whereBB* will always be Hermitian:
Cholesky decomposition can also be used to impute data. Variations of the expectation maximization algorithm among other data imputation algorithms, make use of Cholesky decomposition.[17]
There are various methods for calculating the Cholesky decomposition. The computational complexity of commonly used algorithms isO(n3) in general.[citation needed] The algorithms described below all involve about(1/3)n3FLOPs (n3/6 multiplications and the same number of additions) for real flavors and(4/3)n3FLOPs for complex flavors,[18] wheren is the size of the matrixA. Hence, they have half the cost of theLU decomposition, which uses2n3/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 decomposition was shown to be numerically stable without need for pivoting.[19]
TheCholesky algorithm, used to calculate the decomposition matrixL, is a modified version ofGaussian elimination.
The recursive algorithm starts withi := 1 and
A(1) :=A.
At stepi, the matrixA(i) has the following form:whereIi−1 denotes theidentity matrix of dimensioni − 1.
If the matrixLi is defined by(note thatai,i > 0 sinceA(i) is positive definite),thenA(i) can be written aswhereNote thatbibi* is anouter product, therefore this algorithm is called theouter-product version in (Golub & Van Loan).
This is repeated fori from 1 ton. Aftern steps,A(n+1) =I is obtained, and hence, the lower triangular matrixL sought for is calculated as
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
is written out, the following is obtained:
and therefore the following formulas for the entries ofL:
For complex and real matrices, inconsequential arbitrary sign changes of diagonal and associated off-diagonal elements are allowed. The expression under thesquare root is always positive ifA is real and positive-definite.
For complex Hermitian matrix, the following formula applies:
and it can be shown that is alwaysreal and positive ifA is positive-definite.[20]: 49
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:
TheCholesky–Banachiewicz algorithm starts from the upper left corner of the matrixL and proceeds to calculate the matrix row by row.
The above algorithm can be succinctly expressed as combining adot product andmatrix multiplication in vectorized programming languages such asFortran as the following,
doi=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
whereconjg refers to complex conjugate of the elements.
TheCholesky–Crout algorithm starts from the upper left corner of the matrixL and proceeds to calculate the matrix column by column.
The above algorithm can be succinctly expressed as combining adot product andmatrix multiplication in vectorized programming languages such asFortran as the following,
doi=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
whereconjg 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 awell-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, nopivoting is necessary, and the error will always be small. Specifically, ifAx =b, andy denotes the computed solution, theny solves the perturbed system (A +E)y =b, whereHere ||·||2 is thematrix 2-norm,cn is a small constant depending onn, andε denotes theunit 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 positivein exact arithmetic. Unfortunately, the numbers can become negative because ofround-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.[21] While this might lessen the accuracy of the decomposition, it can be very favorable for other reasons; for example, when performingNewton's method in optimization, adding a diagonal matrix can improve stability when far from the optimum.
When used on indefinite matrices, theLDL* factorization is known to be unstable without careful pivoting;[22] specifically, the elements of the factorization can grow arbitrarily. A possible improvement is to perform the factorization on block sub-matrices, commonly 2 × 2:[23]
where every element in the matrices above is a square submatrix. From this, these analogous recursive relations follow:
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 of some matrix, then one changes the matrix in some way into another matrix, say, and one wants to compute the Cholesky decomposition of the updated matrix:. The question is now whether one can use the Cholesky decomposition of that was computed before to compute the Cholesky decomposition of.
The specific case, where the updated matrix is related to the matrix by, is known as arank-one update. Here the constant is allowed to be negative, but must always be such that the new matrix is still positive definite.
Here is a function[24] written inMatlab syntax that realizes a rank-one update:
functionL=updateChol(L,x,c)% given the L*L' Cholesky decomposition of a matrix, compute the updated% factor L so that we have the Cholesky decomposition of L*L'+c*x*x';n=length(x);fork=1:n-1l=L(:,k);% old value of k-th columnlk=l(k);xk=x(k);dk=sqrt(lk^2+c*xk^2);% new diagonal valueL(:,k)=(lk/dk)*l+(c*xk/dk)*x;% new column valuex=x-l*(xk/lk);c=c*(lk/dk)^2;endL(n,n)=sqrt(L(n,n)^2+c*x(n)^2);end
Arank-n update is one where for a matrix one updates the decomposition such that. This can be achieved by successively performing rank-one updates for each of the columns of.
If a symmetric and positive definite matrix is represented in block form as
and its upper Cholesky factor
then for a new matrix, which is the same as but with the insertion of new rows and columns,
Now there is an interest in finding the Cholesky factorization of, which can be called, without directly computing the entire decomposition.
Writing for the solution of, which can be found easily for triangular matrices, and for the Cholesky decomposition of, the following relations can be found:
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,
with known Cholesky decomposition
and the desire to determine the Cholesky factor
of the matrix with rows and columns removed,
yields the following rules:
Notice that the equations above that involve finding the Cholesky decomposition of a new matrix are all of the form for some constant, which allows them to be efficiently calculated using procedure detailed in the previous section.[24]
The above algorithms show that every positive definite matrix 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 is anpositive semi-definite matrix, then the sequence consists ofpositive definite matrices. (This is an immediate consequence of, for example, the spectral mapping theorem for the polynomial functional calculus.) Also, inoperator norm. From the positive definite case, each has Cholesky decomposition. By property of the operator norm,
The holds because equipped with the operator norm is a C* algebra. So is a bounded set in theBanach space of operators, thereforerelatively compact (because the underlyingvector space is finite-dimensional). Consequently, it has a convergent subsequence, also denoted by, with limit. It can be easily checked that this has the desired properties, i.e., and is lower triangular with non-negative diagonal entries: for all and,
Therefore,. Because the underlying vector space is finite-dimensional, all topologies on the space of operators are equivalent. So tends to in norm means tends to entrywise. This in turn implies that, since each is lower triangular with non-negative diagonal entries, is also.
Let be apositive semi-definite Hermitian matrix. Then it can be written as a product of itssquare root matrix,. NowQR decomposition can be applied to, resulting in, where is unitary and is upper triangular. Inserting the decomposition into the original equality yields. Setting completes the proof.
The Cholesky factorization can be generalized[citation needed] to (not necessarily finite) matrices with operator entries. Let be a sequence ofHilbert spaces. Consider the operator matrix
acting on the direct sum
where each
is abounded operator. IfA is positive (semidefinite) in the sense that for all finitek and for any
there is, then there exists a lower triangular operator matrixL such thatA =LL*. One can also take the diagonal entries ofL to be positive.
GNU Octave numerical computations system provides several functions to calculate, update, and apply a Cholesky decomposition.
TheLAPACK library provides a high performance implementation of the Cholesky decomposition that can be accessed fromFortran,C and most languages. The Cholesky decomposition is available through the*POTRF family of subroutines, and the LDL decomposition through the*HETRF family of subroutines.
InPython, the functioncholesky from thenumpy.linalg module performs Cholesky decomposition. Thescipy.linalg module contains theldl function for the LDL decomposition.
InMatlab, thechol function gives the Cholesky decomposition. Note thatchol uses the upper triangular factor of the input matrix by default, i.e. it computes where is upper triangular. A flag can be passed to use the lower triangular factor instead.
InR, thechol function gives the Cholesky decomposition.
InJulia, thecholesky function from theLinearAlgebra standard library gives the Cholesky decomposition.
InMathematica, the function "CholeskyDecomposition" can be applied to a matrix.
InC++, multiple linear algebra libraries support this decomposition:
^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)".Bulletin Géodésique (in French).2:66–67.doi:10.1007/BF03031308.
^Schwarzenberg-Czerny, A. (1995). "On matrix factorization and efficient least squares solution".Astronomy and Astrophysics Supplement.110:405–410.Bibcode:1995A&AS..110..405S.
Sur la résolution numérique des systèmes d'équations linéaires, Cholesky's 1910 manuscript, online and analyzed onBibNum(in French and English)[for English, click 'A télécharger']