A matrix calculator that handles everything from a 2×2 textbook exercise to a 6×6 engineering problem. Multiply A × B, add or subtract two matrices, find the determinant, compute the inverse via Gauss-Jordan elimination, raise a matrix to any integer power, check the rank, or simply transpose — all with instant results and optional step-by-step dot-product working for multiplication.
How matrix multiplication works
Two matrices A (m×k) and B (k×n) can be multiplied only when A’s column count equals B’s row count — that shared dimension k is the inner dimension. The result C is an m×n matrix where every entry is a dot product:
C[i, j] = Σ A[i, p] · B[p, j] for p = 1 to k
In plain terms: take row i of A, take column j of B, multiply each pair of corresponding numbers, and add up all k products. Do that for every (i, j) combination. Toggle “Show step-by-step working” to see every dot product written out — hover a step to highlight the contributing row and column in the input grids.
Other operations
- Transpose (Aᵀ) — flip rows and columns: Aᵀ[i, j] = A[j, i]. An m×n matrix becomes n×m.
- Determinant — computed via Gaussian elimination with partial pivoting: the product of the diagonal of the upper-triangular form, with a sign flip for every row swap. Zero determinant means the matrix is singular.
- Inverse (A⁻¹) — Gauss-Jordan on the augmented block [A | I]. Requires a square, non-singular matrix. The calculator reports if A is singular rather than dividing by zero.
- Matrix power (Aⁿ) — computed via repeated squaring in O(log n) multiplications. Supports negative exponents by first inverting A.
- Rank — counts non-zero pivot rows after elimination, using a tolerance of 10⁻¹² to handle floating-point near-zeros.
Worked example
Let A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] and B = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]. Both are 3×3 so the product is also 3×3.
C[1,1] = 1·9 + 2·6 + 3·3 = 9 + 12 + 9 = 30
C[1,2] = 1·8 + 2·5 + 3·2 = 8 + 10 + 6 = 24
Continuing for all nine entries:
| Col 1 | Col 2 | Col 3 | |
|---|---|---|---|
| Row 1 | 30 | 24 | 18 |
| Row 2 | 84 | 69 | 54 |
| Row 3 | 138 | 114 | 90 |
Notice A has rank 2 (row 3 = row 1 + row 2 × 2 − row 1, i.e. the rows are linearly dependent), so its determinant is 0 and it has no inverse. Click Fill example in the calculator to load these exact values.
For a better inverse example, try A = [[2, 1, 0], [1, 3, 1], [0, 1, 4]]: det(A) = 2(12 − 1) − 1(4 − 0) + 0 = 22 − 4 = 18 — non-singular.
Formula note
The general rule for an m×k matrix times a k×n matrix:
| Property | Rule |
|---|---|
| Required dimensions | A: m×k, B: k×n |
| Result dimensions | m×n |
| Element formula | C[i,j] = Σₚ A[i,p] · B[p,j] |
| Commutative? | No — A×B ≠ B×A in general |
| Associative? | Yes — (A×B)×C = A×(B×C) |
| Identity element | I (identity matrix, 1s on diagonal) |
Floating-point results are rounded to nine significant figures to suppress machine-epsilon noise (e.g. 1.23×10⁻¹⁶ displays as 0).