## Solving a general system of linear equations

We have seen how to solve a system of linear equations when there is only one variable or one equation. We now turn to the general case. The idea is to reduce a larger system down to one variable or one equation. How exactly do we do that? Let us look at the following system over the rational numbers:

\begin{eqnarray} 2x_1 - x_2 & = & 0 \\ -x_1 + x_2 - 2x_3 & = & 4 \\ 3x_1 - 2x_2 + x_3 & = & -2 \end{eqnarray}

Observe that the first equation is equivalent to $$x_1 = \frac{1}{2}x_2$$. If we know the value for $$x_2$$, then we also know the value for $$x_1$$. Hence, every time we see $$x_1$$, we can replace it with $$\frac{1}{2}x_2$$.

Replacing $$x_1$$ in the second and third equations gives \begin{eqnarray} -\frac{1}{2}x_2 + x_2 - 2x_3 & = & 4 \\ \frac{3}{2}x_2 - 2x_2 + x_3 & = & -2 \\ \end{eqnarray}

Simplifying gives \begin{eqnarray} \frac{1}{2}x_2 - 2x_3 & = 4 &~~~~~~\text{(1)} \\ -\frac{1}{2}x_2 + x_3 & = -2 &~~~~~~\text{(2)} \\ \end{eqnarray}

These two equations form a system that involves only $$x_2$$ and $$x_3$$. If we can find all solutions to this system, we can get all solutions to the original system by setting $$x_1$$ to $$\frac{1}{2}x_2$$. Hence, we have effectively reduced the original problem to one that involves one fewer variable and one fewer equation.

We may continue by using $$(1)$$ to write $$x_2$$ in terms of $$x_3$$ and replace $$x_2$$ in $$(2)$$. However, we can take a shortcut as follows: Note that we have the term $$\frac{1}{2}x_2$$ in $$(1)$$ and its negation in $$(2)$$. Rewriting $$(1)$$ gives $$\frac{1}{2}x_2 = 4 + 2x_3$$. Combining this with $$(2)$$ gives $$-(4+2x_3) + x_3 = -2$$, giving $$-x_3 = 2$$. Hence, we must have $$x_3 = -2$$. This implies that $$x_2 = 0$$ which in turn means $$x_1 = 0$$.

(If we hadn't taken the shortcut, we would first rewrite $$(1)$$ as $$x_2 = 8 + 4x_3$$. So we can replace $$x_2$$ in $$(2)$$ with $$8+4x_3$$ to obtain $$-\frac{1}{2}(8+ 4x_3) + x_3 = -2$$. Simplifying this last equation gives $$x_3 = -2$$ as before.)

## Method of substitution

The example above illustrates the method of substitution. The general recipe is as follows: Assume that the system has more than one variable and one equation. Pick one of the equations and rewrite it so that one of the variables is expressed in terms of the rest; i.e. the variable is the only thing that appears on the left-hand side. Call the right-hand side of this equation $$R$$. Then for each of the remaining equations, whenever you see that variable, replace it with $$R$$. After simplifcation, you will have a system with at least one fewer equation and one fewer variable. Repeat the process until you get down to a system for which you can easily find solutions.

## Exercises

1. Find all solutions to the each of the following systems over $$\mathbb{Q}$$:

1. $$\begin{array}{r} 2x + y = 3 \\ 3x - y = 2 \\ \end{array}$$

2. $$\begin{array}{r} 2x + y - z = 0 \\ -x - y + z = 1 \\ \end{array}$$

2. Is it possible for a system of linear equations with more variables than equations to have no solution?