Computers in Engineering - 308-208 Lecture 26
Computers in Engineering - 308-208

# Lesson 26 - Learning Goals

## 26.3 Learn how to implement Gaussian Elimination in FORTRAN

SYSTEMS OF LINEAR EQUATIONS

A system of n linear equations in n unknowns has (hopefully) one solution.

Example :

5x + 3y -  z = 8

x  -  y + 2z = 5

2x - 3y + 4z = 8

METHODS TO FIND THE SOLUTION

TRANSFORMS PRESERVING SOLUTION :

• Exchange two rows

• Multiply a row by a constant

• Add a multiple of one row to another

GAUSSIAN ELIMINATION :

Transform rows until each has only 1 variable.

This means "diagonal" elements 1, all other numbers except right column are 0.

TRIANGULARIZATION :

Transform equations until lower triangle is all zeroes, then apply "back-substitution".

EXAMPLE

have,

```    5x + 3y -  z = 8
x -  y + 2z = 5
2x - 3y + 4z = 8
```
This is represented with an AUGMENTED MATRIX:
```   | 5   3  -1   8 |
| 1  -1   2   5 |
| 2  -3   4   8 |```
The augmented matrix is the coefficients of the linear equations, including the right hand sides, written as a matrix with n rows and n+1 columns.
```R1=R1/5     | 1  0.6 -0.2  1.6 |
| 1 -1    2    5   |
| 2 -3    4    8   |

| 1  0.6 -0.2  1.6 |
R2=R2-R1    | 0 -1.6  2.2  3.4 |
R3=R3-2R1   | 0 -4.2  4.4  4.8 |

| 1  0.6 -0.2    1.6   |
R2=R2/-1.6  | 0  1   -1.375 -2.125 |
| 0 -4.2  4.4    4.8   |

| 1  0.6 -0.2    1.6   |
| 0  1   -1.375 -2.125 |
R3=R3+4.2R2 | 0  0   -1.375 -4.125 |

| 1  0.6 -0.2    1.6   |
| 0  1   -1.375 -2.125 |
R3=R3/-1.375| 0  0    1      3     |```
It is obvious from here that z=3. Substituting this value into R2 gives y=2. And finally, substituting these values of y and z into R1 gives x=1.

The final solution is x=1, y=2, z=3.