• Home
  • /
  • Blog
  • /
  • How to Solve Linear Equations with Matrices(With Method & Examples)

How to Solve Linear Equations with Matrices(With Method & Examples)

how to solve linear equations with matrices

In mathematics, a matrix is an array of numbers arranged in a rectangular pattern and separated into rows and columns. One of the uses of matrices is to solve linear equations. The concept inverse of a matrix along with other operations on a matrix is used to solve a system of $n$ linear equations in $n$ variables.

Let’s understand how to solve linear equations with matrices with methods and examples.

How to Solve Linear Equations with Matrices

In this method, the values of the variables in the system of equations are calculated by multiplying the inverse of a matrix with the matrix of values on the right-hand side. 

If we have a system of equations in $n$ variables $x_1$, $x_2$, $x_3$, …, $x_n$ represented as

$a_{11} x_1 + a_{12} x_2 + a_{13} x_3 + … + a_{1n} x_n = c_1$

$a_{21} x_1 + a_{22} x_2 + a_{23} x_3 + … + a_{2n} x_n = c_2$

$a_{31} x_1 + a_{32} x_2 + a_{33} x_3 + … + a_{3n} x_n = c_3$

…………………………………………………………………………

$a_{n1} x_1 + a_{n2} x_2 + a_{n3} x_3 + … + a_{nn} x_n = c_n$

The steps followed to solve the above system of linear equations are

  • All the variables in the equations should be written in the appropriate order.
  • The variables, their coefficients, and constants are to be written on the respective sides.

Solving a system of linear equations by the method of finding the inverse consists of two new matrices namely

  • Matrix A: which represents the variables
  • Matrix B: which represents the constants

After that, a system of equations is solved using matrix multiplication, by writing the above equations in the matrix form as shown below:

$\begin{bmatrix} a_{11} x_1 + a_{12} x_2 + a_{13} x_3 + … + a_{1n} x_n \\  a_{21} x_1 + a_{22} x_2 + a_{23} x_3 + … + a_{2n} x_n  \\ a_{31} x_1 + a_{32} x_2 + a_{33} x_3 + … + a_{3n} x_n \\ ………………………………. \\ a_{n1} x_1 + a_{n2} x_2 + a_{n3} x_3 + … + a_{nn} x_n \end{bmatrix} = \begin{bmatrix}  c_1 \\ c_2 \\ c_3 \\ … \\ c_n \end{bmatrix}$

$=> \begin{bmatrix}  a_{11} & a_{12} & a_{13} & … & a_{1n}  \\ a_{21} & a_{22} & a_{23} & … & a_{2n}  \\ a_{31} & a_{32} & a_{33} & … & a_{3n}  \\ … & … & … & … & … \\ a_{n1} & a_{n2} & a_{n3} & … & a_{nn} \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ x_3 \\ …  \\ x_n  \end{bmatrix} = \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\ …  \\ c_n  \end{bmatrix} $

$=> \text{AX} = \text{B}$ —————————— (1)

where, $\text{A} = \begin{bmatrix}  a_{11} & a_{12} & a_{13} & … & a_{1n}  \\ a_{21} & a_{22} & a_{23} & … & a_{2n}  \\ a_{31} & a_{32} & a_{33} & … & a_{3n}  \\ … & … & … & … & … \\ a_{n1} & a_{n2} & a_{n3} & … & a_{nn} \end{bmatrix}$

$\text{X} = \begin{bmatrix} x_1 \\ x_2 \\ x_3 \\ …  \\ x_n  \end{bmatrix}$

$\text{B} = \begin{bmatrix} c_1 \\ c_2 \\ c_3 \\ …  \\ c_n  \end{bmatrix}$

$\text{A}$ is the coefficient matrix, $\text{X}$ the variable matrix and $\text{B}$ the constant matrix.

Multiplying (1) by $\text{A}^{-1}$ we get 

$\text{A}^{-1} \text{A} \text{X} = \text{A}^{-1} \text{B}$

$=> \text{I}. \text{X} = \text{A}^{-1} \text{B}$

