Matrix Equation: How to Solve AX = B with Examples
Matrix Equation: How to Solve AX = B with Examples
The Equation That Solves a Hundred Equations at Once
A power-grid engineer can face a hundred linear equations that must all hold at once. Economists modelling a market and graphics programmers lighting a scene hit the same wall, and writing those equations one by one is hopeless. The matrix equation collapses the entire system into three letters, AX=B, and hands it to a single, reliable solving rule. One compact statement, and the whole tangle becomes solvable.
What a Matrix Equation Is
A matrix equation is an equation of the form AX=B, where A is the coefficient matrix, X is the column matrix of unknown variables, and B is the column matrix of constants. It is the matrix form of a system of linear equations: every equation in the system becomes one row of A paired with one entry of B.
For example, the system
2x + 3y = 5
4x - y = 1
becomes the matrix equation
[ \begin{bmatrix} 2 & 3 \ 4 & -1 \end{bmatrix} \begin{bmatrix} x \ y \end{bmatrix} = \begin{bmatrix} 5 \ 1 \end{bmatrix} ]
The first matrix is A, the column of variables is X, and the column of constants is B. Solving the matrix equation means finding the X that makes the product equal to B. This is the same problem as solving a system of equations — only written so a single operation can finish it.
How Do You Write a System as a Matrix Equation?
Three steps turn any linear system into AX = B.
Line up the variables. Write each equation with the same variables in the same order, filling in a coefficient of 0 where a variable is missing.
Build A from the coefficients. Each row of A is one equation's coefficients, in variable order.
Build X and B. X is the column of variables; B is the column of the right-hand-side constants.
Take the system 3x - 2y = 7 and x + 5y = -4. Lined up, the coefficients are (3, -2) and (1, 5), so
A = [ \begin{bmatrix} 3 & -2 \ 1 & 5 \end{bmatrix} ], X = [ \begin{bmatrix} x \ y \end{bmatrix} ], B = [ \begin{bmatrix} 7 \ -4 \end{bmatrix} ].
The missing-variable rule matters. If one equation reads 2x = 6 in a two-variable system, its row is (2, 0), not (2) — the zero holds the place of y.
How to Solve a Matrix Equation
The standard route is the inverse matrix method. Just as you solve 3x = 12 by multiplying both sides by ( \frac{1}{3} ), you solve AX = B by multiplying both sides on the left by A^{-1}:
AX = B
A^{-1}AX = A^{-1}B
IX = A^{-1}B
X = A^{-1}B
Here I is the identity matrix, which leaves X unchanged, so the solution is
[ X = A^{-1}B ].
The whole method rests on A having an inverse. The inverse of a matrix exists only when its determinant is non-zero. So before solving, check det A.
Variable glossary: A is the coefficient matrix; X is the column of unknowns; B is the column of constants; A^{-1} is the inverse of A; I is the identity matrix; det A is the determinant of A.
When Does a Matrix Equation Have a Solution?
The determinant decides everything.
- det A ≠ 0: The inverse exists, and the equation has exactly one solution, X = A^{-1}B.
- det A = 0 (singular A): The inverse does not exist, and the system has either no solution or infinitely many — never exactly one. Which case you are in depends on whether B is consistent with the rows of A.
This is why the determinant check is not optional bookkeeping. It is the test for whether the inverse method can even run.
Examples of Matrix Equation
Example 1
Write the system x + 2y = 4, 3x - y = 5 as a matrix equation.
[ \begin{bmatrix} 1 & 2 \ 3 & -1 \end{bmatrix} \begin{bmatrix} x \ y \end{bmatrix} = \begin{bmatrix} 4 \ 5 \end{bmatrix} ]
Example 2
Solve [ \begin{bmatrix} 2 & 1 \ 1 & 3 \end{bmatrix} \begin{bmatrix} x \ y \end{bmatrix} = \begin{bmatrix} 5 \ 10 \end{bmatrix} ].**
First, det A = (2)(3) - (1)(1) = 5 ≠ 0, so the inverse exists. For a 2×2 matrix, the inverse is ( \frac{1}{det A} \begin{bmatrix} d & -b \ -c & a \end{bmatrix} ):
A^{-1} = ( \frac{1}{5} \begin{bmatrix} 3 & -1 \ -1 & 2 \end{bmatrix} )
Now X = A^{-1}B:
X = ( \frac{1}{5} \begin{bmatrix} 3 & -1 \ -1 & 2 \end{bmatrix} \begin{bmatrix} 5 \ 10 \end{bmatrix} = \frac{1}{5} \begin{bmatrix} 15 - 10 \ -5 + 20 \end{bmatrix} = \frac{1}{5} \begin{bmatrix} 5 \ 15 \end{bmatrix} = \begin{bmatrix} 1 \ 3 \end{bmatrix} )
Final answer: x = 1, y = 3.
Example 3
Solve AX = B where A = [ \begin{bmatrix} 1 & 2 \ 2 & 4 \end{bmatrix} ] and B = [ \begin{bmatrix} 3 \ 7 \end{bmatrix} ].
Check the determinant first: det A = (1)(4) - (2)(2) = 0. The matrix is singular, so the inverse does not exist — the method cannot run here.
Read the equations: x + 2y = 3 and 2x + 4y = 7. The second is twice the first but does not yield a consistent result. Final answer: no solution (the system is inconsistent).
Example 4
A right-hand side that flips the verdict: solve [ \begin{bmatrix} 1 & 2 \ 2 & 4 \end{bmatrix} \begin{bmatrix} x \ y \end{bmatrix} = \begin{bmatrix} 3 \ 6 \end{bmatrix} ].**
The equations give the same line with infinitely many solutions, all points on x + 2y = 3.
Example 5
Solve the 3x3 system x + y + z = 6, 2y + 5z = -4, 2x + 5y - z = 27 given det A = -21. A = [ \begin{bmatrix} 1 & 1 & 1 \ 0 & 2 & 5 \ 2 & 5 & -1 \end{bmatrix} ], B = [ \begin{bmatrix} 6 \ -4 \ 27 \end{bmatrix} ].
Since det A = -21 ≠ 0, a unique solution exists. Solving gives:
x = 5, y = 3, z = -2.
Example 6
Find the unknown matrix X in [ \begin{bmatrix} 1 & 0 \ 0 & 2 \end{bmatrix} X = \begin{bmatrix} 4 \ 6 \end{bmatrix} ].**
X = [ \begin{bmatrix} 1 & 0 \ 0 & \frac{1}{2} \end{bmatrix} \begin{bmatrix} 4 \ 6 \end{bmatrix} = \begin{bmatrix} 4 \ 3 \end{bmatrix} )
Final answer: X = [ \begin{bmatrix} 4 \ 3 \end{bmatrix} ], i.e. x = 4, y = 3.
Why Matrix Equations Matter — "one rule for any system"
Long before computers, people had systems of equations to solve in surveying, astronomy, and trade, and they solved them by repetitive substitution. The breakthrough was realising that the structure of every linear system is the same — coefficients times unknowns equals constants — so a single notation and method could handle all of them. That is what AX = B delivers.
Engineering. Circuit analysis, structural load balancing, and control systems all reduce to large AX = B systems solved by computer.
Computer graphics and physics simulation. Lighting, fluid flow, and rigid-body dynamics are systems of linear equations solved by computers regularly.
Economics and data science. Linear regression is solved as a matrix equation, as are equilibrium and optimisation models.
Common Errors When Working With Matrix Equations
Mistake 1: Solving without checking the determinant
Where it slips in: Jumping straight to X = A^{-1}B.
Don't do this: Computing the inverse before confirming A is invertible. If det A = 0, the inverse formula divides by zero, and the method fails.
Mistake 2: Multiplying on the wrong side
Where it slips in: Applying A^{-1} to solve AX = B.
Don't do this: Writing X = BA^{-1}. Matrix multiplication is not commutative, so the side matters.
Mistake 3: Dropping a zero coefficient when building A
Where it slips in: A system where one equation is missing a variable.
Don't do this: Writing a short row that skips the missing variable, which misaligns the columns of A.
Bottom Line
- A matrix equation writes a linear system compactly as AX = B, with A as the coefficients, X as the unknowns, and B as the constants.
- When A is invertible, the solution is X = A^{-1}B.
- A unique solution exists when det A ≠ 0; a singular A means no or infinitely many solutions.
- The most common mistake is solving without checking the determinant.
Practice Questions on Matrix Equation
- Rewrite the system 4x - y = 3, 2x + 3y = 11 as a matrix equation AX = B.
- Solve the system from Question 1 using the inverse method.
- Without fully solving, decide whether [ \begin{bmatrix} 1 & 3 \ 2 & 6 \end{bmatrix} X = \begin{bmatrix} 2 \ 5 \end{bmatrix} ] has a solution.
- Solve [ \begin{bmatrix} 1 & 1 \ 1 & -1 \end{bmatrix} \begin{bmatrix} x \ y \end{bmatrix} = \begin{bmatrix} 6 \ 2 \end{bmatrix} ].