Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Compute the rational Cholesky decomposition of a matrix
| ResourceFunction["RationalCholeskyDecomposition"][m] gives the rational Cholesky decomposition of a matrix m, given as a list {l,d} where l is a unit lower-triangular matrix and d is the diagonal of a diagonal matrix. | 
 decomposition.
 decomposition.Perform a rational Cholesky decomposition on a matrix m:
| In[1]:= | ![{lm, dm} = ResourceFunction["RationalCholeskyDecomposition"][{{2, 1}, {1, 2}}]](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/7b0fda4e5067462d.png) | 
| Out[1]= |  | 
Confirm that lm.DiagonalMatrix[dm].ConjugateTranspose[lm]⩵m:
| In[2]:= | ![lm . DiagonalMatrix[dm] . ConjugateTranspose[lm]](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/29148559d533e557.png) | 
| Out[2]= |  | 
Hilbert matrices are symmetric and positive definite:
| In[3]:= | ![m = HilbertMatrix[5]](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/3e20e73e07044a81.png) | 
| Out[3]= |  | 
Compute the rational Cholesky decomposition with exact arithmetic:
| In[4]:= | ![ResourceFunction["RationalCholeskyDecomposition"][m]](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/4abfff3035288ec3.png) | 
| Out[4]= |  | 
| In[5]:= | ![MatrixForm[First[%]]](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/2fca96e3e6658d11.png) | 
| Out[5]= |  | 
Compute the rational Cholesky decomposition with machine arithmetic:
| In[6]:= | ![ResourceFunction["RationalCholeskyDecomposition"][N[m]]](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/4c3db5f9795bd3b5.png) | 
| Out[6]= |  | 
Compute the rational Cholesky decomposition with 24-digit precision arithmetic:
| In[7]:= | ![ResourceFunction["RationalCholeskyDecomposition"][N[m, 24]]](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/4a14ffee7e06f288.png) | 
| Out[7]= |  | 
Compute the rational Cholesky decomposition of a random complex Hermitian matrix:
| In[8]:= | ![r = RandomComplex[(1 + I) {-1, 1}, {4, 4}];
ResourceFunction["RationalCholeskyDecomposition"][
 r . ConjugateTranspose[r] + IdentityMatrix[4]]](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/4ff6ebbc92a5019e.png) | 
| Out[9]= |  | 
Use symbolic matrices:
| In[10]:= | ![ResourceFunction["RationalCholeskyDecomposition"][{{x, y}, {y, x}}]](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/03bf991db6ec8e48.png) | 
| Out[10]= |  | 
With TargetStructure→"Structured", a list containing a LowerTriangularMatrix and a DiagonalMatrix is returned:
| In[11]:= | ![ResourceFunction["RationalCholeskyDecomposition"][\!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"1", "1", "1", "1"},
{"1", "2", "2", "2"},
{"1", "2", "3", "3"},
{"1", "2", "3", "4"}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
GridBoxSpacings->{"Columns" -> {
Offset[0.27999999999999997`], {
Offset[0.7]}, 
Offset[0.27999999999999997`]}, "Rows" -> {
Offset[0.2], {
Offset[0.4]}, 
Offset[0.2]}}], "", ")"}],
Function[BoxForm`e$, 
MatrixForm[BoxForm`e$]]]\), TargetStructure -> "Structured"]](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/6710e662a9ae299a.png) | 
| Out[11]= |  | 
A symmetric Toeplitz matrix:
| In[12]:= | ![tm = ToeplitzMatrix[{x, y, z}]](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/5bd5f26feaf97d69.png) | 
| Out[12]= |  | 
Compute its rational Cholesky decomposition:
| In[13]:= | ![ResourceFunction["RationalCholeskyDecomposition"][tm]](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/64bc6c307627c0f8.png) | 
| Out[13]= |  | 
Derive the conditions for the original matrix to be positive definite:
| In[14]:= | ![Reduce[Thread[Last[%] > 0], {x, y, z}] // FullSimplify](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/680de9b29b23b758.png) | 
| Out[14]= |  | 
Create a symmetric positive definite matrix:
| In[15]:= |  | 
Compute its rational Cholesky decomposition:
| In[16]:= | ![{lm, dm} = ResourceFunction["RationalCholeskyDecomposition"][m]](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/33769f1ef5565707.png) | 
| Out[16]= |  | 
Compute the Cholesky decomposition from the result of RationalCholeskyDecomposition:
| In[17]:= | ![DiagonalMatrix[Sqrt[dm]] . ConjugateTranspose[lm] // MatrixForm](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/369a5cc55111da51.png) | 
| Out[18]= |  | 
Compare with the result of CholeskyDecomposition:
| In[19]:= | ![CholeskyDecomposition[m] // MatrixForm](https://www.wolframcloud.com/obj/resourcesystem/images/610/61004a1b-552c-41f1-9b5c-18908c8b55a8/78060613cf71b2d3.png) | 
| Out[19]= |  | 
This work is licensed under a Creative Commons Attribution 4.0 International License