$=> \text{X} = \text{A}^{-1} \text{B}$

Condition for Consistency of a System of Linear Equations

The condition for consistency of a system of linear equation $\text{AX} = \text{B}$ is

  • If $|\text{A}| \ne 0$, then the system is consistent and has a unique solution, given by $\text{X} = \text{A}^{-1} \text{B}$
  • If $| \text{A}| = 0$, and $( \text{Adj A}) \text{B} \ne 0$ then the system is inconsistent
  • If $| \text{A}| = 0$, and $( \text{Adj A}) \text{B} = 0$, then the system is consistent and has infinitely many solutions.

Note: 

  • $\text{AX} = 0$ is known as a homogeneous system of linear equations, here $\text{B} = 0$. A system of homogeneous equations is always consistent.
  • The system has a non-trivial solution (non-zero solution), if $| \text{A} | = 0$

Examples on How to Solve Linear Equations with Matrices

Example 1: Solve a pair of linear equations $3x – 4y = 6$ and $2x – 3y = 6$

The given pair of equations is

$3x – 4y = 6$ ———————————– (1)

$2x – 3y = 6$ ———————————– (2)

Rewriting the equations in the form of matrices, we get

$\begin{bmatrix} 3 & -4\\ 2 & -3 \end{bmatrix} \begin{bmatrix} x\\ y \end{bmatrix} = \begin{bmatrix} 6\\ 6 \end{bmatrix}$, which is of the form $\text{AX} = \text{B}$, where

  • $\text{A} = \begin{bmatrix} 3 & -4\\ 2 & -3 \end{bmatrix}$
  • $\text{X} = \begin{bmatrix} x\\ y \end{bmatrix}$
  • $\text{B} = \begin{bmatrix} 6\\ 6 \end{bmatrix}$

The steps to be followed are 

Multiply the above equation by $\text{A}^{-1}$ to get 

$\text{A}^{-1} \text{A} \text{X} = \text{A}^{-1} \text{B}$

$=> \text{I}. \text{X} = \text{A}^{-1} \text{B}$

$=> \text{X} = \text{A}^{-1} \text{B}$

$\text{A}^{-1}$ is calculated using the formula $\text{A}^{-1} = \frac{\text{Adj }(\text{A})}{|\text{A}|}$

$|\text{A}| = \begin{vmatrix} 3 & -4\\ 2 & -3 \end{vmatrix} = 3 \times (-3) – (-4) \times 2 = -9 + 8 = -1$

Since, $|\text{A}| \ne 0$, therefore given system of equations has a unique solution.

Now, to find $\text{A}^{-1}$, we will find adjoint, which is calculated by taking the transpose of the cofactors matrix and cofactors matrix is obtained from the minors of matrix $\text{A}$.

Minors of $\text{A} = \begin{bmatrix} 3 & -4\\ 2 & -3 \end{bmatrix}$ are

$\text{M}_{1, 1} = -3$

$\text{M}_{1, 2} = 2$

$\text{M}_{2, 1} = -4$

$\text{M}_{2, 2} = 3$

Cofactors of matrix $\text{A}$ are

$\text{C}_{1, 1} = (-1)^{1 + 1} \text{M}_{1, 1} = 1 \times (-3) = -3$

$\text{C}_{1, 2} = (-1)^{1 + 2} \text{M}_{1, 2} = -1 \times 2 = -2$

$\text{C}_{2, 1} = (-1)^{2 + 1} \text{M}_{2, 1} = -1 \times (-4) = 4$

$\text{C}_{2, 2} = (-1)^{2 + 1} \text{M}_{2, 2} = 1 \times 3 = 3$

Cofactors matrix = $\begin{bmatrix} -3 & -2\\ 4 & 3 \end{bmatrix}$

Therefore, $\text{Adj}(\text{A}) = \begin{bmatrix} -3 & 4\\ -2 & 3 \end{bmatrix}$

$=> \text{A}^{-1} = \frac{\text{Adj}(\text{A})}{|\text{A}|} = \frac{1}{-1} \begin{bmatrix} -3 & 4\\ -2 & 3 \end{bmatrix} = \begin{bmatrix} 3 & -4\\ 2 & -3 \end{bmatrix}$

