Identity matrix generator
Choose the order n and get the exact identity matrix: for order 3, three ones on the diagonal and six zeros elsewhere. Use it to start a Gauss-Jordan inverse or to write A − λI. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- N
- 3
- Diagonal
- 1, 1, 1
- Ones
- 3
- Zeros
- 6
The identity matrix of order n is the unique n-by-n square matrix that has ones along the main diagonal and zeros in every off-diagonal cell. It is the multiplicative identity of matrix algebra: multiplying any compatible matrix A on the left or the right by I leaves A unchanged. Students meet I_n in the first week of linear algebra; engineers use it to seed Gauss-Jordan inverses, to write A minus lambda I for characteristic polynomials, and to initialize homogeneous linear systems. This identity matrix generator accepts a positive integer dimension n and returns the exact I_n as a nested array of zeros and ones, together with the diagonal list, the counts of ones and zeros, and a short Kronecker-delta formula.
What the identity matrix is and how I_n is built
An identity matrix I_n is defined entrywise by the Kronecker delta: the entry in row i and column j equals one when i equals j and equals zero otherwise. That single rule produces the familiar pictures students copy by hand: the one-by-one identity is a lone one; the two-by-two identity has ones at positions one-one and two-two with zeros in the corners; the three-by-three identity places ones on the main diagonal and zeros in the six off-diagonal cells. The same pattern continues for every positive integer n.
Algebraically I_n is the unique n-by-n matrix that satisfies A times I equals I times A equals A whenever the products are defined, which is why it plays the role that the number one plays for ordinary multiplication. Its determinant is one, its rank is n, its trace is n, its inverse is itself, and every eigenvalue is one.
Those textbook facts make I_n the default starting point for inverse algorithms, the shift term in A minus lambda I, and the homogeneous right-hand side when you write A x equals I x. This generator does not invent a floating-point approximation: every accepted n produces exact integer zeros and ones. Classic checks include n equals one giving a single one, n equals three giving the familiar three-by-three identity, and n equals four giving sixteen entries of which exactly four are ones.
Where an identity matrix generator earns its keep
Secondary-school and college linear algebra courses constantly assign fill-in-the-blank identity grids, similarity checks that leave I_n unchanged, and Gauss-Jordan drills that begin by writing A beside I. A single trusted oracle that returns the nested array, the diagonal list, and the entry counts speeds grading and demo setup without asking learners to retype a three-by-three by hand. Computer graphics and robotics notebooks seed homogeneous transforms with I_4; statistics and machine learning pipelines initialize covariance or attention masks from I_n before adding noise.
If you later need the product of two matrices, the inverse of a square matrix, the determinant, the rank, or the trace, treat those as separate search intents and landings rather than stretching this identity matrix generator page to cover every linear-algebra verb.
What you can do with it
Homework and exam answer keys
Generate I_n, the diagonal of ones, and entry counts for textbook 2×2, 3×3, and small n×n sets so teachers and auto-graders share one ground truth.
Gauss-Jordan and inverse seeds
Emit the identity block that sits beside A in an augmented system, or the I_n used to check that A times A inverse equals the identity.
FAQ
What is an identity matrix?
The identity matrix I_n is the n×n square matrix with ones on the main diagonal and zeros elsewhere. Multiplying a compatible matrix A by I_n leaves A unchanged.
What happens if n is zero or negative?
Non-positive dimensions are rejected; this generator only builds a visible I_n for n ≥ 1.
What is the maximum matrix size?
n ≤ 32. Larger dense identity matrices are outside the free parse path; classroom, contest, and notebook sizes are fully covered.
Is the result exact or a floating-point approximation?
Exact integers. Every accepted n writes 1 on the diagonal and 0 elsewhere. There is no rounding, no random seed, and no date-dependent path.
What does the identity matrix generator cost?
The browser tool is free and runs locally.
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/identity-matrix \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":3}'const res = await fetch("https://api.kit.forhosting.com/algebra/identity-matrix", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": 3
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/algebra/identity-matrix",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": 3
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/algebra/identity-matrix", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":3}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":3}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/algebra/identity-matrix", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"n": 3
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "algebra.identity_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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_n | 32 |
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
Non-positive dimensions, non-integers, and oversized requests are rejected with invalid_input instead of a silent empty grid.
What the identity matrix is and how I_n is built
The algorithm is a nested loop that writes one on the diagonal and zero elsewhere, with no random seeds, no wall-clock timestamps, and no network calls, so identical n always yields identical JSON.
Input contract, response shape, and error behaviour
Zero and negative orders are rejected because a non-positive dimension is not a classroom identity grid: the empty zero-by-zero convention is deliberately out of scope. Example: n equals three yields the three-by-three identity with ones at the three diagonal cells and zeros in the six remaining cells. Pair the matrix with sibling landings when you next need a product, a transpose, a trace, or an inverse rather than overloading this identity page. POST a JSON body with one required field named n: a positive integer dimension of the identity matrix I_n. Each value may be a JSON integer or a decimal integer string such as three. Missing n, empty strings, non-numeric text, fractional numbers, NaN, and Infinity fail with invalid_input naming the field. Dimensions above thirty-two are rejected so a free parse Worker never materializes an oversized dense array. On success the body includes the echoed integer n, the nested matrix of zeros and ones, the diagonal list of n ones, ones equal to n, zeros equal to n squared minus n, method kronecker_delta, and a short formula string restating I_n of i j equals one if i equals j else zero. Pricing for successful API calls is the published base of $0.002 per item; validation failures do not consume prepaid balance.
Where an identity matrix generator earns its keep
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 fixtures and numeric tests
Build deterministic I_n fixtures for coding contests, unit tests, and notebooks that need exact zeros and ones without a hand-rolled loop.