Cholesky decomposition calculator
Split a symmetric positive definite matrix into a lower triangle L times its transpose: the classic 3×3 example whose first row is 4, 12, −16 gives an L with 2, 1 and 3 on its diagonal. Useful for solving systems and sampling. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Runs in your browser. Free, unlimited — your data never leaves this page.
Cholesky is the standard way to solve linear systems, generate correlated random samples, and test whether a matrix is positive definite at all — when the factorization exists, the matrix is positive definite by construction. Send your matrix as an array of rows and receive the factor, the echoed input and the method used, in one deterministic call.
What the Cholesky decomposition actually gives you
Every symmetric positive definite matrix A can be written as the product of a lower triangular matrix and its own transpose: A = L·Lᵀ. That factor L is, loosely, the square root of the matrix — and once you have it, several expensive problems become cheap. Solving A·x = b stops requiring general elimination: you solve L·y = b by forward substitution, then Lᵀ·x = y by back substitution, both in quadratic time.
Inverting the matrix, computing its determinant (the product of the squared diagonal entries of L) and whitening or correlating random vectors all reduce to operations on the triangle. The cholesky decomposition calculator returns exactly that factor: an n×n lower triangular matrix with positive entries on the diagonal and zeros everywhere above it. Because the computation is deterministic floating-point arithmetic with fixed rounding, the same input always produces byte-identical output, which makes the result safe to cache, compare and store in an audit trail.
How the factorization is computed and checked
For each diagonal position it takes the corresponding entry of A, subtracts the squared norm of the factor row computed so far and takes the square root; for each position below the diagonal it subtracts the dot product of the two partial rows and divides by the diagonal entry already known. That single square root is also the definitive positive-definiteness test: the quantity under it is positive for every row if and only if the matrix is positive definite.
Before any of that, the input is validated: it must be a square array of at most 50 rows, every entry must be a finite number within the declared magnitude ceiling, and mirrored entries must agree within a relative tolerance, because a non-symmetric matrix has no Cholesky factorization at all.
Where it fits in real work
The two classic homes of Cholesky are statistics and numerical computing. In statistics, drawing samples from a multivariate normal distribution with covariance matrix Σ means multiplying a vector of independent standard normals by the Cholesky factor of Σ — Monte Carlo engines do this millions of times, and they need the factor computed once, correctly, up front.
In numerical computing, least-squares problems, Kalman filters and interior-point optimizers all solve symmetric positive definite systems at every iteration, and Cholesky is roughly twice as fast as general LU because it exploits symmetry and needs no pivoting.
What you can do with it
Validate a covariance matrix before sampling
Check that an estimated covariance or correlation matrix is truly positive definite — and get the factor you need for correlated Monte Carlo draws — before it poisons a simulation.
Solve a symmetric system without a library
Get L once, then solve A·x = b with two triangular substitutions in your own code, in any language, without linking LAPACK or NumPy.
Cross-check your own linear algebra code
Compare the factor your implementation produced against an independent deterministic result to catch indexing and rounding bugs.
FAQ
What matrices are accepted?
Square matrices up to 50×50, symmetric within a relative tolerance, with finite entries up to 1e15 in magnitude. Non-square, non-symmetric or non-positive-definite inputs are rejected with a specific error message.
What exactly is returned?
The lower triangular factor L such that A = L·Lᵀ, rounded to your chosen precision (default 10 decimals), plus the input matrix, the dimension, the method name and the formula used.
Is my matrix stored?
No. It is processed in memory and discarded; only the computed response leaves the function.
How accurate is the result?
The factor is computed in double precision floating point and rounded to the requested number of decimals. For well-conditioned matrices within the size limit, the rounded result satisfies A ≈ L·Lᵀ to that precision.
How can I tell whether a matrix is positive definite?
Try to factor it. If the factorization succeeds, the matrix is positive definite by construction; if it fails, the calculator stops and names the row where it broke, instead of returning a plausible but wrong answer.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/math/cholesky-decomposition \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"matrix":[[4,12,-16],[12,37,-43],[-16,-43,98]]}'const res = await fetch("https://api.kit.forhosting.com/math/cholesky-decomposition", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"matrix": [
[
4,
12,
-16
],
[
12,
37,
-43
],
[
-16,
-43,
98
]
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/cholesky-decomposition",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"matrix": [
[
4,
12,
-16
],
[
12,
37,
-43
],
[
-16,
-43,
98
]
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/cholesky-decomposition", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"matrix":[[4,12,-16],[12,37,-43],[-16,-43,98]]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"matrix":[[4,12,-16],[12,37,-43],[-16,-43,98]]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/cholesky-decomposition", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"matrix": [
[
4,
12,
-16
],
[
12,
37,
-43
],
[
-16,
-43,
98
]
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.cholesky_decomposition",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_n | 50 |
max_abs_entry | 1000000000000000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
The Cholesky decomposition API takes a symmetric positive definite matrix and returns its lower triangular factor: the unique matrix L with positive diagonal entries such that A = L·Lᵀ. If the matrix is not symmetric, not square or not positive definite, the API tells you exactly why instead of returning a plausible-looking wrong answer.
What the Cholesky decomposition actually gives you
You send the matrix as a JSON array of rows, optionally with a precision between 0 and 15 decimal places, and the response contains the factor rounded to that precision, the matrix you sent, the dimension and the algorithm name.
How the factorization is computed and checked
The endpoint runs the Cholesky-Banachiewicz algorithm, a row-by-row procedure that builds L directly from the definition A = L·Lᵀ. If any pivot comes out zero or negative, the computation stops and the API reports that the matrix is not positive definite, naming the row where it failed. Errors are returned as structured invalid_input responses, never as numeric garbage.
Where it fits in real work
This API is the one-call version of that step: useful when you want to verify a covariance matrix is valid before feeding it to a sampler, when a pipeline needs the factor without linking a linear algebra library, or when you want a second opinion on a result your own code produced. It runs on the edge with nothing kept afterwards, costs $0.002 per request, and the identical code runs free in your browser on this page — paste a matrix, see the factor, and pay only when you automate the call.
Technical questions
What does it cost?
$0.002 per request. It is also free to run in your browser on this page with the same code.
What happens if my matrix is not positive definite?
The request fails with an invalid_input error stating that the matrix is not positive definite and naming the row where the pivot failed. No partial factor is returned.