Assignment #6 - 84B

# Assignment #6 - 84B

```                            ASSIGNMENT 6
WEIGHT: 30
DUE: 20 NOVEMBER 84

IN THIS ASSIGNMENT, YOU MUST FIRST WRITE A SIMPLE PASCAL PROCEDURE
TO COMPUTE THE DETERMINANT OF A 3X3 MATRIX M.  THE DETERMINANT OF M,
CALLED DET(M), IS DEFINED AS:
__             __
| A    A    A   |
|  11   12   13 |
|               |      --->  DET(M) = (A  A  A   + A  A  A
M =  | A    A    A   |                       11 22 33    12 23 31
|  21   22   23 |                            + A  A  A   )
|               |                               13 21 32
| A    A    A   |                       -   (A  A  A   + A  A  A
|  31   32   33 |                             13 22 31    12 21 33
--             --                                 + A  A  A   )
11 32 23

IF THE DETERMINANT IS 0, THEN M IS SINGULAR.  THEREFORE, YOUR
PROCEDURE SHOULD RETURN A FLAG CALLED "SINGULAR" THAT IS TRUE IF THIS
CONDITION EXISTS AND FALSE OTHERWISE.

TYPE MATRIX = ARRAY(3,3) OF INTEGER;
.                 .
.                 .
.                 .
PROCEDURE   FIND_DET(M:MATRIX; VAR SINGULAR:BOOLEAN;
VAR DET:INTEGER)  ;

THEN, USE THE PRECEDING PROCEDURE TO FIND THE SOLUTION TO THE 3X3
SYSTEM OF EQUATIONS :

A  X  + A  X  + A  X  = B
11 1    12 2    13 3    1

A  X  + A  X  + A  X  = B
21 1    22 2    23 3    2

A  X  + A  X  + A  X  = B
31 1    32 2    33 3    3

USING CRAMER'S RULE.

CRAMER'S RULE STATES THAT THE SOLUTION TO THE PRECEDING PROBLEM CAN
BE FOUND BY BUILDING AN "AUGMENTED MATRIX" M(I) BY REPLACING THE ITH
COLUMN OF M WITH THE CONSTANTS B , B  , B  .
1   2    3

THE VALUE OF X  AT THE SOLUTION POINT IS SIMPLY
I

DET( M(I) )
X   =   -----------
I        DET( M )

FOR EXAMPLE, THE VALUE OF X  IS
1

__           __
|  B  A   A   |
|   1  12  13 |
|             |
|  B  A   A   |
DET   |   2  22  23 |
|             |
|  B  A   A   |
|   3  32  33 |
--           --
X   =  _________________________________
1              __           __
| A   A   A   |
|  11  12  13 |
|             |
| A   A   A   |
DET   |  21  22  23 |
|             |
| A   A   A   |
|  31  32  33 |
--           --

NOTE THAT THIS PROCEDURE WORKS ONLY IF THE MATRIX M IS NOT SINGULAR.
IF THIS CONDITION IS NOT MET, THEN YOU SHOULD PRINT A MESSAGE SPECIFYING
THAT THE GIVEN SYSTEM OF LINEAR EQUATIONS CANNOT BE SOLVED USING
CRAMER'S RULE.

TEST YOUR PROGRAM WITH THE FOLLOWING 3 SYSTEMS OF LINEAR EQUATIONS:

A    A    A    B
K1   K2   K3   K
_________________
1    1    2    9
2    4   -3    1
3    6   -5    0

2    1    3    0
1    2    0    0
0    1    1    0

1   -2    7    4
3    5    1    2
4    3    8   -1
```