Advanced Math/Matrix
Expert: Paul Klarreich - 12/21/2009
QuestionI have to develop a c program which can balance a chemical equation by the method of 'Generalized matrix inverse method for balancing chemical equation and their stability'. But I am using a little different method. where I am not able to find complete step to find rank of a matrix. I don't be able to develop the algorithm for that.
Main Qus:
starting from a matrix how I can make its left rowXrow a unit matrix by just Adding & Subtracting only rows of that matrix.
Example:
main matrix:
1 0 0 -1 0 1 0 0 0
2 1 1 -3 0 0 1 0 0
0 1 2 -1-1 0 0 1 0
0 1 0 0-1 0 0 0 1
After operation:(r2-2r1;r3-r2;r4-r2;r2-r3;r4+r3;r1+r4;r2+r4)
1 0 0 0 -2 5 -2 1 1
0 1 0 0 -1 0 0 0 1
0 0 1 0 -1 2 -1 1 0
0 0 0 1 -2 4 -2 1 1
(I know the operation for the above matrix but not for all)
Is there is any general rule or method that if I apply that same rule into all matrix I get the result. so there is no need to find which row of that matrix is added or subtracted with other. that is the starting procedure is same for all(its simplify my C++ code/algorithm) but the solution should use only add/subtraction of rows?
please help me...Rahul
AnswerI think your program could work like this:
for k = 1 to n
check that A[k,k] is not zero.
if it is zero, then
repeat
switch row k with a later one
until A[k,k] is not zero.
Divide row k by A[k,k] to make A[k,k] = 1.
for newrow = k+1 to n
Get factor = A[newrow,k]
Subtract Row k * factor from Row newrow.
-- now A[newrow,k] = zero.
end for
end for
Now you should have your matrix diagonalized.