Assignment #6 - 88B

Assignment #6 - 88B

```
308-208
Assignement #6
TA : AZEDINE.
WEIGHT: 35
DUE: 20 NOVEMBER

Write a PASCAL program to solve the following
simultaneous  linear equations for X1, X2, ..., Xn.

A11 * X1 + A12 * X2 + A13 * X3 + ..... +  A1n * Xn = B1

A21 * X1 + A22 * X2 + A23 * X3 + ..... +  A2n * Xn = B2

An1 * X1 + An2 * X2 + An3 * X3 + ..... +  Ann * Xn = Bn

There are several possible  methods  for  solving  such  equations ,
however the following  method is recommended. First read the value of
the number of the equations (n) and the coefficients of the equations
into a matrix ( with n rows and n+1 columns). Now transform the equa-
-tions in  the following  manner. Take the first equation, and divide
all its coefficients by the coefficient of X1 ( ie A11). This coeffi-
-cient of X1 now  becomes one. Next modify the remaining equations by
substracting  suitable multiples of the first equation from  each  of
them, so as to obtain  a zero coefficient for X1 in the second, third
..and n_th equations. Repeat this sequence dividing the second equa-
-tion by the coefficient of X2 in the second equation. Substract sui-
-table multiples of the second equation from  third, fourth ..... and
n_th equations, so that their X  coefficient becomes a zero. Continue
the process until all the coefficients in the lower left of the matrix
the lower left of the matrix are zero,and all the diagonal coefficients
are one
The value of Xn can now be determined directly from the n_th  equation
The solution for Xn-1 can be  determined from  the  (n-1)_th  equation
using the value obtained for Xn. Simularly  X2  can be determined from
the second equation,and X1 from the first equation using the solutions

I want you to run it on 3 differents set of data.You must print the
simultaneous  linear  equations, that should be solved, and the result
in an elegent manner.

Set #1:  n=3;
2 X1 + 4 X2 - 2 X3 = 4
3 X1 +   X2 - 2 X3 = 6
X1 -   X2 +   X3 = 3

Set #2:  n=2;
2 X1 + 13 X2 = 25
5 X1 + 53 X2 = 37

Set #3:  n=4;
3 X1 + 2 X2 -   X3  +  1 X4  = 4
2 X1 +   X2 - 2 X3  -   6 X4 = 5
X1 -   X2 +   X3           = 3
5 X1        - 3 X3  +   7 X4 = 1
```