2008-04-14

Solving simultaneous equations using Matrix method

The previous topic I discussed was Maclaurin's Series. Now I'm going to discuss "solving simultaneous equations using Matrix method".

I know a lot of people would think solving simultaneous equations would be an easy task. There would be three methods, by subtracting, by substitution and by graphical method. I would not recommend subtracting, mainly because it needs some thinking before you execute operations on the equations. But once you have successfully executed operations on the equations correctly, you can get the answer straight away.

Substitution would be a better way for all of us to use. Just take one of the two equations and make one of the variables the subject and then substitute the subject variable with the expression you obtained. You'd also get the same answer.

The easy-to-see way is by graphical method. Plot the two lines and/or curves and get the intersection points and you also get the answer straight away. But the catch is it's troublesome whereby you need to get some values before you can plot.

But the above illustration only involves equations with two variables. How about equations with more than two variables? How to we solve it? Of course you can have substitution method, but that is very tedious. The only way we can solve this is through Matrix. That's why we learn Matrix!

I came across this question on a forum:

3x - y + 2z = 0
2x + y -4x = -9
x+ y + 3z = 6

By using the conventional subtracting method, we'd have

3x - y + 2z = 0 - (1)
2x + y -4x = -9 - (2)
x+ y + 3z = 6 - (3)

Add (1) to (2):
5x - 2z = -9
5x = -9 + 2z
x = (-9 + 2z)/5 - (4)

Add (1) to (3):
4x + 5z = 6 - (5)

Put (4) into (5):
4((-9 + 2z)/5) + 5z = 6
-36/5 + 8z/5 + 5z = 6
-36 + 8z + 25z = 30
33z = 66
z = 2

From here onwards, solve for x using (5) and then solve for y.

Substitution is even more for people who won't want to spend time thinking. Won't show example here.

In subsequent explanation, the matrix mentioned here refers to a standard 3 x 3 matrix.
For Matrix method, there are 3 sub types with first being idiot-proof method, which we know that you need to obtain an inverse of a matrix, multiplying it with another matrix in order to get the answer. But, it's tedious to get the inverse matrix by hand.

The second being Gaussian Elimination Method. This method is the simplest to be solved by hand and is the standard method for solving them on computers. Basically you just have to do operations on the row of numbers, called row echelon operations, starting with first row, then using it to subtract/add the other rows then put the new 'row numbers' into the row.

For example if you multiply the first number on the second row by 5, then subsequently you have to do the same for all numbers on the same row. The objective of row echelon operations is to reduce the matrix into
(1 a b)
(0 1 c)
(0 0 1)

The other method is Gauss-Jordan Elimination Method. This method you must reduce further the matrix into the reduced row echelon form using row echelon operations, but this time round take first row subtract/add the second row then subtract/add the third row before putting it back into the first row:
(1 0 0)
(0 1 0)
(0 0 1)

Note that, though this method looks like an extension of Gaussian Elimination Method, it simply display the answers simultaneously. Also, this method is used to find the inverse of a matrix (won't touch on this topic).

For Gaussian Elimination Method:


Write the augmented matrix.
(3 -1 2 | 0)
(2 1 4 | -9)
(1 1 3 | 6)

In row-echelon form,

1/3R1 -> R1 (1 -1/3 2/3 | 0)
R1 - 3/2R2 -> R2 (0 -5/2 8 | 27/2)
R1 - 3R3 -> R3 (0 -4 -7 | -18)

(1 -1/3 2/3 | 0)
-2/5R2 -> R2 (0 1 -16/5 | -27/5)
-8/5R2 + R3 -> R3 (0 0 -99/5 |-198/5)

x - 1/3y + 2/3z = 0 - (1)
y - 16/5z = -27/5 - (2)
-99/5z = -198/5 - (3)

From (3): z = 2 - (4)
Substitute (4) into (2)

y = -27/5 + 16/5 * 2
= 1 - (5)

Substitute (5) and (4) into (1):

x = 1/3 * 1 - 2/3 * 2
= -1

For Gauss-Jordan Elimination Method:
Write the augmented matrix.
(3 -1 2 | 0)
(2 1 4 | -9)
(1 1 3 | 6)

In row-echelon form,

1/3R1 -> R1 (1 -1/3 2/3 | 0)
R1 - 3/2R2 -> R2 (0 -5/2 8 | 27/2)
R1 - 3R3 -> R3 (0 -4 -7 | -18)

(1 -1/3 2/3 | 0)
-2/5R2 -> R2 (0 1 -16/5 | -27/5)
-8/5R2 + R3 -> R3 (0 0 -99/5 |-198/5)

Until here, the steps above are carried out the same way as you would for Gaussian Elimination Method.

(1 -1/3 2/3 | 0)
(0 1 -16/5 | -27/5)
-5/99R3 -> R3 (0 0 1 | 2)

R1 + 1/3R3 -> R1 (1 0 -2/5 | -9/5)
R2 - 16/99R3 -> R2 (0 1 0 | 1)
(0 0 1 | 2)

R1 + 2/5R3 -> R1 (1 0 0 | -1)
(0 1 0 | 1)
(0 0 1 | 2)

Hence, x = -1, y = 1 and z = 2.

Isn't it a lot simpler and clearer?

No comments: