ForHosting KIT · Math

Cofactor expansion calculator

Expand a determinant along the row or column you pick and see every term: in the 3×3 example, the first row contributes 4, 5 and −60, which add up to −51. Compare lines to find the shortest route. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon

Runs in your browser. Free, unlimited — your data never leaves this page.

Cofactor expansion, also called Laplace expansion, is the classical recursive definition of the determinant: pick any row or column, multiply each entry by its signed minor, and add the results. This calculator lets you choose exactly which row or column to expand along — a genuine pedagogical difference, because a line full of zeros makes the arithmetic trivial while a dense line makes it long. It returns the determinant together with the full expansion breakdown: every entry of the chosen line, its alternating sign, its cofactor computed from the corresponding minor, and its contribution to the final sum. Non-square matrices are rejected with a clear validation error, because the determinant is only defined for square matrices.

How cofactor expansion along a chosen line works

The result is identical no matter which line you pick, which is exactly the theorem students are asked to verify in linear algebra courses. This capability applies that recursion literally. For the chosen row or column it computes each minor determinant by expanding again along the first row of the smaller submatrix, recursing down to the one-by-one base case where the determinant is the single entry, with the two-by-two case short-circuited to the closed form ad minus bc.

The output exposes every intermediate quantity: each entry of the expansion line, the alternating sign determined by its position parity, the cofactor value, and the contribution entry times cofactor. Summing the contributions column by hand reproduces the returned determinant, which makes the tool useful for auditing work rather than merely checking a final number. Because the recursion is factorial in cost, dimensions are capped at ten by ten; classroom and contest sizes are fully covered.

Why choosing the expansion line matters

The determinant is invariant across expansion lines, but the work to compute it by hand is not. Expanding along a row or column that contains zeros eliminates terms entirely, because a zero entry contributes nothing no matter how large its cofactor would be; textbooks teach students to hunt for the sparsest line before touching any minor, and this calculator demonstrates that strategy concretely by letting you compare a row expansion against a column expansion on the same matrix.

Teachers use it to build step-by-step solutions: the terms array is exactly the sequence of products a student should write down, so answer keys can show every cofactor rather than a bare final number. Students use it to find their own mistakes — when a hand computation disagrees with the tool, the per-term breakdown localizes the error to one specific minor instead of forcing a full redo. Programmers verifying a small determinant routine in a contest setting can also use the cofactor path as an independent oracle against LU-based implementations.

If you need a plain determinant without choosing a line, matrix inversion, eigenvalues, or symbolic minors over polynomials, treat those as separate intents rather than overloading this cofactor expansion page.

Step-by-step homework solutions

Expand det(A) along a chosen row or column and get every entry, sign, cofactor, and contribution so answer keys show the full Laplace expansion, not just the final number.

Zero-line expansion strategy drills

Compare expansions along different rows and columns of the same matrix to demonstrate why picking the line with the most zeros minimizes hand computation.

Error localization for students

When a hand computation disagrees with the returned determinant, diff the per-term breakdown against the student's work to find the exact minor where the mistake happened.

Does the choice of row or column change the determinant?

No. Laplace's theorem guarantees the same value along any row or column. The choice only changes how much arithmetic the expansion takes — lines with more zeros are cheaper, which is why this calculator lets you pick the line.

What happens if the matrix is not square?

The determinant is only defined for square matrices; jagged rows or unequal row versus column counts are rejected with a message that names the failing row.

What does the terms array contain?

The determinant is the sum of all contributions.

What is the maximum matrix size?

n ≤ 10. Minors are expanded recursively, which is factorial in cost; the cap keeps the free parse path sub-millisecond. Classroom and contest sizes are fully covered.

What does it cost?

The browser tool is free and runs locally.

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.

POSThttps://api.kit.forhosting.com/math/cofactor-expansion-old

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.

curl -X POST https://api.kit.forhosting.com/math/cofactor-expansion-old \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"matrix":[[2,1,3],[0,4,1],[5,2,1]]}'
{
  "matrix": [
    [
      2,
      1,
      3
    ],
    [
      0,
      4,
      1
    ],
    [
      5,
      2,
      1
    ]
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.cofactor_expansion_old",
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

How cofactor expansion along a chosen line works

The Laplace expansion theorem states that the determinant of an n by n matrix can be computed along any single row or column: multiply each entry a_ij of that line by its cofactor C_ij, where the cofactor is (-1) raised to the power i plus j times the determinant of the minor obtained by deleting row i and column j, then sum all n products. All arithmetic is deterministic floating-point code with no random seeds, no wall-clock timestamps, and no network calls, so identical inputs always produce byte-identical JSON.

What you send and what you get back

Zero entries still appear in the terms array with contribution zero, so the expansion is fully auditable. Wire the free browser form for quick checks, then call the identical contract from scripts for bulk answer keys. Send one required field named matrix: a nested JSON array of rows of finite numbers, or a JSON string encoding the same nested array. Every row must have the same length, and that length must equal the number of rows so the matrix is square; a two-by-three grid fails immediately with invalid_input and a message that names the offending row. Two optional fields steer the expansion. axis, with alias along, accepts row or col and defaults to row. index, with alias line, is the one-based position of the row or column to expand along and defaults to one; it must be an integer between one and n. Missing matrix, non-array shapes, jagged rows, non-numeric cells, NaN, Infinity, empty grids, dimensions above ten, an unknown axis, or an out-of-range index all fail with invalid_input and are not charged. On success the response echoes the cleaned matrix with stable twelve-significant-digit rounding, the integer dimension n, the resolved axis and index, the determinant as a number, abs_determinant, sign as minus one, zero, or plus one, a boolean is_singular flag, the full terms array with entry, row, col, sign, cofactor, and contribution for every position of the expansion line, and a short formula string naming the line used. Successful API calls cost the published base of $0.002 per item; validation failures do not consume prepaid balance.

Why choosing the expansion line matters

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.

Read the full KIT documentation →