Matrix Calculator: a complete guide
What a matrix is and why engineers use them
A matrix is a rectangular grid of numbers arranged in rows and columns. A matrix with 3 rows and 2 columns is called a 3 by 2 matrix. Matrices look like a simple table, but they let one compact object stand for a whole set of calculations, which is why they appear all over engineering: structural analysis, circuit networks, computer graphics, control systems, statistics and machine learning all rely on them.
A stiffness matrix describes how a structure resists load. A rotation matrix turns a point around an axis. A set of simultaneous equations in a circuit can be written as one matrix equation. Once the problem is in matrix form, the same few operations solve it, and those operations are exactly what this calculator performs.
The operations, in plain language
Each button on the calculator does one standard operation. Here is what they mean and when each one is allowed.
- Addition and subtraction work entry by entry, so both matrices must be the same size.
- Multiplication is row by column. Each entry of the result is a row of the first matrix multiplied by a column of the second and added up. The first matrix must have as many columns as the second has rows. Unlike ordinary numbers, A times B is usually not equal to B times A, which is why there are separate A x B and B x A buttons.
- The transpose flips a matrix over its main diagonal, so rows become columns.
- The determinant is a single number for a square matrix. If it is zero, the matrix is singular, which means it squashes space flat and cannot be undone.
- The inverse of a square matrix, written A to the power of minus 1, is the matrix that gives the identity matrix when multiplied by A. It exists only when the determinant is not zero.
- The rank is the number of independent rows. A square n by n matrix has an inverse exactly when its rank is n.
- The trace is the sum of the numbers on the main diagonal of a square matrix.
- The row reduced echelon form is what you get after Gauss-Jordan elimination. It is the standard way to solve equations and find the rank by hand.
A worked example
Take A with rows (1, 2) and (3, 4). Its determinant is 1 x 4 minus 2 x 3, which is minus 2. Because that is not zero, A has an inverse. The inverse has rows (-2, 1) and (1.5, -0.5), or in fractions (-2, 1) and (3/2, -1/2). You can check it by multiplying A by that result: you get the identity matrix with 1s on the diagonal and 0s elsewhere.
To try it, leave the default matrices, press Determinant and then Inverse. Switch the result format to Fractions to see the exact values instead of decimals.
Exact fractions instead of rounded decimals
Most calculators work with decimals, and decimals pick up tiny rounding errors in every step. Invert a 4 by 4 matrix this way and a value that should be exactly 0 can come out as 0.0000000001, which then makes the determinant look non-zero when it truly is zero.
This calculator does its arithmetic with exact fractions made of arbitrarily large whole numbers, so 1/3 is stored as 1/3 and never as 0.3333. Zero really is zero, singular matrices are detected correctly, and you can choose to read the answer as an exact fraction or as a decimal rounded to six places only at the very end.
Common mistakes
- Multiplying matrices with mismatched sizes. Check that columns of A equal rows of B.
- Expecting A times B to equal B times A. It usually does not.
- Trying to invert a matrix whose determinant is zero, or one that is not square.
- Typing a decimal comma or stray text. Use a dot or a fraction such as 3/4.
- Forgetting that empty boxes count as 0.