Solving a System of Equations with Matrices

The idea

A system of linear equations can be written as a single matrix equation AX=BAX = B, where AA holds the coefficients, XX the unknowns, and BB the right-hand sides.

When AA is square and ∣A∣≠0|A| \neq 0, it has an inverse, and multiplying both sides by A−1A^{-1} on the left solves the whole system at once. This is the matrix method:

AX=B  ⇒  X=A−1B,A−1=1∣A∣ adj AAX = B \;\Rightarrow\; X = A^{-1}B, \qquad A^{-1} = \dfrac{1}{|A|}\,\text{adj}\,A

Steps of the matrix method

  1. Write the system as AX=BAX = B, keeping the variables in the same order in every row.
  2. Find ∣A∣|A|. If it is 0, stop and use the consistency test below instead.
  3. Find adj A\text{adj}\,A, the transpose of the matrix of cofactors.
  4. Compute X=1∣A∣(adj A) BX = \dfrac{1}{|A|}(\text{adj}\,A)\,B.
  5. Substitute the answer back into one original equation to check.

Worked example: two variables

Solve 2x+3y=82x + 3y = 8 and x−y=−1x - y = -1 using matrices.

A=[231−1],X=[xy],B=[8−1],∣A∣=(2)(−1)−(3)(1)=−5A = \begin{bmatrix} 2 & 3 \\ 1 & -1 \end{bmatrix}, \quad X = \begin{bmatrix} x \\ y \end{bmatrix}, \quad B = \begin{bmatrix} 8 \\ -1 \end{bmatrix}, \qquad |A| = (2)(-1) - (3)(1) = -5

Solution: For a 2×22 \times 2 matrix the adjoint swaps the diagonal entries and changes the sign of the other two:

X=1−5[−1−3−12][8−1]=1−5[−5−10]=[12]X = \dfrac{1}{-5}\begin{bmatrix} -1 & -3 \\ -1 & 2 \end{bmatrix}\begin{bmatrix} 8 \\ -1 \end{bmatrix} = \dfrac{1}{-5}\begin{bmatrix} -5 \\ -10 \end{bmatrix} = \begin{bmatrix} 1 \\ 2 \end{bmatrix}

So x=1x = 1, y=2y = 2. Check: 2(1)+3(2)=82(1) + 3(2) = 8 and 1−2=−11 - 2 = -1.

Worked example: three variables

Solve the system:

x−y+z=4,x+y+z=2,2x+y−3z=0x - y + z = 4, \qquad x + y + z = 2, \qquad 2x + y - 3z = 0

Solution by the matrix method:

A=[1−1111121−3],∣A∣=1(−3−1)+1(−3−2)+1(1−2)=−10A = \begin{bmatrix} 1 & -1 & 1 \\ 1 & 1 & 1 \\ 2 & 1 & -3 \end{bmatrix}, \qquad |A| = 1(-3 - 1) + 1(-3 - 2) + 1(1 - 2) = -10

The cofactors give the adjoint (each row of adj A\text{adj}\,A is a column of cofactors):

adj A=[−4−2−25−50−1−32]\text{adj}\,A = \begin{bmatrix} -4 & -2 & -2 \\ 5 & -5 & 0 \\ -1 & -3 & 2 \end{bmatrix}X=1−10[−4−2−25−50−1−32][420]=1−10[−2010−10]=[2−11]X = \dfrac{1}{-10}\begin{bmatrix} -4 & -2 & -2 \\ 5 & -5 & 0 \\ -1 & -3 & 2 \end{bmatrix}\begin{bmatrix} 4 \\ 2 \\ 0 \end{bmatrix} = \dfrac{1}{-10}\begin{bmatrix} -20 \\ 10 \\ -10 \end{bmatrix} = \begin{bmatrix} 2 \\ -1 \\ 1 \end{bmatrix}

So x=2x = 2, y=−1y = -1, z=1z = 1.

