• Nem Talált Eredményt

Examples of Gaussian Elimination

2.3 Systems of Linear Equations

2.3.1 Examples of Gaussian Elimination

 4

−1 2

.

2.3 Systems of Linear Equations

In the previous section we encountered a system of equations several times. Namely, every time we wanted to express a vector as a linear combination of some other vectors we got linear equations by equating the coordinates of the linear combination and the vector in question.

By alinear equation we mean an equation of the forma1x2+a2x2+· · ·+anxn=b, where x1, x2, . . . , xnare variables, and the coefficientsa1, a2, . . . , an and the constant termb are real numbers. Asystem of linear equations consists of finitely many linear equations, where the same variables (sayx1, . . . , xn) occur in every equation. By a solution of this system we mean the real numbers y1, . . . , yn that satisfy all the equations at the same time when substituted in the place of the variables.

These kind of systems occur in many applications (beside the one that we have already seen), so we give a general algorithm for their solution called theGaussian elimination. With the help of this algorithm we will be able to decide if a system of linear equations is solvable, and if it is, then the algorithm will give all of its solutions in a manageable way. Our method will also make it possible for us to prove general statements about systems of equations.

2.3.1 Examples of Gaussian Elimination

Before describing the general algorithm we give some examples as an introduction. Let us consider the following system of linear equations with3 variables and 4equations (in the left column):

2x1− x2+ 6x3 =12 x112x2+ 3x3 =6 x112x2+3x3 =6 2x1+2x2+ 3x3 =24 → 2x1+ 2x2+ 3x3 =24 → 3x2−3x3 =12 6x1− x2+17x3 =46 6x1− x2+17x3 =46 2x2− x3 =10 4x1− x2+13x3 =32 4x1− x2+13x3 =32 x2+ x3 =8

For the elimination of the first variable x1 from the last three equations we first divide the first equation by 2 and hence the coefficient of x1 becomes 1, while the other equations are left unchanged (this can be seen in the middle column above). Then we subtract a suitable multiple of the (new) first equation from the others so thatx1 does not occur in the resulting equations (see the third column).

Now we can repeat these steps for the system of the last three equations, where the number of the variables is less than in the original system (since x1 has already been eliminated).

But before this we rewrite the steps above in a form which is practical for storing this kind of data. Namely, the names of the variables and the signs of the operations are superfluous (at least for the computer). Hence we omit them and write the coefficients and the constant term on the right hand sides in a so-calledaugmented coefficient matrix. This is nothing else than a table of numbers where every row belongs to an equation and we write the coefficients of the variables in the (fixed) order of the variables in every row, while we separate the constant term in the end of every line by a vertical line. Here are the3matrices for the original system and for the ones after the first two steps:

Observe that the multiplication of an equation by a number α (i.e. the division by 1/α) corresponds to the multiplication of the elements in a row byα in the augmented coefficient matrix. Similarly, adding (or subtracting) a multiple of an equation to another corresponds to adding (or subtracting) a scalar multiple of a row to another, where we make the operations element-wise (like in the case of column vectors).

Now we continue the elimination using this notation. In the next step we divide the second row by3(i.e. multiply it by1/3), then we subtract from the third and the fourth row the (new) second row multiplied by 2and 1, respectively:

In the third row of the resulting matrix the first non-zero number is 1, so we only subtract 2 times this row from the last one. This way every number in the last row becomes 0, and this row corresponds to the equation0x1+ 0x2+ 0x3 = 0. This equation holds regardless of how the values of the variablesx1, x2 and x3 are chosen. Hence the solutions of the system remain the same if we omit this equation:

The result above is called therow echelon form of the system: there is a non-zero element in every row before the vertical line, and the first one among these is 1 (in every row).

Moreover if i < j, then the first non-zero number in the jth row is on the right of the first non-zero element in the ith row. The first non-zero element in a row on the left side of the vertical line is called the leading coefficient of that row. Observe that one may read the

solution of the equation from this. The last row corresponds to 0x1 + 0x2 + 1x3 = 2, i.e.

x3 = 2. From the second row we get x2 −x3 = 4, hence x2 = 4 +x3 = 6. We get similarly from the first row thatx1 = 3.