Therefore, $\begin{bmatrix} x\\ y \end{bmatrix} = \begin{bmatrix} 3 & -4\\ 2 & -3 \end{bmatrix} \begin{bmatrix} 6\\ 6 \end{bmatrix}$

$=> \begin{bmatrix} x\\ y \end{bmatrix} = \begin{bmatrix} 3 \times 6 – 4 \times 6\\ 2 \times 6 – 3 \times 6 \end{bmatrix} = \begin{bmatrix} -6 \\ -6 \end{bmatrix}$

The solution of pair of linear equations $3x – 4y = 6$ and $2x – 3y = 6$ is $x = -6$ and $y = -6$

Example 2: Solve a pair of linear equations $2x – 5y = 9$ and $-6x + 15y = 11$

The given pair of equations is

$2x – 5y = 9$ ———————————– (1)

$-6x + 15y = 11$ ———————————– (2)

Rewriting the equations in the form of matrices, we get

$\begin{bmatrix} 2 & -5\\ -6 & 15 \end{bmatrix} \begin{bmatrix} x\\ y \end{bmatrix} = \begin{bmatrix} 9\\ 11 \end{bmatrix}$, which is of the form $\text{AX} = \text{B}$, where

  • $\text{A} = \begin{bmatrix} 2 & -5\\ -6 & 15 \end{bmatrix}$
  • $\text{X} = \begin{bmatrix} x\\ y \end{bmatrix}$
  • $\text{B} = \begin{bmatrix} 9\\ 11 \end{bmatrix}$

The steps to be followed are 

Multiply the above equation by $\text{A}^{-1}$ to get 

$\text{A}^{-1} \text{A} \text{X} = \text{A}^{-1} \text{B}$

$=> \text{I}. \text{X} = \text{A}^{-1} \text{B}$

$=> \text{X} = \text{A}^{-1} \text{B}$

$\text{A}^{-1}$ is calculated using the formula $\text{A}^{-1} = \frac{\text{Adj }(\text{A})}{|\text{A}|}$

$|\text{A}| = \begin{vmatrix} 2 & -5\\ -6 & 15 \end{vmatrix} = 2 \times 15 – (-5) \times (-6) = 30 – 30 = 0$

Since, $|\text{A}| = 0$, therefore given system of equations does not have any solution, i.e., the system of equations is inconsistent.

Example 3: Solve a system of linear equations 

The given system of equations is

$x – y + z = 2$ ———————————– (1)

$-2x + y + z = 6$ ———————————– (2)

$2x + 2y + z = -3$ ———————————– (3)

Rewriting the equations in the form of matrices, we get

$\begin{bmatrix} 1 & -1 & 1 \\ -2 & 1 & 1 \\ 2 & 2 & 1 \end{bmatrix} \begin{bmatrix} x\\ y \\ z\end{bmatrix} = \begin{bmatrix} 2\\ 6 \\ -3 \end{bmatrix}$, which is of the form $\text{AX} = \text{B}$, where

  • $\text{A} = \begin{bmatrix} 1 & -1 & 1 \\ -2 & 1 & 1 \\ 2 & 2 & 1 \end{bmatrix}$
  • $\text{X} = \begin{bmatrix} x\\ y \\ z \end{bmatrix}$
  • $\text{B} = \begin{bmatrix} 2\\ 6 \\ -3 \end{bmatrix}$

The steps to be followed are 

Multiply the above equation by $\text{A}^{-1}$ to get 

$\text{A}^{-1} \text{A} \text{X} = \text{A}^{-1} \text{B}$

$=> \text{I}. \text{X} = \text{A}^{-1} \text{B}$

$=> \text{X} = \text{A}^{-1} \text{B}$

$\text{A}^{-1}$ is calculated using the formula $\text{A}^{-1} = \frac{\text{Adj }(\text{A})}{|\text{A}|}$

$|\text{A}| = \begin{vmatrix} 1 & -1 & 1\\ -2 & 1 & 1 \\ 2 & 2 & 1\end{vmatrix} = 1 \times (1 \times 1 – 1 \times 2) – (-1) \times (-2 \times 1 – 1 \times 2) + 1 \times (-2 \times 2 – 1 \times 2)$

$ = 1 \times (1 – 2) + 1 \times (-2 – 2) + 1 \times (-4 – 2) = 1 \times (-1) + 1 \times (-4) + 1 \times (-6)$

$ = -1 – 4 – 6 = -11$

Since, $|\text{A}| \ne 0$, therefore given system of equations has a unique solution.

Now, to find $\text{A}^{-1}$, we will find adjoint, which is calculated by taking the transpose of the cofactors matrix and cofactors matrix is obtained from the minors of matrix $\text{A}$.

Minors of $\text{A} = \begin{bmatrix} 1 & -1 & 1\\ -2 & 1 & 1 \\ 2 & 2 & 1\end{bmatrix}$ are

$\text{M}_{1, 1} = \begin{bmatrix} 1 & 1\\ 2 & 1 \end{bmatrix} = 1 \times 1 – 1 \times 2 = 1 – 2 = -1 $

$\text{M}_{1, 2} = \begin{bmatrix} -2 & 1\\ 2 & 1 \end{bmatrix} = -2 \times 1 – 1 \times 2 = -2 – 2 = -4$

$\text{M}_{1, 3} = \begin{bmatrix} -2 & 1\\ 2 & 2 \end{bmatrix} = -2 \times 2 – 1 \times 2 = -4 – 2 = -6$

$\text{M}_{2, 1} = \begin{bmatrix} -1 & 1\\ 2 & 1 \end{bmatrix} = -1 \times 1 – 1 \times 2 = -1 – 2 = -3$

$\text{M}_{2, 2} = \begin{bmatrix} 1 & 1\\ 2 & 1 \end{bmatrix} = 1 \times 1 – 1 \times 2 = 1 – 2 = -1$

$\text{M}_{2, 3} = \begin{bmatrix} 1 & -1\\ 2 & 2 \end{bmatrix} = 1 \times 2 – (-1) \times 2 = 2 + 2 = 4$

$\text{M}_{3, 1} = \begin{bmatrix} -1 & 1\\ 1 & 1 \end{bmatrix} = -1 \times 1 – 1 \times 1 =  -1 – 1 = -2$

$\text{M}_{3, 2} = \begin{bmatrix} 1 & 1\\ -2 & 1 \end{bmatrix} = 1 \times 1 – 1 \times (-2) = 1 + 2 = 3$

$\text{M}_{3, 3} = \begin{bmatrix} 1 & -1\\ -2 & 1 \end{bmatrix} = 1 \times 1 – (-1) \times (-2) = 1 – 2 = -1$

Cofactors of matrix $\text{A}$ are

$\text{C}_{1, 1} = (-1)^{1 + 1} \text{M}_{1, 1} = 1 \times (-1) = -1$

$\text{C}_{1, 2} = (-1)^{1 + 2} \text{M}_{1, 2} = -1 \times (-4) = 4$

$\text{C}_{1, 3} = (-1)^{1 + 3} \text{M}_{1, 3} = 1 \times (-6) = -6$

$\text{C}_{2, 1} = (-1)^{2 + 1} \text{M}_{2, 1} = -1 \times (-3) = 3$

$\text{C}_{2, 2} = (-1)^{2 + 2} \text{M}_{2, 2} = 1 \times (-1) = -1$

$\text{C}_{2, 3} = (-1)^{2 + 3} \text{M}_{2, 3} = -1 \times 4 = -4$

$\text{C}_{3, 1} = (-1)^{3 + 1} \text{M}_{3, 1} = 1 \times (-2) = -2$

$\text{C}_{3, 2} = (-1)^{3 + 2} \text{M}_{3, 2} = -1 \times 3 = -3$

$\text{C}_{3, 3} = (-1)^{3 + 3} \text{M}_{3, 3} = 1 \times (-1) = -1$

