Matrix Calculator
Define up to 8 matrices (A – H), then combine them with +, −, ×, ÷ and functions like det, inv, rref, and transpose — all evaluated in one expression.
How to use it
- Define a matrix. Tap New Matrix (or any unused letter A–H) to open the editor with a fresh 2×2 of zeros. Type a value, then press Tab, the arrow keys, or the on-screen ← → to move between cells. Empty cells count as 0.
- Resize. Use the Rows −/+ and Cols −/+ controls in the editor header. Any size from 1×1 up to 9×9 is allowed; existing values are preserved when you grow the matrix and trimmed when you shrink it.
- Build an expression. Press a defined matrix's letter (it shows as a small chip at the top of the display) to add it to the expression bar, then combine it with
+,−,×,÷, parentheses, and the operation keys (A², A⁻¹, Aᵀ, Aⁿ, rref, det, trace). Scalar numbers can multiply matrices but cannot be added to them. - Apply an operation to a single matrix. Insert the matrix first, then press the operation. A⁻¹ and Aᵀ wrap the most recent matrix automatically — so pressing B then A⁻¹ turns the expression into
inv(B). det, trace, and rref open a parenthesis for you to fill, e.g.det(→ press A → press ). - Evaluate. Press ↵ (or Enter). The result — a matrix in brackets, or a single number for det and trace — appears below the expression. As you type, the result updates live whenever the expression is valid.
- Re-edit a matrix. Tap any matrix tile at the top of the display to reopen its editor. Changes are reflected immediately in the result.
- Mistakes and undo. Use ⌫ to delete the last character of the expression. Use ↺ / ↻ (or Ctrl+Z / Ctrl+Y) to undo and redo definitions, edits, and resizes. Tap Clear once to wipe just the current expression and result; tap it again (the label changes to Clear All) to also wipe every matrix you've defined. Any other action in between cancels the second-press intent. Both are undoable.
- Persistence. Your matrices and current expression are saved to your browser automatically and restored next time you open the page.
Supported operations
A + B — element-wise addition (matrices must be the same size).
A − B — element-wise subtraction.
A × B — matrix multiplication (A's columns must equal B's rows).
A ÷ B — multiplies A by the inverse of B (B must be square and invertible).
A² — squares a square matrix (equivalent to A × A).
A⁻¹ — matrix inverse (square, non-singular matrices only).
Aᵀ — transpose (swaps rows and columns).
Aⁿ — integer matrix power; type the base matrix then press Aⁿ and enter the exponent.
det(A) — determinant; returns a scalar (square matrices only).
trace(A) — sum of the main diagonal; returns a scalar (square matrices only).
rref(A) — reduced row echelon form.
√ — square root of a scalar value in an expression.
Worked examples
In each example, matrices are written row-by-row in square brackets — [[1,2],[3,4]] means the 2×2 matrix with first row 1 2 and second row 3 4.
1. Add two 2×2 matrices.
Define A = [[1,2],[3,4]] and B = [[5,6],[7,8]].
Build the expression A+B and press ↵.
Result: [[6,8],[10,12]]. Addition is element-wise, so the matrices must have the same shape.
2. Multiply a 2×3 by a 3×2.
Define A = [[1,2,3],[4,5,6]] (2 rows × 3 cols) and B = [[7,8],[9,10],[11,12]] (3 rows × 2 cols).
Evaluate A×B → [[58,64],[139,154]].
The inner dimensions agree (3 cols meet 3 rows), so the product exists; the outer dimensions give the result's shape (2×2). Try B×A instead — it produces a 3×3 because the inner dimensions still match but in the other direction. Matrix multiplication is not commutative.
3. Determinant of a 3×3.
Define A = [[1,2,3],[0,1,4],[5,6,0]].
Evaluate det(A) → 1.
Expanding along the first row by hand: 1·(1·0 − 4·6) − 2·(0·0 − 4·5) + 3·(0·6 − 1·5) = −24 + 40 − 15 = 1.
4. Invert a 2×2 and verify.
Define A = [[4,7],[2,6]].
Evaluate A⁻¹ → [[0.6,−0.7],[−0.2,0.4]].
To check, evaluate A×A⁻¹ → the 2×2 identity [[1,0],[0,1]]. (Tiny rounding from floating-point is snapped to clean integers.)
5. Solve a 2-variable system with rref.
For the system 2x + y = 5, x − y = 1, write the augmented coefficient matrix A = [[2,1,5],[1,−1,1]].
Evaluate rref(A) → [[1,0,2],[0,1,1]]. The reduced form reads off as x = 2, y = 1. (Sanity-check: 2·2 + 1 = 5 ✓ and 2 − 1 = 1 ✓.)
6. Verify det(AB) = det(A)·det(B).
Define A = [[1,2],[3,4]] and B = [[2,0],[1,2]].
Evaluate the chained expression det(A×B) → −8.
Then check the pieces: det(A) → −2, det(B) → 4, and −2 × 4 = −8. The determinant of a product is always the product of the determinants — a useful identity when one factor has a known determinant.
7. Powers of a shear matrix.
Define A = [[1,1],[0,1]].
Evaluate A² → [[1,2],[0,1]]. Now press Aⁿ with the expression A, then type 5 → [[1,5],[0,1]].
For this kind of shear, Aⁿ = [[1,n],[0,1]] in general — handy for spotting patterns by experiment.
8. Transpose changes shape.
Define A = [[1,2,3],[4,5,6]] (2×3).
Evaluate Aᵀ → [[1,4],[2,5],[3,6]] (3×2). Rows become columns and vice versa. Note that (Aᵀ)ᵀ = A — try chaining Aᵀ twice to see it.
9. Trace of a diagonal matrix.
Define A = [[3,0,0],[0,5,0],[0,0,7]].
Evaluate trace(A) → 15. The trace is the sum of the main diagonal — for diagonal matrices, that's just the sum of the entries you typed.
Keyboard shortcuts
A – H — insert matrix name into expression.
0 – 9, . — digits and decimal point.
+ - * / — arithmetic operators.
( ) — parentheses.
Backspace — delete last character.
Enter — evaluate the expression.
Escape — close the matrix editor.
Tab / Shift+Tab — move between cells in the editor.
Arrow keys — navigate cells in the editor.
Ctrl+Z — undo. Ctrl+Y or Ctrl+Shift+Z — redo.
Tips and limits
Up to 8 matrices (A–H) can be defined at once.
Matrix dimensions can be between 1×1 and 9×9.
All arithmetic uses 64-bit floating-point. Results within 1×10⁻¹⁰ of an integer are rounded to that integer.
For rref, irrational values are shown as decimals rounded to 6 significant figures.
Your matrices and the current expression are saved automatically to browser storage and restored when you return.
Tap Clear once to wipe just the current expression while keeping your defined matrices. Tap it a second time — the label flips to Clear All — to also wipe every matrix and start completely fresh.