Instead of this we can continue the process, and eliminate all non-zero numbers in the matrix above the leading coefficient. That is, we add the last row to the second one and subtract 3 times the last row from the first one. Note that this does not effect the first two columns of the matrix, because the first two elements in the last row are zero. Finally, we add 12 times the (new) second row to the first one (effecting only the second and the last column, because every other element in the second row is 0):

1 −12 0 0 0 1 0 6 0 0 1 2

∼

1 0 0 3 0 1 0 6 0 0 1 2

The result above is the so-calledreduced row echelon form: it is a row echelon form (and hence the leading coefficient of every row is1) and every other element in the column of the leading coefficients is zero. One can read the solution of the system from it directly: the last column contains the values ofx1, x2 and x3 in this order.

Let us change the right hand side of the last equation in the original system to 33. If we repeat the steps that we made above until we got the identically zero last row, here we obtain the following matrix:

1 −12 3 6 0 1 −1 4

0 0 1 2

0 0 0 1

Here the last row corresponds to the equation 0x1+ 0x2+ 0x3 = 1, which does not hold for any values of x1, x2, x3. As this equation follows from the original ones, this means that the system is inconsistent, i.e. it has no solution. Hence our algorithm can stop whenever a row occurs where every element is zero except the last one (we may call this aforbidden row).

We show another example for the Gaussian elimination, where the steps that we made above cannot always be accomplished and we need a refinement of our method. Also, in this case we will have infinitely many solutions. So let us consider the system

x1+ x2+ 2x3+ 2x4+ x5 =−1, 4x1+ 4x2+ 8x3+ 9x4+ x5 =−7, 2x1+ 5x2+ 13x3+ x4+ 26x5 = 10,

x1+ 3x2+ 8x3+ 2x4+ 11x5 = 1, 2x1+ x2+ x3+ 2x4+ 3x5 = 3.

First we make the augmented coefficient matrix of the system. The boxed element of the matrix will indicate the current phase of the process. These boxed elements will be set to 1 and these will be the leading coefficients of the rows. The first coefficient of the first row is 1originally, so we do not need to multiply this row, we only change the numbers below it to

0by adding an appropriate multiple of the first row to the other rows:

Now we change the position of the box: we step to the next row and then to the next column. But in this example we cannot continue as before, because the boxed element is zero and hence we cannot multiply the row so that this number becomes1. But this problem can be solved easily: we may swap the second and the third rows (equations) - and leave the position of the box unchanged:

Now we continue as above: we divide the second row by3and add an appropriate multiple of the (new) second row to the others below it such that every number below the leading coefficient of the second row becomes zero:

Next we change the position of the box as before, and we get that the boxed element is zero again. But unlike in the previous case every element below the boxed number is zero and we cannot swap the rows. Hence we cannot change the boxed element to 1 without changing the first two rows (which we will keep fixed for a while). Instead of this, we change the position of the box again: we step to the next element in the same row:

The current leading coefficient is1, so we do not have to multiply the third row, we simply change the numbers below the boxed element to zero. This way every element of the last two rows becomes zero, so we can omit these rows and obtain the echelon form of the matrix:

The following steps of the algorithm lead to the reduced echelon form. We are going to change every element above the leading coefficients to zero. We begin this process in the last row by adding the last row to the second one and subtracting two times the last row from the first one. Then we step back to the second row and subtract it from the first one:

1 1 2 0 7 5

0 1 3 0 5 1

0 0 0 1 −3 −3

∼

1 0 −1 0 2 4

0 1 3 0 5 1

0 0 0 1 −3 −3

We have reached the reduced echelon form and the algorithm stops. This form gives us all the solutions of the system in a manageable form. To see this we consider the equations that correspond to the rows of the last matrix:

x1 − x3 + 2x5 = 4, x2+ 3x3 + 5x5 = 1,

x4−3x5 =−3.

Easy to see that the values ofx3 and x5 can be chosen freely, and after that the values of the other variables can be expressed in terms of these values uniquely. Hence the solutions of the system can be written in the following form:

x3 =α∈R, x5 =β ∈R, x1 = 4−2β+α,

x2 = 1−5β−3α, x4 =−3 + 3β.

We call the variablesx3 and x5 free parameters (since their values can be chosen freely).

They are those variables for which there is no leading coefficient in the corresponding column of the coefficient matrix.