Checking by elimination: subtracting the first equation from the second eliminates xx and zz at once:

(x+y+z)−(x−y+z)=2−4  ⇒  2y=−2  ⇒  y=−1(x+y+z) - (x-y+z) = 2-4 \;\Rightarrow\; 2y = -2 \;\Rightarrow\; y=-1

Substituting y=−1y=-1 into the second equation gives x+z=3x+z=3. Substituting into the third gives 2x−3z=12x-3z=1. Using x=3−zx=3-z:

2(3−z)−3z=1  ⇒  6−5z=1  ⇒  z=1  ⇒  x=22(3-z)-3z=1 \;\Rightarrow\; 6-5z=1 \;\Rightarrow\; z=1 \;\Rightarrow\; x=2

Both methods agree.

Consistency: one solution, none, or infinitely many

Consistency test for AX = B with a square matrix A
ConditionResult
∣A∣≠0|A| \neq 0Consistent, with exactly one solution X=A−1BX = A^{-1}B
∣A∣=0|A| = 0 and (adj A)B≠O(\text{adj}\,A)B \neq OInconsistent: no solution
∣A∣=0|A| = 0 and (adj A)B=O(\text{adj}\,A)B = ONot decided by this test: infinitely many solutions or none, so check directly

Example: show that x+y=2x + y = 2 and 2x+2y=52x + 2y = 5 has no solution.

Solution: A=[1122]A = \begin{bmatrix} 1 & 1 \\ 2 & 2 \end{bmatrix}, so ∣A∣=2−2=0|A| = 2 - 2 = 0. With adj A=[2−1−21]\text{adj}\,A = \begin{bmatrix} 2 & -1 \\ -2 & 1 \end{bmatrix}:

(adj A)B=[2−1−21][25]=[−11]≠O(\text{adj}\,A)B = \begin{bmatrix} 2 & -1 \\ -2 & 1 \end{bmatrix}\begin{bmatrix} 2 \\ 5 \end{bmatrix} = \begin{bmatrix} -1 \\ 1 \end{bmatrix} \neq O

So the system is inconsistent. Geometrically the two equations are parallel lines. Change the second right-hand side to 4 and (adj A)B(\text{adj}\,A)B becomes OO: the equations are then the same line, with infinitely many solutions.

Common mistakes

  • Multiplying in the wrong order. It's X=A−1BX = A^{-1}B. Matrix multiplication isn't commutative, and BA−1BA^{-1} isn't even defined here.
  • Forgetting to transpose the cofactors. adj A\text{adj}\,A is the transpose of the cofactor matrix. Skipping the transpose gives a wrong inverse whenever AA isn't symmetric.
  • Mixing up variable order. If one equation is written z+x−yz + x - y, rewrite it as x−y+zx - y + z before building AA, or the columns won't line up.
  • Reading (adj A)B=O(\text{adj}\,A)B = O as "infinitely many solutions". With ∣A∣=0|A| = 0 it can also mean no solution. The test only rules a system inconsistent when (adj A)B≠O(\text{adj}\,A)B \neq O.

Where this comes up in exams

The 2025-26 CBSE Class XII syllabus lists the consistency, inconsistency and number of solutions of a system of linear equations, and solving systems in two or three variables using the inverse of a matrix. The JEE Main 2026 syllabus lists the test of consistency and the solution of simultaneous linear equations in two or three variables using matrices, and JEE Advanced 2026 lists solutions of simultaneous linear equations in two or three variables.

Checked against CBSE Mathematics curriculum, Classes XI-XII (2025-26), JEE (Main) 2026 syllabus (NTA) and JEE (Advanced) 2026 syllabus. Syllabi can change from year to year, so confirm with the latest official notification for your exam.

Continue learning

The matrix method only produces a unique solution when the coefficient matrix isn't singular, and checking that comes down to a basic square-matrix property.

From past GATE papers