Cofactors matrix = $\begin{bmatrix} -1 & 4 & -6 \\ 3 & -1 & -4 \\ -2 & -3 & -1 \end{bmatrix}$

Therefore, $\text{Adj}(\text{A}) = \begin{bmatrix} -1 & 3 & -2\\ 4 & -1 & -3 \\ -6 & -4 & -1\end{bmatrix}$

$=> \text{A}^{-1} = \frac{\text{Adj}(\text{A})}{|\text{A}|} = \frac{1}{-11} \begin{bmatrix} -1 & 3 & -2\\ 4 & -1 & -3 \\ -6 & -4 & -1 \end{bmatrix} = \frac{1}{11} \begin{bmatrix} 1 & -3 & 2\\ -4 & 1 & 3 \\ 6 & 4 & 1 \end{bmatrix}$

Therefore, $\begin{bmatrix} x\\ y \\ z \end{bmatrix} = \frac{1}{11} \begin{bmatrix} 1 & -3 & 2\\ -4 & 1 & 3 \\ 6 & 4 & 1 \end{bmatrix} \begin{bmatrix} 2\\ 6 \\ -3\end{bmatrix}$

$= \frac{1}{11} \begin{bmatrix} 1 \times 2 – 3 \times 6 + 2 \times (-3) \\ -4 \times 2 + 1 \times 6 + 3 \times (-3) \\ 6 \times 2 + 4 \times 6 + 1 \times (-3) \end{bmatrix} = \frac{1}{11} \begin{bmatrix} 2 – 18 – 6 \\ -8 + 6 – 9 \\ 12 + 24 – 3 \end{bmatrix} = \frac{1}{11} \begin{bmatrix} -22 \\ -11 \\ 33 \end{bmatrix} = \begin{bmatrix} -2 \\ -1 \\ 3 \end{bmatrix}$

Therefore, solution of system of equations $x – y + z = 2$, $-2x + y + z = 6$, and $2x + 2y + z = -3$ is $x = -2$, $y = -1$, and $z = 3$ 

Practice Problems

Solve the following system of equations using the matrix method.

  • $3x + 2y = 8$,  $6x – 4y = 9$
  • $x + 3y = 6$,  $2x – 3y = 12$
  • $141x + 93y = 189$,  $93x + 141y = 45$
  • $x – y + z = 2$, $2x – y – z = -6$, $2x + 2y + z = -3$
  • $3x + y + z = 2$, $x + 2y + z = -3$, $3x + y + 2z = 4$
  • $x – 3y + z = -5$, $-3x – y – z = 1$, $2x – 2y + 3z = 1$

FAQs

What do you mean by a linear equation?

A linear equation is an equation of degree one that has one or more variables.

What do you mean by consistent equations?

A consistent system of equations is a system of equations having one or more solutions.

Give the formula used in the matrix multiplication method for solving linear equations.

The formula used in the matrix multiplication method for solving linear equations is $\text{AX} = \text{B}$, where $\text{A}$ is the coefficient matrix, $\text{X}$ is the variable matrix and $\text{B}$ is the constant matrix.

How do you solve equations using matrices?

You can use matrices to solve linear equations. For this write the matrix on the left as the product of coefficients and variables. Next, multiply each side of the matrix equation by the inverse of a matrix.

What is the formula of matrix equation?

The formula used to find the value of variables using the matrix method is $\text{X} = \text{A}^{-1} \text{B}$, where $\text{X}$ is a variable matrix, $\text{A}$ is a coefficient matrix, and $\text{B}$ is a matrix of constants on the right-hand side of equations.

Conclusion

One of the uses of matrices is to solve linear equations. The concept inverse of a matrix along with other operations on a matrix is used to solve a system of $n$ linear equations in $n$ variables. The formula used to find the value of variables using the matrix method is $\text{X} = \text{A}^{-1} \text{B}$, where $\text{X}$ is a variable matrix, $\text{A}$ is a coefficient matrix, and $\text{B}$ is a matrix of constants on the right-hand side of equations.

Recommended Reading

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>