ForHosting KIT · Developer Utilities

Cofactor matrix calculator

The cofactor matrix API takes a square matrix, entry by entry, and returns the matrix of its cofactors: for each position (i, j), the signed determinant of the minor you get by removing row i and column j.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

It is the intermediate step behind the adjugate, the inverse formula A^-1 = adj(A)/det(A) and every textbook determinant expansion, computed in one deterministic call instead of by hand, sign by sign, with every entry validated before any arithmetic begins.

What a cofactor matrix actually is

For a square matrix A, the cofactor C(i,j) combines two things: the minor M(i,j), which is the determinant of the submatrix left after deleting row i and column j, and a checkerboard sign (-1)^(i+j) that alternates across rows and columns. The cofactor matrix collects every C(i,j) in the same position as the original entry, so it has exactly the same shape as A. Students meet it as the machinery behind Laplace expansion along a row or column, but it is far more than an exercise: the transpose of the cofactor matrix is the adjugate, and dividing the adjugate by the determinant yields the inverse whenever the determinant is not zero. Getting one sign wrong anywhere flips a whole row or column of the result, which is exactly the kind of quiet mistake a deterministic computation removes for good. You send the entries, you receive the full cofactor matrix with every sign already applied, plus the order n so the response is completely self-describing.

How the computation is done

Each cofactor needs the determinant of an (n-1) x (n-1) minor, so the endpoint computes n squared determinants internally for a matrix of order n. Each one is evaluated by Gaussian elimination with partial pivoting, a method that is exact for the integer and simple-decimal matrices people actually send and numerically well behaved for everything else, unlike naive recursive expansion, whose cost explodes factorially with n. Results are rounded to nine decimal places so the answer is byte-for-byte stable no matter where it runs. The input contract is strict on purpose: the matrix must be square, every entry must be a finite number, and the order is capped at ten, because beyond that a cofactor matrix is rarely what you want — its cost grows as the fifth power of n and the adjugate-inverse route is the slowest known way to invert anything. A 1x1 matrix returns [[1]], the convention that keeps A times adj(A) equal to det(A) times the identity true at that edge case.

When to use it and when not to

Use it when the cofactor matrix itself is the deliverable: checking homework entry by entry, generating fully worked examples for teaching, verifying an implementation of the adjugate formula against a trusted reference, or feeding a symbolic pipeline that needs each signed minor explicitly rather than a single aggregated number. If what you really need is the determinant alone or the inverse, those are separate, cheaper capabilities — the determinant is one number and the inverse is computed directly with Gauss-Jordan elimination rather than through n squared minors. The same code that answers the API runs free in your browser on this page, so you can paste a matrix, inspect the result and only pay — $0.002 per request — when you automate the call from your own system. Nothing you send is kept anywhere: the matrix is processed in memory and discarded, and only the cofactor matrix is returned to you.

Check linear algebra homework

Compare your hand-computed cofactors, signs included, against an exact result for any square matrix up to 10x10.

Verify an adjugate implementation

The adjugate is the transpose of the cofactor matrix; test your code against golden outputs before trusting its inverse formula.

Generate worked teaching examples

Produce complete cofactor matrices for lecture notes or exercises without computing n squared minors by hand.

What does it cost?

$0.002 per request via the API. It is also free to run in your browser on this page, with the same code and the same result.

What exactly is a cofactor?

C(i,j) = (-1)^(i+j) times the determinant of the minor obtained by removing row i and column j. The cofactor matrix places each C(i,j) in the same position as the original entry.

What input does it accept?

A square matrix as an array of rows, each row an array of finite numbers, from 1x1 up to 10x10. A ragged matrix or a non-numeric entry is rejected with a clear error naming the offending position.

What does a 1x1 matrix return?

[[1]], the standard convention, so that the identity A times adj(A) equals det(A) times the identity also holds for n = 1.

Is the matrix stored after the call?

No. It is processed in memory and discarded; only the cofactor matrix and its order are returned.

Why is the order limited to 10?

A cofactor matrix requires n squared minor determinants, so the work grows very quickly with n. Above 10x10 the cofactor route is almost never the right tool; the determinant or inverse capabilities answer those needs directly.

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-matrix

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-matrix \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"matrix":[[1,2],[3,4]]}'
{
  "matrix": [
    [
      1,
      2
    ],
    [
      3,
      4
    ]
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.cofactor_matrix",
  "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.

max_n10
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.

Read the full KIT documentation →