Assignment #4 - 94A

Assignment #4 - 94A


ASS4 94
-----

                        PROGRAM EQTINS
* This is a program,which solves a system of three equations with
* three unknowns(X, Y, Z).

  A1X + B1Y + C1Z = K1
  A2X + B2Y + C2Z = K2
  A3X + B3Y + C3Z = K3

1. Find a solution for the three equations with
   case a) real data, and,
   case b) complex data.
   Data are given at the end of the assignment.

* For the solution,we use the "CRAMER'S RULE" method
* which uses determinants to solve the problem.This program is being
* adapted to solve equations,with comlex numbers.Cramer's rule first
* calculates the determinant of the matrix,without the column of
* solutions:
*                    **              **
*                    *  A1   B1   C1  *
*           detmatr= *  A2   B2   C2  *
*                    *  A3   B3   C3  *
*                    **              **
* Then,we take the resulting collumn,and we change it with the first
* collumn,after with the second collumn,and finally with the third
* collumn,and we calculate their respective determinants.
* The results are:
*        **            **       **            **      **            **
*        *  K1  B1  C1  *       *  A1  K1  C1  *      *  A1  B1  K1  *
*        *  K2  B2  C2  *       *  A2  K2  C2  *      *  A2  B2  K2  *
*        *  K3  B2  C3  *       *  A3  K3  C3  *      *  A3  B3  K3  *
*        **            **       **            **      **            **
*    X =-------------------,Y =------------------,Z =------------------
*        **            **       **            **      **            **
*        *  A1  B1  C1  *       *  A1  B1  C1  *      *  A1  B1  C1  *
*        *  A2  B2  C2  *       *  A2  B2  C2  *      *  A2  B2  C2  *
*        *  A3  B3  C3  *       *  A3  B3  C3  *      *  A3  B3  C3  *
*        **            **       **            **      **            **
*

2) Put the results (only the real parts) in an array called W(5).
   Then sort them in ascending order and print the matrixafter
   having done so.

3) Print the value and position of the maximum member of the above
   array (W).


4) Organize you program in Subroutines and Functions for your calculations.
   (4 is very important, extra marks will be given for good programs).

Data
----
Read your data as you wish, but use the following values :

FOR REAL VALUES USE :
A1=3  A2=2  A3=5
B1=4  B2=1  B3=6
C1=5  C2=3  C3=-1
K1=4  K2=8  K3=6

FOR COMPLEX VALUES USE :
A1=(2.1,1.4)      A2=(-1.0,1.0)     A3=(-1.0,-2.0)
B1=(3.4,1.2)      B2=(2.0,-1.0)     B3(-2.0,1.0)
C1=(1.0,-0.5)     C2=(-3.0,-0.5)    C3(0.5,0.5)
K1=(-12.24,19.54) K2=(-12.58,18.12) K3=(4.63,-18.02)

Nikos Soumas