Matrix
calculator.
Add, multiply, invert or raise matrices up to 5 by 5, with exact fractions.
- Size
- 2 × 2
- Rank
- 2
- Determinant
- 10
Each entry pairs a row of A with a column of B, so the inner sizes must match. BA is also defined here, and it is 3 × 3.
AB as shaded tiles
AB is 2 × 2. Its rows are row 1: 2, −1; row 2: 6, 2. Tiles for positive entries use the first colour and negative entries the second, deeper for larger sizes.
Size, rank, determinant and trace
| Matrix | Size | Rank | det | Trace |
|---|---|---|---|---|
| A | 2 × 3 | 2 | – | – |
| B | 3 × 2 | 2 | – | – |
| AB | 2 × 2 | 2 | 10Trace 4 | 4 |
A dash means the matrix is not square, so it has no determinant or trace.
Working
- 1The matricesA =B =
- 2Check the sizes2 × 3 times 3 × 2: inner sizes match, so AB is 2 × 2.
- 3Entry (1, 1): row 1 of A times column 1 of B1×2+2×0+0×4=2
- 4Entry (1, 2): row 1 of A times column 2 of B1×1+2×(−1)+0×3=−1
- 5Entry (2, 1): row 2 of A times column 1 of B(−1)×2+3×0+2×4=6
- 6Entry (2, 2): row 2 of A times column 2 of B(−1)×1+3×(−1)+2×3=2
- 7The resultAB =
- 8Check: BᵀAᵀ is the transpose of ABBᵀAᵀ =
How it's worked out
A matrix is a grid of numbers with m rows and n columns, called an m by n matrix. Most mistakes with matrices are size mistakes, so the size rules come first. Each operation only works for certain shapes.
| Operation | Needs | Result |
|---|---|---|
| A + B, A − B | Same size | Same size |
| A × B | Columns of A = rows of B | Rows of A by columns of B |
| k × A, Aᵀ | Any size | Same, or flipped for Aᵀ |
| Aⁿ, det, trace | Square A | Square, or one number |
| A⁻¹ | Square, det not 0 | Same size |
Multiplication uses the row-column rule. Entry i, j of AB is row i of A times column j of B: multiply the pairs and add them up. That is why the inner sizes have to match. An m by n matrix times an n by p matrix gives an m by p matrix.
The determinant is one number for a square matrix. For a 2 by 2 matrix it is ad minus bc. A larger one is found by expansion along the first row: each entry times the determinant of what is left when you cross out its row and column, with signs that alternate.
The inverse comes from row reduction. Write A next to the identity matrix I, then row-reduce the whole block. When the left side turns into I, the right side is the inverse. If the left side cannot reach I, A has no inverse.
The rank is the number of pivots left after row reduction, which is the number of independent rows. The trace adds the main diagonal. A power multiplies a square matrix by itself; this tool uses repeated squaring, so the 10th power needs only a handful of products.
Worked examples
Maya multiplies a 2 by 3 matrix by a 3 by 2 matrix
Maya has a homework product with two rectangular matrices. A has 3 columns and B has 3 rows, so the product exists, and it is 2 by 2.
Entry 1, 1 is row 1 of A times column 1 of B: 1 times 2, plus 2 times 0, plus 0 times 4, which is 2. Entry 2, 2 is (−1)(1) + (3)(−1) + (2)(3) = 2.
If she swaps the order, BA is a 3 by 3 matrix instead, with 1 in its top left corner. The two products are not even the same shape.
Leo inverts a 3 by 3 matrix from a physics model
Leo's spring model gives a matrix with 2 on the diagonal and −1 next to it. Its determinant is 4, which is not 0, so the inverse exists.
Every entry is a multiple of 1/4 because the determinant is 4. The check multiplies A by this inverse and gets the identity back.
Sam finds Fibonacci numbers with a matrix power
Sam raises the matrix with rows 1, 1 and 1, 0 to the 10th power. The answer holds three Fibonacci numbers in a row: 34, 55 and 89.
The 5th power gives 3, 5 and 8 in the same places. Each power moves one step along the sequence.
Reading your result
Order matters in a product. With P = [1, 2; 3, 4] and Q = [5, 6; 7, 8], PQ has 19 in its top left corner while QP has 23. Doing one map and then another is not the same as doing them the other way round.
A zero determinant means no inverse. The determinant is 0 exactly when the matrix is not invertible. For [1, 2; 2, 4] it is 0: the second row is twice the first, and the rank is only 1.
Rank counts independent rows. In the 3 by 4 matrix with rows 1, 2, 3, 4 and 2, 4, 6, 8 and 1, 0, 1, 0, the second row is twice the first, so the rank is 2. By the rank theorem, the rank plus the number of free columns equals the number of columns.
Fractions stay exact. The inverse of [1/2, 1/3; 1/4, 1/5] has determinant 1/60, so its inverse has whole numbers: 12, −20, −15 and 30. In the decimal view the same numbers show at the places you pick.
A matrix can act on a point. Rotating the point (3, 1) by 90° is the product of [0, −1; 1, 0] with the column (3, 1), which gives (−1, 3).
Common mistakes
- Multiplying entry by entry. AB is not the grid of products of matching entries. Each entry of AB uses a whole row of A and a whole column of B.
- Checking the wrong sizes. For AB, compare the columns of A with the rows of B. Two 2 by 3 matrices can be added but not multiplied.
- Dividing by a matrix. There is no division. To undo A, multiply by its inverse, and do it on the same side: A⁻¹B and BA⁻¹ are usually different.
- Trusting a nearly zero determinant. A determinant such as 0.000001 still gives an inverse, but its entries are huge and small typing errors swing them a lot.
- Rounding the inputs. Typing 0.33 for one third changes the answer. Type 1/3 to keep it exact.
Questions people ask
Sources
- Margalit and Rabinoff, Interactive Linear Algebra, section 3.4 Matrix Multiplication
- Margalit and Rabinoff, Interactive Linear Algebra, section 3.5 Matrix Inverses
- Margalit and Rabinoff, Interactive Linear Algebra, section 4.1 Determinants
- Margalit and Rabinoff, Interactive Linear Algebra, section 4.2 Cofactor Expansions
- Margalit and Rabinoff, Interactive Linear Algebra, section 2.9 The Rank Theorem