SOLUTION: How to solve 5x5 matrix using cramer's rule?

Algebra ->  Matrices-and-determiminant -> SOLUTION: How to solve 5x5 matrix using cramer's rule?      Log On


   



Question 962819: How to solve 5x5 matrix using cramer's rule?
Answer by Edwin McCravy(20054) About Me  (Show Source):
You can put this solution on YOUR website!
I assume this is a computer course you are taking and
you are writing a program for Cramer's rule.

Cramer's rule involves determinants. A determinant is 
an array, or matrix, which has a numerical value.

You must have a subprogram VAL( ) for determining the value 
VAL( ) of a determinant.  If not, you will have to write one.
But no teacher should assign this problem until a program
for evaluating a determinant has already been written.
So hopefully, you already have such a VAL( ) subprogram that
your program can call. 

Suppose we have the 5x5 system of 5 equations in 
the variables V,W,X,Y,Z:

A(1,1)*V+A(1,2)*W+A(1,3)*X+A(1,4)*Y+A(1,5)*Z=C(1)
A(2,1)*V+A(2,2)*W+A(2,3)*X+A(2,4)*Y+A(2,5)*Z=C(2)
A(3,1)*V+A(3,2)*W+A(3,3)*X+A(3,4)*Y+A(3,5)*Z=C(3)
A(4,1)*V+A(4,2)*W+A(4,3)*X+A(4,4)*Y+A(4,5)*Z=C(4)
A(5,1)*V+A(5,2)*W+A(5,3)*X+A(5,4)*Y+A(5,5)*Z=C(5)

We make 6 5x5 arrays or matrixes with a numerical
value (determinants), 

D, DV, DW, DX, DY, and DZ

We begin with D, the determinant of coefficients:

Here is the determinant D :

A(1,1)  A(1,2)  A(1,3)  A(1,4)  A(1,5)
A(2,1)  A(2,2)  A(2,3)  A(2,4)  A(2,5)
A(3,1)  A(3,2)  A(3,3)  A(3,4)  A(3,5)
A(4,1)  A(4,2)  A(4,3)  A(4,4)  A(4,5)
A(5,1)  A(5,2)  A(5,3)  A(5,4)  A(5,5)

D does not use the column of C's, the numbers 
to the right of the equal sign in the original 
problem.  But each of the other 5 matrices will 
have the column of C's replacing the column 
corresponding to the letter it represents.

The 1st variable is V, so we will construct DV.
DV will be just like D except that the first column 
will by replaced by the column of C's.  Here is DV:

C(1)  A(1,2)  A(1,3)  A(1,4)  A(1,5)
C(2)  A(2,2)  A(2,3)  A(2,4)  A(2,5)
C(3)  A(3,2)  A(3,3)  A(3,4)  A(3,5)
C(4)  A(4,2)  A(4,3)  A(4,4)  A(4,5)
C(5)  A(5,2)  A(5,3)  A(5,4)  A(5,5)

The 2nd variable is W, so we will construct DW.
DW will be like D except that the 2nd column will
by replaced by the column of C's.  Here is DW:

A(1,1)  C(1)  A(1,3)  A(1,4)  A(1,5)
A(2,1)  C(2)  A(2,3)  A(2,4)  A(2,5)
A(3,1)  C(3)  A(3,3)  A(3,4)  A(3,5)
A(4,1)  C(4)  A(4,3)  A(4,4)  A(4,5)
A(5,1)  C(5)  A(5,3)  A(5,4)  A(5,5)

You get the idea.  
Array DX will have the C's as its 3rd column. 
Array DY will have the C's as its 4th column.
Array DZ will have the C's as its 5th column.

Then we will find the 6 values of D, DV, DW, DX, DY, DZ
The variables V will be found this way:

V = VAL(DV)/VAL(D)
W = VAL(DW)/VAL(D)
X = VAL(DX)/VAL(D)
Y = VAL(DY)/VAL(D)
Z = VAL(DZ)/VAL(D)

Of course there will be an error if VAL(D)=0.  So watch out for that.

Good luck on writing your program.  If I can be of further help,
let me know in the thank-you note form below.

Edwin