Cramer's rule calculator
If 2x + y and x + 3y both equal 5, the solution is (2, 1), with determinants 5, 10 and 5: enter the coefficients and constants and see each unknown as a ratio of two determinants. 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.
Cramer's rule is the classical determinant method for solving a square linear system of the form A times x equals b when the coefficient matrix A is invertible. For an n by n matrix you compute the main determinant D equals det of A, then for every column index i you replace that column of A with the constants vector b to form A sub i and set the unknown x sub i equal to det of A sub i divided by D. The construction is exact in exact arithmetic, fully transparent for homework checks, and still useful as a teaching oracle next to Gaussian elimination. This calculator accepts a nested coefficient matrix and a matching constants vector, returns every variable with its replacement determinant, and rejects a zero coefficient determinant with a clear validation error so singular or dependent systems are never presented as unique solutions.
How Cramer's rule solves Ax equals b
Start from a square real system written as A times x equals b, where A is an n by n coefficient matrix, x is the unknown column vector of length n, and b is the right-hand side of length n. Cramer's rule first demands that D equals the determinant of A is nonzero; otherwise the matrix is singular and there is either no solution or infinitely many, and the classical formula is undefined. When D is nonzero there is exactly one solution.
For each index i from zero through n minus one, form the matrix A sub i by copying A and replacing column i with the entire vector b, leaving every other column untouched. Compute D sub i equals det of A sub i with the same determinant algorithm used for D. Then the unique value of the i-th unknown is x sub i equals D sub i divided by D.
For two-by-two systems the determinants reduce to the familiar ad minus bc products students memorize; for three-by-three systems a first-row Laplace expansion is standard; for larger n a pivoted LU factorization evaluates each determinant in cubic time. After all n quotients are known you hold the full solution vector and can substitute back into every equation to verify residuals near zero. Entries must be finite; NaN and Infinity are rejected.
Dimension mismatches between the matrix and the constants vector fail early with invalid input. A coefficient determinant numerically indistinguishable from zero fails with a message that Cramer's rule requires a non-singular matrix, so clients can switch to a rank analysis or least-squares path rather than guessing.
Where Cramer's rule calculators show up in real work
Secondary-school and college linear algebra courses constantly assign Cramer's rule drills, two-by-two and three-by-three systems with integer solutions, and comparisons against elimination; a single trusted oracle that returns every variable beside its replacement determinant speeds grading and demo setup. Programming contest problems and interview warm-ups often hide small dense systems under geometry constraints, circuit laws, or mixture equations, and engineers need exact unique solutions with transparent intermediate determinants rather than a black-box solver that only prints the vector.
Control labs and introductory circuit analysis still walk students through Cramer's rule before introducing matrix factorizations, so matching det of A and det of A sub i to hand work matters more than asymptotic cost. Numerical methods courses use Cramer's rule as a contrast case against Gaussian elimination and iterative methods, and need a correct singular rejection when the coefficient determinant vanishes.
If you later need only the determinant of a matrix, a reduced-row-echelon form, least-squares for non-square systems, or eigenvalue solvers, treat those as separate search intents and landings rather than overloading this Cramer's rule calculator page.
What you can do with it
Homework and exam answer keys
Generate each variable, det(A), and replacement det(A_i) for textbook Ax=b sets so teachers and auto-graders share one Cramer's rule ground truth.
Small circuit and mixture systems
Solve two- and three-equation Kirchhoff or mixture problems with transparent determinants instead of opaque black-box linear solvers.
FAQ
What happens if the coefficient determinant is zero?
Cramer's rule requires det(A) ≠ 0 for a unique solution; singular or dependent systems are rejected rather than inventing values.
What matrix sizes are supported?
Square systems from 1×1 through 8×8. Determinants use closed forms for 1×1 and 2×2, cofactor expansion for 3×3, and LU with partial pivoting for larger n.
How do I format the input?
Send matrix as a nested array of rows (e.g. [[2,1],[1,3]]) and constants as a matching length-n array (e.g.
What does it cost?
The browser tool is free and runs locally.
How does Cramer's rule work?
Find the determinant D of the coefficients, then replace one column at a time with the constants and divide each new determinant by D. If 2x + y and x + 3y both equal 5, D is 5, so x is 10 ÷ 5, or 2, and y is 5 ÷ 5, or 1.
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/algebra/cramers-rule \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"matrix":[[2,1],[1,3]],"constants":[5,5]}'const res = await fetch("https://api.kit.forhosting.com/algebra/cramers-rule", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"matrix": [
[
2,
1
],
[
1,
3
]
],
"constants": [
5,
5
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/algebra/cramers-rule",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"matrix": [
[
2,
1
],
[
1,
3
]
],
"constants": [
5,
5
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/algebra/cramers-rule", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"matrix":[[2,1],[1,3]],"constants":[5,5]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"matrix":[[2,1],[1,3]],"constants":[5,5]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/algebra/cramers-rule", 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,
3
]
],
"constants": [
5,
5
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "algebra.cramers_rule",
"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.
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
How Cramer's rule solves Ax equals b
The entire pipeline is deterministic floating-point arithmetic: no random seeds, no wall-clock timestamps, no network calls, and no model drift, so identical matrix and constants always produce identical JSON.
What you send and what you get back
Send two fields. Both fields are required. Classic textbook checks include the two-by-two system two x plus y equals five and x plus three y equals five with solution x equals two and y equals one, and any three-by-three invertible classroom example with integer answers. The field matrix is a square nested array of finite numbers, or a JSON string of that shape, with at most eight rows and eight columns. The field constants is a length-n array of finite numbers, or a JSON string of that array, matching the matrix dimension exactly. Missing fields, non-numeric strings, NaN, Infinity, non-square matrices, empty matrices, oversized dimensions, and constants of the wrong length fail with invalid_input and are not charged. When det of A is zero or extremely close to zero the request fails with a message that the coefficient determinant is zero and Cramer's rule cannot produce a unique solution. On success the response echoes the cleaned matrix and constants, a printable multi-equation system string, the main determinant, the array det_columns of the n replacement determinants, the solution array of n numbers, and a variables array of objects each with a human name such as x, y, z or x1 through xn, the numeric value, and the corresponding det_Ai. The flags unique true, method cramers_rule, and det_method closed or cofactor or LU document how the determinants were evaluated. Pricing for successful API calls is the published base of $0.002 per item; validation failures do not consume prepaid balance.
Where Cramer's rule calculators show up in real work
Because this capability is a pure parse engine, API pricing is the published base of $0.002 per successful item and failed validation does not consume balance.
Integration use cases
Contest and interview fixtures
Bulk-produce unique solutions for dense n≤8 systems and catch singular coefficient matrices with a hard invalid_input instead of silent NaNs.
Technical questions
What is Cramer's rule?
For a square invertible system Ax=b, each unknown is x_i = det(A_i)/det(A), where A_i is A with column i replaced by the constants vector b.