Condition number calculator
The condition number API takes a square matrix and returns its 2-norm condition number: the ratio between the largest and the smallest singular value of the matrix.
Run — free
This single number tells you how much a small error in your data — a rounding, a measurement noise, a truncated coefficient — can be amplified when you solve a linear system or invert the matrix. A condition number near 1 means the problem is stable; a large one warns that your answer may be dominated by noise. The computation runs in one deterministic pass: the matrix is validated, A-transpose-A is formed, and its eigenvalues are found by a classical Jacobi iteration, whose square roots are the singular values.
What a condition number actually measures
When you solve a system Ax = b numerically, you almost never work with the exact A and b. Coefficients come from measurements, previous computations or decimal input that was rounded on the way in. The condition number of A is the worst-case amplification factor of that uncertainty: if the input changes by a relative amount epsilon, the solution can change by up to kappa times epsilon. With kappa = 10, a one-per-cent error in your data can produce a ten-per-cent error in the answer. With kappa = 1,000,000, you may lose six of the roughly sixteen decimal digits a double can hold. The 2-norm condition number computed here, kappa_2, is defined through the singular values of A: the largest singular value sigma_max measures the most the matrix can stretch a vector, the smallest sigma_min the most it can shrink one, and their ratio is kappa_2. An orthogonal matrix like a rotation has kappa_2 exactly 1 — the best possible. A matrix with linearly dependent rows has sigma_min = 0 and kappa_2 infinite, which is why this capability rejects singular matrices instead of printing a meaningless huge number.
How the number is computed here
The algorithm is deterministic and self-contained, with no external numeric library. First your input is normalized: entries may be sent as an array of rows or as plain text with rows separated by newlines or semicolons and values by commas or spaces. Every entry must be a finite number, all rows must have the same length, and the matrix must be square — a 2-by-3 matrix has no condition number in this sense, so the request is rejected with a clear error naming the guilty field. The code then forms the symmetric matrix G = A^T A and extracts its eigenvalues with the classical cyclic Jacobi iteration: a fixed sequence of plane rotations that zero the off-diagonal entries one by one until the matrix is diagonal to working precision. Because the rotation order, the sign convention and the sweep cap are all fixed, the same matrix always yields the same answer, bit for bit. The eigenvalues of G are the squared singular values of A, so their square roots give sigma_max and sigma_min, and the ratio, rounded to twelve decimal places for stable output, is the returned condition number. Matrices whose smallest singular value is below a scaled numerical floor — roughly kappa_2 above ten billion — are reported as numerically singular, because double precision cannot honestly distinguish them from a rank-deficient matrix.
Reading the result and using it well
The response gives you four things: the condition number itself, sigma_max, sigma_min and a plain-language message that classifies the matrix. Treat kappa below about 10 as well-conditioned — direct solvers will behave nicely. Between a hundred and a million, plan for a visible loss of precision and prefer stable algorithms: QR decomposition or LU with partial pivoting rather than forming an explicit inverse, which squares the error of the solve you feed it. Beyond a million, the honest reading is that the answer depends more on your data's noise than on the solver, and the right move is usually to rescale the problem, regularize it, or revisit whether the matrix model is the right one. Two practical habits pay off: check the condition number before blaming a solver for a bad answer, because an ill-conditioned matrix produces wrong answers from correct code; and compare condition numbers across formulations, because the same physical problem written with different units or basis functions can differ by orders of magnitude in kappa. The same code that runs here runs free in your browser on this page, so you can paste a matrix and see the result before paying $0.002 per request to automate it.
What you can do with it
Check a linear system before solving
Estimate how many digits of the solution you can trust before running an LU or QR solve on measured coefficients.
Diagnose a regression that will not converge
A near-collinear design matrix shows up as a huge condition number of X-transpose-X long before the solver fails.
Compare discretizations of the same problem
Two finite-element or basis-function formulations of one physical model can differ by orders of magnitude in conditioning; pick the stable one.
FAQ
What does it cost?
$0.002 per request. It is also free to run in your browser on this page.
Why was my matrix rejected as singular?
Because its smallest singular value is numerically zero, which makes the condition number infinite. This also covers matrices that are technically invertible but rank-deficient to double precision (kappa above roughly ten billion).
Why does the matrix have to be square?
The 2-norm condition number kappa_2 = sigma_max / sigma_min is defined through the singular values of a square coefficient matrix. For rectangular least-squares problems, condition the square matrix X-transpose-X instead.
How can I send the matrix?
As an array of equal-length numeric rows, or as text with rows separated by newlines or semicolons and entries by commas or spaces. Both forms give identical results.
How large a matrix can it take?
Up to 32 by 32, with absolute entry values up to 1e12. The computation is exact arithmetic in double precision with a deterministic Jacobi iteration.
Is the result reproducible?
Yes. The Jacobi iteration uses a fixed rotation order, sign convention and sweep cap, so the same input always produces the same output, rounded to twelve decimal places.
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/condition-number \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"matrix":[[2,1],[1,2]]}'const res = await fetch("https://api.kit.forhosting.com/math/condition-number", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"matrix": [
[
2,
1
],
[
1,
2
]
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/condition-number",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"matrix": [
[
2,
1
],
[
1,
2
]
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/condition-number", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"matrix":[[2,1],[1,2]]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"matrix":[[2,1],[1,2]]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/condition-number", 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": [
[
2,
1
],
[
1,
2
]
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.condition_number",
"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_rows | 32 |
max_cols | 32 |
max_abs | 1000000000000 |
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. |