Linear Algebra
Identity Matrix
Generate an n×n identity matrix.
Formula
Formula
Iij = 1 if i=j else 0
Variables
| Symbol | Definition | Type & range | Units | Role |
|---|---|---|---|---|
| n | matrix size | integer (ℤ) | — | input |
Try it yourself
Interactive calculator
Worked examples
Example 1
Givenn = 4
Result
| 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 0 | 0 | 1 |
Example 2
Givenn = 2
Result
| 1 | 0 |
| 0 | 1 |