Latest Post

Loading...

Monday 16 April 2012

Gaussian EliminationTo Solve Three Simultaneous Equations . By sherlock

This tutorial will explain how to apply the Gaussian Elimination Method to solving three simultaneous equations. Gaussian Elimination is a process of steps used to solve simultaneous equations. As the name suggests it uses specific methods to eliminate variables in the equations until a single variable is left. To start this tutorial we need first three simultaneous equations; 2X+3Y-4Z=20 5X-6Y+7Z=30 8X+9Y+10Z=100 We now have our three equations. We now need to turn these into a matrix. A matrix basically means a table. For Gaussian Elimination we use the following format for the matrix; X1 | Y1 | Z1 | A1 X2 | Y2 | Z2 | A2 X3 | Y3 | Z3 | A3 Where X1 means the multiplier of X in the first equation and A1 means the answer, or equal to value of equation one. Using this, our starting matrix will look like this; 2 | 3 | -4 | 20 5 | -6 | 7 | 30 8 | 9 | 10 | 100 Note that if the variable is deducted in the equation we take the negativeinto the table, e.g. the first equation has 4Z deducted, so in our matrix table we have negative four. The aim of Gaussian Elimination is to turn this matrix into this; 1 | 0 | 0 | A Value 0 | 1 | 0 | A Value 0 | 0 | 1 | A Value I will explain how we use this matrix later on, when we reach that stage. How do we get our matrix table to this I hear you asking? To do this we can do specific operations to the rows in the matrix to work our way towards the goal matrix. These operations are; 1. We can multiply or divide an entire row by any number. 2. We can add or deduct any row to another. 3. We can also substitute rows from earlier calculations back in. 4. To simplify the matrix we can also swap any row with another. On a side note if your starting matrix contains any zeros you may need to either modify the following steps or ignore them all together. For this tutorial I will focus on the above matrix. To start with we will focus on making any row be the following; 1 | 0 | 0 | A Value To do this we can start of by making the second column, the 'Y' column have the same value for both rows one and two. The easiest way to reach this is to multiply the first row by the second row's 'Y' value; (2x-6) | (3x-6) | (-4x-6) | (20x-6) 5 | -6 | 7 | 30 8 | 9 | 10 | 100 Now we do the same to make row two's 'Y' value be equal to the value we just calculated for row one. We do this by multiplying the entire row by row one's original 'Y' value. -12 | -18 | 24 | -120 (5x3) | (-6x3) | (7x3) | (30x3) 8 | 9 | 10 | 100 Now we have rows one and two which both have the same value in the 'Y' column, we deduct row two from row one, which gives us this new matrix; -27 | 0 | 3 | -210 15 | -18 | 21 | 90 8 | 9 | 10 | 100 We now have eliminated our first variable. Now we need to eliminate the 'Z' variable in the first row, but we cannot simply just repeat the process exactly because the other two rows have 'Y' values, if we do any deductions into row one we will get a 'Y' value again. To combat this we need to eliminate the 'Y' variable from either the second or third row. To do this we use the same method as we did to remove the 'Y' variable from the first row, multiply the second row by the value of the third row's 'Y' variable and multiply the third row by the second row's 'Y' value; -27 | 0 | 3 | -210 (15x9) | (-18x9) | (21x9) | (90x9) (8x-18) | (9x-18) | (10x-18) | (100x-18) To eliminate the 'Y' variable from row two simply deduct row three from row two. This gives us this matrix; -27 | 0 | 3 | -210 279 | 0 | 369 | 2610 -144 | -162 | -180 | -1800 Now we have eliminated the 'Y' variable from the second row we cannow use this row to eliminate the 'Z' variable from the first row. You may see a pattern emerging here because we now use the same method as we have been; we need to make the 'Z' variable in rows one and two to have the same value. Likewe have been doing, to do this we need to multiply the first row by the 'Z' value of the second row and multiply the second row by the 'Z' value from the first row; (-27x369) | 0 | (3x369) | (-210x369) (279x3) | 0 | (369x3) | (2610x3) -144 | -162 | -180 | -1800 Now, like we have done before, deduct row two from row one, leaving us with the following matrix; 10800 | 0 | 0 | 85320 837 | 0 | 1107 | 7830 -144 | -162 | -180 | -1800 The final step we need to take on getting our first final row is to divide row one by its own 'X' value to leave us with the following matrix; 1 | 0 | 0 | 7.9 837 | 0 | 1107 | 7830 -144 | -162 | -180 | -1800 We now have our first final row! We now have two paths which we must choose from. These are; 1. Go Back to the original matrix and use the same methods focusing on getting a row with the 'X' and 'Z' eliminated, leaving only the 'Y' variable. 2. Continue using the matrix above. If you started out with a matrix that contained some zeros I would recommend that you take the first path, as I have done when I worked on the Simultaneous Equation Solver Program (free download). For this tutorial we will be following the second path, as the first would only be a repeat of everything we have already done. Looking at our latest matrix it is clearto me where I will be taking this tutorial next. In the interest of doing the least possible steps we will now move on to making a row be this; 0 | 0 | 1 | A Value We will come back to this row later on; 0 | 1 | 0 | A Value This can be done in three simple steps. Looking at row two all we need to do is eliminate the 'X' value, as we have already eliminated the 'Y' value. As row one only has a 'X' value logic dictates we use this row. For this step simply multiply row one by row two's 'X' value; (1x837) | 0 | 0 | (7.9x837) 837 | 0 | 1107 | 7830 -144 | -162 | -180 | -1800 This gives us a new matrix which is this; 837 | 0 | 0 | 6612.3 837 | 0 | 1107 | 7830 -144 | -162 | -180 | -1800 Now like we have done before, we deduct row one from row two which will give us the following matrix; 837 | 0 | 0 | 6612.3 0 | 0 | 1107 | 1217.7 -144 | -162 | -180 | -1800 Now we have eliminated the 'X' value from the second row we now only have a 'Z' value. To finish this row off we simply divide row two by its 'Z' value, which leaves us with thismatrix; 1 | 0 | 0 | 7.9 -144 | -162 | -180 | -1800 0 | 0 | 1 | 1.1 To simplify this matrix I have substituted the final values for row one back into our matrix, as well as this I have swapped over rows two and rows there. We are now two-thirds complete, leaving just one row to go! The final row is the easiest because we can use rows one and three to eliminate the 'X' and 'Z' values from row two. To start this let's multiply row one by row two's 'X' value, leaving use this matrix; -144 | 0 | 0 | -1137.6 -144 | -162 | -180 | -1800 0 | 0 | 1 | 1.1 Repeating a familiar step that we have done before, deduct row one from row two. This gives us the following matrix; -144 | 0 | 0 | -1137.6 0 | -162 | -180 | -662.4 0 | 0 | 1 | 1.1 We now do the same again to remove the 'Z' value, so our matrix now looks like this; 1 | 0 | 0 | 7.9 0 | -162 | -180 | -662.4 0 | 0 | -180 | -198 I have substitute row ones final values back into the matrix to simplify the matrix. For the final time we now deduct row three from row two, leaving use with this matrix; 1 | 0 | 0 | 7.9 0 | -162 | 0 | -464.4 0 | 0 | -180 | -198 The final step is to divide the second row by its 'Y' value. To give the final matrix of; 1 | 0 | 0 | 7.9 0 | 1 | 0 | 2.867 0 | 0 | 1 | 1.1 So now we have our final matrix, how do we use this? Well taking the first row, it simply means this; 1X + 0Y + 0Z = 7.9 Which when simplified means this; X=7.9 So from our final matrix table we candetermine that; X=7.9 Y=2.867 Z=1.1 The final thing we need to do is plug these values back into our original equations to check they are correct. Equation one; (2x7.9) + (3x2.867) - (4x1.1) = 20 15.8 + 8.6 - 4.4 = 20 24.4 - 4.4 = 20 This equation is correct. Equation two; (5x7.9) - (6x2.867) + (7x1.1) = 30 39.5 - 17.2 + 7.7 = 30 22.3 + 7.7 = 30 This equation is correct. Equation 3; (8x7.9) + (9x2.867) + (10x1.1) = 100 63.2 + 25.8 + 11 = 100 89 + 11 = 100 This equation is correct. So that's how to use Gaussian Elimination to resolve three simultaneous equations