Matrix Calculator
Explore matrix arithmetic, determinants, inverses, and row operations.
Matrix A
Matrix B
Operations
Matrix A holds the coefficients, one row per equation and one column per unknown. Matrix B is the right-hand side b: a single column with one entry per equation.
Result
Choose an operation above. The result follows the matrices as you edit them.
Show calculation steps
Help
Every calculation here is done with exact fractions; nothing is rounded along the way.
Entering a matrix
- Choose the number of rows and columns (up to 10 × 10), then click a cell and type. Entries can be integers (
5,-3), fractions (1/2,-7/4), decimals (0.125,1.5) or scientific notation (2.5e-4). - Tab and Shift+Tab move along a row, cell by cell. Enter moves down the column, and from the bottom to the top of the next one; Shift+Enter moves up. ↑ and ↓ change row; ← and → change cell once the cursor is at the edge of the text.
- Changing the size keeps every entry that still fits; new cells start at 0. Clear sets a matrix to zeros, and the round button between the matrices swaps A and B.
- A cell that is empty or unfinished (such as
1/) is outlined with dashes and simply waits; one that cannot be a number is marked and explained under the matrix.
Pasting from a spreadsheet
Copy a block of cells in Excel, Google Sheets or another spreadsheet, click a cell here and paste. Pasting into the top-left cell replaces the whole matrix, which takes the size of what was pasted; pasting into any other cell fills in from that cell, and the matrix grows if it has to.
Rows may also be separated by new lines or semicolons and entries by tabs, commas or spaces (1, 2; 3, 4), and [[1, 2], [3, 4]] and LaTeX matrices are understood, so anything copied from a result here can be pasted back.
Sizes: what can be added and multiplied
An m × n matrix has m rows and n columns. A + B and A − B need two matrices of the same size, and work entry by entry.
The product AB needs A to have as many columns as B has rows: an m × n matrix times an n × p matrix is m × p. Its entry in row i, column j is row i of A times column j of B:
In general AB ≠ BA. Powers A^n need a square matrix, and A^0 = I. The calculator never changes a size to make an operation possible: it says what the operation needs.
Determinant and inverse
The determinant of a square matrix is one number that tells whether the matrix can be undone. For a 2 × 2 matrix,
and its size is the factor by which the matrix scales areas (volumes, for 3 × 3); a negative sign means orientation is reversed. For larger matrices the calculator reduces to a triangular form: adding a multiple of one row to another does not change the determinant, swapping two rows changes its sign, and the determinant of a triangular matrix is the product of its diagonal.
A square matrix A has an inverse A⁻¹, with AA⁻¹ = A⁻¹A = I, exactly when det A ≠ 0. A matrix with determinant 0 is called singular. The inverse is found by reducing [A | I] to [I | A⁻¹]; for example
Rank, REF and RREF
Row reduction uses three operations that keep the solutions of a system unchanged: swapping two rows, multiplying a row by a nonzero number, and adding a multiple of one row to another.
- A row-echelon form (REF) has its zero rows at the bottom and each row’s first nonzero entry (its pivot) to the right of the pivot above. It is not unique. The one shown here comes from swaps and row replacements only, so its pivots are not scaled to 1.
- The reduced row-echelon form (RREF) also has every pivot equal to 1 and zeros above and below each pivot. Every matrix has exactly one.
- The rank is the number of pivots: the number of independent rows, which is also the number of independent columns. Columns with a pivot are pivot columns; the others are free columns.
Solving a linear system
To solve Ax = b, put the coefficients in Matrix A and the right-hand side in Matrix B as one column. The calculator reduces the augmented matrix [A | b] and reads off the answer:
- a row 0 … 0 | c with c ≠ 0 says 0 = c: there is no solution;
- otherwise, if every column of A has a pivot, there is exactly one solution;
- otherwise each free column gives a free variable that can take any value, and there are infinitely many solutions, written as one solution plus a multiple of one direction for each free variable.
For example 2x + y = 5, x − y = 1 has the one solution x = 2, y = 1.
Exact fractions and decimals
- What you type is read exactly:
0.125is 1/8 and0.1is 1/10, not the nearest binary number. Every result is a fraction in lowest terms, so 1/3 + 1/6 is exactly 1/2, and a pivot or a determinant is zero only when it really is zero. - Decimal only changes how a result is written: to 4, 8, 12 or 15 significant digits, rounded half away from zero. A value that needs no more digits than that is shown as it is; when anything was rounded the result is marked with ≈. Switching back to Exact shows the same fractions as before.
- Use as A and Use as B carry the exact result, whatever the display.
- Limits: matrices up to 10 × 10, entries of up to 40 characters, exponents up to 1000, and numbers of up to 2000 digits during a calculation. Beyond them the calculator says so instead of giving a partial answer.