# Solution of a system with 3 variables

$$\begin{array}{rcrcrcr} x & - & 2y & + & 3z & = & 7 \\\ 2x & + & y & + & z & = & 4 \\\ -3 x & + & 2y &- &2z & = & -10 \end{array}$$

I have no idea how to do this and my math book is just telling me to do it, and explains nothing. I have a problem containing 3 equations with 3 variables. What do I do? I tried to solve for x and y and then find z but that didn't work and I got the wrong answer. What do I do? My book tells me to "Multiply each side of equation by -1 and add the result to equation 2, also add equations 2 and 3" I have no idea what this means or why they do it, it is never explained in this book anywhere and they seem like completely arbirtrary number not dependent upon anything, like the author is doing it for fun.

-
It may be helpful if you include the actual system of equations you are working with. – yunone Apr 16 '11 at 19:59
Maybe it would be a good idea to post the problem you're talking about and show what you did, because like that one can't do much more than point you to Wikipedia. (ah, @yunone you beat me by 17 seconds!) – t.b. Apr 16 '11 at 19:59
Do you know how to solve 2 equations with 2 variables? – Graphth Apr 16 '11 at 20:00
Yes, I know how to do 2 variables, but with 3 the book is telling me to multiply by the coefficients on one variable to solve for the others or something very strange, and then add them. I have no idea, it doesn't explain at all. x-2y+3z = 7 2x+y+z = 4 -3x+2y-2z = -10 I got z= -1 but that isn't right. – Adam Apr 16 '11 at 20:01
@Theo, whoops, didn't mean to snipe your comment there! – yunone Apr 16 '11 at 20:03

An organizational trick I wish I had learned sooner is to represent your system as a matrix, and then solve accordingly. Your system is given by $$\begin{bmatrix} 1 & -2 & 3 & 7\\ 2 & 1 & 1 & 4\\ -3 & 2 & -2 & -10\\ \end{bmatrix}$$ Notice this the entries of the matrix are just the coefficients of $x,y,z$ and the sum of the equation in each row. Let's say you want to solve for $z$ by eliminating $x$ and $y$ from the third equation. Start by substracting twice the first equation from the second, and adding three times the first equation to the third to clear the $x$ from the first and second equations. That is, $$(2x+y+z)-2(x-2y+3z)=5y-5z=4-2(7)=-10$$ and $$3(x-2y+3z)+(-3x+2y-2z)=3(7)+(-10)=11.$$ So the trick is to find some multiple of the leading coefficient to add or subtract from another to get a $0$ coefficient for $x$. This gives in the matrix $$\begin{bmatrix} 1 & -2 & 3 & 7\\ 0 & 5 & -5 & -10\\ 0 & -4 & 7 & 11\\ \end{bmatrix}$$

Immediately you have your last two equations as a system in terms of only $y$ and $z$, namely $5y-5z=-10$ and $-4y+7z=11$, which you should be able to solve normally. Continuing in the manner above...

Since $2x+y+z-2(x-2y+3z)=5y-5z=4-2(7)=-10$, and similarly for the third row. Notice also that the second row now gives the equation $5y-5z=-10$, which is equivalent to $y-z=-2$. Simplifying the matrix gives

$$\begin{bmatrix} 1 & -2 & 3 & 7\\ 0 & 1 & -1 & -2\\ 0 & -4 & 7 & 11\\ \end{bmatrix}$$

This nice thing about having $x$ cleared from the second equations means you can now clear $y$ from the third equations by manipulating the second equation, without having to worry about introducing a new $x$. So adding 4 times the second equation to the third, that is, $4(y-z)+(-4y+7z)=4(-2)+11=3$, gives a new matrix $$\begin{bmatrix} 1 & -2 & 3 & 7\\ 0 & 1 & -1 & -2\\ 0 & 0 & 3 & 3\\ \end{bmatrix}$$

But this last row gives the equation $3z=3$, or $z=1$. Immediately from $y-z=-2$, you see $y=-2+z=-1$. You can then solve for $x$. This is a nice algorithm for solving a system of linear equations of reasonable size.

-
"Start by substracting twice the first equation from the second, and adding three times the first equation to the third to clear the x from the first and second equations. " Why would I want to do that and what does it achieve? Where do these number originate from and why have you chose that order? – Adam Apr 16 '11 at 20:44
@Adam You want to get rid of $x$ in your second equation and third equations. You have 2 xs in your second equation, and only 1 x in your first. So multiplying the first equation by 2 gives you 2xs, and then upon subtracting, the xs cancel, and you're left with a new equation in only y and z. Likewise for the third equation, you have -3 xs in the third equation, so multiplying the first equation by 3 gives you three xs, and upon adding, the xs cancel. This gives you two new second and third equations, which are a system in only two variables y and z which you know how to solve. – yunone Apr 16 '11 at 20:47
You can add and subtract multiples of one equation to and from another without changing the solution of your system. – yunone Apr 16 '11 at 20:48
This isn't substitution thought is it? That is the only way I know how to do these. – Adam Apr 16 '11 at 20:51
When you get to systems larger than 2 variables, it is best to clear some variables to get a smaller system, and you can solve that with substitution. The result is still the same. – yunone Apr 16 '11 at 20:53

I assume you know how to solve a system of two linear equations such as

