First, we place the equation into matrix form, Ax=b:
x - 2y - z = 2x−2y−z=2
2x - y+ z = 42x−y+z=4
-x +y -2z = -4−x+y−2z=−4
Becomes:
A = ( (1, -2, -1), (2, -1, 1), (-1, 1, -2))
x = ((x_1), (x_2), (x_3)) = ((x), (y), (z))
b = ((2), (4), (-4))
Giving us:
( (1, -2, -1), (2, -1, 1), (-1, 1, -2)) ((x_1), (x_2), (x_3)) = ((2), (4), (-4))
From here, we will use elementary row operations to solve this. Our altered matrix, A', should be an upper triangular matrix; that is, one where the only non-zero entries are along the main diagonal (upper left corner to lower right) and above. Thus, there will be no non-zero entries below (or to the left) of the main diagonal.
Let us define R_1 = (1, -2, -1), R_2 = (2, -1, 1), R_3 = (-1, 1, -2) and our b values of b_1 = 2, b_2 = 4, b_3 = -4
First, we will change entries a_21 and a_31 to 0 via these operations. Note that these operations will also transform the corresponding b values; essentially at this point, we are adding and subtracting equations to/from one another, which by necessity will include adding and subtracting the answers of the original equations. We will begin by subtracting twice row 1 from row 2 (to reduce the first entry in row 2 to 0), and then we will add row 1 to row 3 (reducing the first entry in row 3 to 0). These new rows will be labelled as R'_2 and R'_3
R'_2 = R_2 - 2 R_1 = (2-2, -1 + 4, 1 + 2) = (0, 3, 3) and b'_2 = b_2 - 2b_1 = 4 - 4 = 0
And
R'_3 = R_3+R_1 = (-1 + 1, 1 - 2, -2 - 1) = (0, -1, -3) and #b'_3 = b_3 + b_1 = -4 + 2 = -2
At this point in our operations we should have:
( (1, -2, -1), (0, 3, 3), (0, -1, -3)) ((x_1),(x_2),(x_3)) = ((2),(0),(-2))
Next, we wish to reduce entry a'_32 to 0. We will do this by adding one third of R'_2 to R'_3, making sure to also make the appropriate change to b'_3
R''_3 = R'_3 + 1/3 R'_2 = (0+0, -1+1, -3+1) = (0, 0, -2) and b"_3 = b'_3+ 1/3 b'_2 = -2 + 0 = -2
This yields our upper triangular matrix as:
( (1, -2, -1), (0, 3, 3), (0, 0, -2)) ((x_1),(x_2),(x_3)) = ((2),(0),(-2))
From here, we note that row 3 multiplies out to 0x_1 + 0x_2 -2 x_3 = -2 => -2x_3 = -2 => x_3 = 1
We may then multiply out row 2 (i.e. multiplying the row by our x column vector to get the appropriate result from our b vector) and recall that x_3 = 1 to obtain:
3x_2 + 3x_3 = 0 = 3x_2 + 3 => 3x_2 = -3 => x_2 = -1
Performing a similar trick with our first row we get:
x_1 - 2x_2 - x_3 = x_1 +2 -1 = x_1 +1 = 2 => x_1 = 1
Since x_1, x_2, x_3 are x, y, z respectively, we get x = 1, y = -1, z = 1