Solve Matrices - Gaussian Elimination, Inverse, Cramer's Rule
Book A Free Math Class
Solve Matrices - Gaussian Elimination, Inverse, Cramer's Rule
BT
Bhanzu Team Last updated on May 28, 2026 11 min read
How Cayley Turned A Notational Trick Into A Mathematical Object
In 1858, Arthur Cayley published A Memoir on the Theory of Matrices — the paper that named what had been, until then, just a shorthand for the coefficients of a linear system. Cayley defined matrix multiplication, the inverse, and the algebra that would let mathematicians treat a whole system of equations as a single object Ax=b. Without Cayley's paper, the methods in this article — Gaussian elimination, the inverse method, Cramer's rule — would still be three unrelated tricks. With it, they are three views of the same single equation.
To solve matrices means to find the values of the unknown variables x1,x2,…,xnx1,x2,…,xn that satisfy a system of linear equations written in matrix form. For a system Ax=b, the solution is the column vector x. The three standard methods all return the same vector when the system has a unique solution.
The Two Matrix Forms Every Solution Method Uses
Two ways of writing the same system. Choose based on the method.
Form 1 — Coefficient matrix and constant vector. Used for the inverse method and Cramer's rule.
A=(231−2),x=(xy),b=(5−3)
The full equation: Ax=b.
Form 2 — Augmented matrix. Used for Gaussian elimination. The constant vector is appended as the last column, separated by a vertical bar.
[2351−2−3]
Same system, two layouts. The choice depends on the method.
Method 1 — Gaussian Elimination (The Workhorse)
The most reliable method. Three row operations are allowed:
- Swap two rows.
- Multiply a row by a non-zero scalar.
- Add a multiple of one row to another row.
Apply them in sequence to reduce the augmented matrix to row-echelon form — leading 1s on the diagonal, zeros below each leading 1. Then back-substitute to find the variables.
For very large systems, professional software uses LU decomposition or QR factorisation — both are dressed-up forms of Gaussian elimination. The 19th-century algorithm is what your laptop runs when you call NumPy's linalg.solve.
Method 2 — The Matrix-Inverse Method
If AAA is invertible (i.e., det(A)≠0), the solution is:
x=A−1b.
Compute the inverse A−1, then multiply by b. For a 2×2 matrix:
A−1=1det(A)(d−b−ca)where A=(abcd).
For a 3×3 matrix, use the adjoint divided by the determinant — the algebra is heavier but the principle is the same.
Cost: computing an inverse is roughly the same work as Gaussian elimination. The inverse method is only faster when you need to solve Ax=b for many different b vectors with the same A. Otherwise, prefer Gaussian elimination.
Method 3 — Cramer's Rule
Each unknown is a ratio of determinants. For a system Ax=b with det(A)≠0:
xᵢ=det(Aᵢ)/det(A)
where Aᵢ is the matrix obtained by replacing the iii-th column of A with b.
Cramer's rule is elegant for 2×2 and 3×3 systems, and impractical for anything larger — the determinant computation scales as n!, while Gaussian elimination scales as n³. For a 5×5 system, Cramer's rule does 6 determinants — each of which is a 120-term sum — while Gaussian elimination does about 100 arithmetic operations.
Quick — Standard — Stretch: Three Worked Examples
Quick — solve a 2×2 system by Gaussian elimination
System: x+2y=5 and 3x−y=1. Augmented matrix:
[1253−11]
R2←R2−3R1:
[1250−7−14]
From row 2: −7y=−14⇒y=2. Back-substitute: x+2(2)=5⇒x=1.
Final answer: x=1, y=2.
Standard (Wrong-Path-First) — solve a 2×2 system by the inverse method
System: 2x+4y=8, x+2y=4.
Wrong path. Plug straight into the inverse formula. A=(2412), so det(A)=2⋅2−4⋅1=0. The student who jumped ahead writes A−1=1/0 — and either freezes at the division by zero or invents a non-existent "0-determinant inverse."
The diagnosis. A zero determinant means the matrix is singular — there is no inverse, and the inverse method cannot be used. The system either has no solutions or infinitely many. The two equations are linearly dependent. The solution set is the entire line x+2y=4.
Final answer: Infinitely many solutions; the system reduces to the single equation x+2y=4.
Stretch — solve a 3×3 system using Cramer's rule
System: x+2y+3z=9, 2x−y+z=8, 3x+y−z=2.
A=(1232−1131−1), b=(982).
Compute det(A) by cofactor expansion along row 1: det(A)=25.
Ax replaces column 1 with b: Ax=(9238−1121−1). Expanding: det(Ax)=50.
Ay replaces column 2 with b: det(Ay)=25.
Az replaces column 3 with b: det(Az)=25.
Final answer: x=2, y=1, z=1.
When Does A System Have No Solution, One Solution, or Infinitely Many?
Three cases, decided by the rank of the augmented matrix versus the rank of the coefficient matrix.
- Unique solution. det(A)≠0. The lines (in 2D) or planes (in 3D) intersect at exactly one point.
- No solution. det(A)=0 and the augmented matrix has a row of the form [0,0,…,0|c] with c≠0 after row reduction. The lines are parallel; the planes don't all meet.
- Infinitely many solutions. det(A)=0 and the augmented matrix's reduced form has no contradictory row — at least one variable is free. The lines coincide; the planes share a line or more.
The determinant is the diagnostic. Always compute it first.
Why matrix methods matter — from GPS to image compression
The methods in this article scale to systems with millions of variables — and modern engineering runs on them.
- GPS triangulation. Your phone solves a linear system to compute its position from four satellite signals.
- Computer graphics. Every 3D rendering involves multiplying vectors by transformation matrices.
- Image and audio compression. JPEG, MP3, and H.264 all use linear-algebra-heavy transforms.
- Machine learning. Training a neural network involves repeatedly solving very large linear systems Ax=b.
Where Students Lose Marks On Solving Matrices
Mistake 1: Skipping the determinant check before inverting
Where it slips in: Inverse-method problems where the matrix is singular.
The correct way: Compute det(A) first. If zero, switch to Gaussian elimination.
Mistake 2: Mixing row operations across the augmented column
Correct way: Treat the augmented matrix as a single object.
Mistake 3: Confusing Cramer's rule's denominator and numerator
Correct way: The original det(A) goes in the denominator for every variable.
Cayley and Gauss — A Short History
- Carl Friedrich Gauss formalised the elimination method.
- Arthur Cayley defined matrix multiplication, the identity matrix, and the matrix inverse.
What to Remember About Solving Matrices
- A system Ax=b has three solution methods: Gaussian elimination, the inverse method, and Cramer's rule.
- The determinant is the diagnostic — non-zero means a unique solution.
- Gaussian elimination is the workhorse; the inverse method is for repeated right-hand sides; Cramer's rule is for small systems.
Where To Go From Here — Three Problems
- Solve 3x+y=10 and x−2y=−1 using Gaussian elimination.
- Show that the system 4x+2y=6 and 2x+y=3 has infinitely many solutions.
- Solve the system 2x+y+z=4, x−y+z=0, x+y−z=2 using Cramer's rule.