# Solving a System of Linear Equations

Step-by-Step, What is the solution for this system of linear equations?

7x + 2y -5z = -18

x + 5y - 3z = -40

2x -y -9z = -26

The correctly answer is (x = 2, y = -6, z = 4).

-
@AustinMohr I don't know why it didn't display. Sorry! –  Pedro Tamaroff May 28 '12 at 1:17

Well,use Gauss-Jordan...(use fractions ,if you think it´s better)

1. Divide row 1 by 7
2. Subtract row 1 from row 2
3. Subtract (2 × row 1) from row 3

4. Divide row 2 by 4.714

5. Subtract (-1.571 × row 2) from row 3
6. Divide row 3 by -8.333
7. Subtract (-0.714 × row 3) from row 1
8. Subtract (-0.485 × row 3) from row 2
9. Subtract (0.286 × row 2) from row

Ten you will get in your matrix,that in this point is in a reduced row echelon form,the answer you already had:first line is (1 0 0 2),second line(0 1 0 -6), third line (0 0 1 4).The one´s correnspond to x , y and z.

-
It usually best to write those decimals as fractions. Else, the results are wrong. –  Pedro Tamaroff May 28 '12 at 22:33
Also, on this site, it helps if you use LaTex. Just an fyi, so you can get a better result when you given an answer. –  yiyi Sep 21 '12 at 2:34
I answered this one when I created the account,so I didn't know Latex very well.I know better now,way better.Thanks! –  Charlie Sep 21 '12 at 15:13

Without resorting to matrices as Austin does in his answer, you can first multiply the last equation ($2x-y-9z=-26$) by an appropriate constant so that when you add it to the first equation ($7x+2y-5z=-18$), the $y$ variable is canceled. Repeat the process but this time add the last equation to the second equation ($x+5y-3z=-40$). Now you're left with 2 equations in two variables. Use this same process to multiply one of the equations by a constant so that when you add then two together, you eliminate the $x$ variable. Finally you have a single linear equation to solve for $z$. Once you have a value for $z$, plug that into your original equations and look for a way to multiply one equation by a constant to make a variable disappear.

I do recommend using matrices over this method. This takes longer, looks messier,and the process isn't as algorithmic as using Gaussian elimination.

EDIT I thought it might be useful to show you how to set this up using Gaussian elimination. At each step the indicated operation will use $R_1$ for row 1, $R_2$ for row 2, and $R_3$ for row 3. $$\begin{bmatrix} 1&5&-3&-40\\2&-1&-9&-26\\7&2&-5&-18 \end{bmatrix} \xrightarrow{-2R_1+R_2} \begin{bmatrix} 1&5&-3&-40\\0&-11&-3&54\\7&2&-5&-18 \end{bmatrix} \xrightarrow{-7R_1+R_3} \begin{bmatrix} 1&5&-3&-40\\0&-11&-3&54\\0&-33&16&262 \end{bmatrix} \xrightarrow{-3R_2+R_3} \begin{bmatrix} 1&5&-3&-40\\0&-11&-3&54\\0&0&25&100 \end{bmatrix} \xrightarrow{\frac{1}{25}R_3} \begin{bmatrix} 1&5&-3&-40\\0&-11&-3&54\\0&0&1&4 \end{bmatrix} \xrightarrow{\text{skipping steps}} \begin{bmatrix} 1&0&0&2\\0&1&0&-2\\0&0&1&4 \end{bmatrix}$$

-

One way is to write a corresponding matrix equation. Let $$A = \left[ \begin{array}{ccc} 7 & 2 & -5\\ 1 &5 & -3\\ 2 & -1 & -9 \end{array} \right],$$ $$X = \left[ \begin{array}{c} x\\ y\\ z \end{array} \right],$$ and $$B = \left[ \begin{array}{c} -18\\ -40\\ -26 \end{array} \right].$$ You should convince yourself that the system of linear equations is exactly the same as the matrix equation $$AX = B.$$ Multiplying both sides on the left by $A^{-1}$ (matrix multiplication does not commute) gives $$A^{-1}AX = A^{-1}B$$ which simplifies to $$X = A^{-1}B.$$ You can use a calculator to evaluate this last line.

Note $A^{-1}$ may not always exist (you will know this is the case if your calculator gives a message like "singular matrix"). In this situation, you have either an inconsistent system (no solutions) or a dependent system (infinitely-many solutions). To handle these kinds of systems, you should resort to Gauss-Jordan elimination.

-

We tag the equations for convenience:

$$\tag 1 7x + 2y -5z = -18$$

$$\tag 2 x + 5y - 3z = -40$$

$$\tag 3 2x -y -9z = -26$$

We first perform $(1)-7\times(2)$ which gives

$$\tag 4-33y+16z=262$$

Now we perform $2\times(1)-7\times (3)$, which gives

$$\tag 5 11 y+ {53} z=146$$

Now we make $11\times(4)+33\times (5)$, which gives

$$1925z=7700$$

so $z=7700/1925=4$. And now it's just a "chain reaction".

Note we chose the constants so that the first term cancelled out. This method is called Gaussian elimination, or Gauss-Jordan method.

-