$$\left\{ \begin{array}{c} -5x-5y=-5 \\ x+4y=-2% \end{array}% \right.\qquad(\ast)$$

but not how to represent it in terms of a matrix. I start with your system of 3 equations

$$\left\{ \begin{array}{c} x-2y+3z=7 \\ 2x+y+z=4 \\ -3x+2y-2z=-10.% \end{array}% \begin{array}{c} \text{(eq. 1)} \\ \text{(eq. 2)} \\ \text{(eq. 3)}% \end{array}% \right.\qquad(\ast\ast)$$

In order to eliminate one of the variables $x,y,z$ you can replace one of the 3 equations as follows. Multiply another equation by an adequate multiplier and add the result termwise to it. Suppose you want to eliminate $z$. If you multiply eq. 2 by $2$ you obtain the equivalent equation

$$4x+2y+2z=8.$$

Now add it to eq. 3 to get the equation

$$\left( 4-3\right) x+\left( 2+2\right) y+\left( 2-2\right) z=8-10\Leftrightarrow x+4y=-2,$$

which means you did eliminate the variable $z$. The multiplier $m=2$ was chosen so that $1$ (coeff. of $z$ in eq. 2) $\times m-2$ (coeff.of $z$ in eq.3)$=0$, i.e. $m=2$. Thus you can replace your system by the equivalent one

$$\left\{ \begin{array}{c} x-2y+3z=7 \\ 2x+y+z=4 \\ x+4y=-2% \end{array}% \begin{array}{c} \text{(eq. 1)} \\ \text{(eq. 2)} \\ \text{(new eq. 3)}% \end{array}% \right.$$

Similarly you get

$$\left\{ \begin{array}{c} \left( 1-6\right) x-\left( 2+3\right) y+\left( 3-3\right) z=7-12 \\ 2x+y+z=4 \\ x+4y=-2% \end{array}% \begin{array}{c} \text{(new eq. 1)} \\ \text{(eq. 2)} \\ \text{(new eq. 3)}% \end{array}% \right.$$

by multiplying eq. 2 by the multiplier $m=-3$ (so that $1\times c+3=0$, as above) and adding it to eq.1, which simplifies to

$$\left\{ \begin{array}{c} -5x-5y=-5 \\ 2x+y+z=4 \\ x+4y=-2% \end{array}% \begin{array}{c} \text{(new eq. 1)} \\ \text{(eq. 2)} \\ \text{(new eq. 3)}% \end{array}% \right.$$

From these new eqs. 1 and 3, you can compute $x$ and $y$ (the initial system $(\ast)$ of 2 eqs. can be solved by this method too. Do you see how?). Inserting them in eq. 2 we obtain $z=4-2x-y$.

-

If you know how to solve two equations in two unknowns, here is how I'd approach it without have to figure out any weird or tricky substitutions.

Multiply the first equation by $-2$ and add it to the second. The point is to eliminate the $x$ term in the equation. Now you have

$x-2y+3z=7$

$5y-5z=-10$

$-3x+2y-2z=-10$

Now do the same thing with the third equation. Multiply the first by 3 and add to the third to get

$x-2y+3z=7$

$5y-5z=-10$

$-4y+7z=11$

Now the last two equations are a system of two equations and two unknowns. Solve those like you normally do, and you get $y=$ something and $z=$ something. You can now plug those into the first equation to solve for $x$, and you get the solution.

-

What we would like to do is to transform $$\begin{array}{rcrcrcr} x & - & 2y & + & 3z & = & 7 \\\ 2x & + & y & + & z & = & 4 \\\ -3 x & + & 2y &- &2z & = & -10 \end{array}$$

into something of this form. $$\begin{array}{rcrcrcr} x & & & & & = & 3 \\\ & & y & & & = & 12 \\\ & & & &z & = & 21 \end{array}$$

I find it easier by labeling equations as E1, E2, E3, etc..

Our starting point is this$\dots$ $$\begin{array}{rrcrcrcr} (E1)& x & - & 2y & + & 3z & = & 7 \\\ (E2) & 2x & + & y & + & z & = & 4 \\\ (E3) & -3 x & + & 2y &- &2z & = & -10 \end{array}$$ as I solve the systems of equations, move towards a solution, the system of equations will go through several generations. My first goal is to eliminate the $z$ from (E1) and (E2). We do this by using (E3) as a pivot row, as follows

$$\begin{array}{r} 2(E1) + 3(E3) \\\ 2(E2)+(E3) \\\ (E3) \end{array}$$ Notice that (E3) is used in calculating the 2nd generation of all 3 rows. Performing these operations gives us $$\begin{array}{rrcrcrcr} (E1)& -7x & + & 2y & & & = & -16 \\\ (E2) & x & + & 4y & & & = & -2 \\\ (E3) & -3 x & + & 2y &- &2z & = & -10 \end{array}$$ Next, we want to eliminate the $y$s from (E1) and (E3) by using the new (E2) as the pivot row. The operations we wish to perform to produce the 3rd generation are $$\begin{array}{r} (E2) - 2(E1) \\\ (E2) \\\ (E2)-2(E3) \end{array}$$ giving us

$$\begin{array}{rrcrcrcr} (E1)& 15x & & & & & = & 30 \\\ (E2) & x & + & 4y & & & = & -2 \\\ (E3) & 7 x & & &+ &4z & = & 18 \end{array}$$ Eliminating the $x$s from (E2) and (E3), where use (E1) as the pivot row. $$\begin{array}{r} \frac{1}{15}(E1) \\\ \frac{1}{4}\bigg((E2)-\frac{1}{15}(E1)\bigg) \\\ \frac{1}{4}\bigg((E3)-\frac{7}{15}(E1)\bigg) \end{array}$$ giving us $$\begin{array}{rrcrcrcr} (E1)& x & & & & & = & 2 \\\ (E2) & & & y & & & = & -1 \\\ (E3) & & & & &z & = & 1 \end{array}$$ This method is called Elimination. You can Google Gaussian Elimination with Back-Substitution for a computationally more efficient method.

-