Computational Physics - Department of Physics

(Axel Boer) #1

6.4 Linear Systems 179


det{A}=∑
p

(− 1 )pa 1 p 1 ·a 2 p 2 ···an pn,

where the sum runs over all permutationspof the indices 1 , 2 ,...,n, altogethern!terms. To
calculate the inverse ofAis a formidable task. Here we have to calculatethe complementary
cofactorai jof each elementai jwhich is the(n− 1 )determinant obtained by striking out the
rowiand column jin which the elementai jappears. The inverse ofAis then constructed
as the transpose of a matrix with the elements(−)i+jai j. This involves a calculation ofn^2
determinants using the formula above. A simplified method ishighly needed.
With the LU decomposed matrixAin Eq. (6.18) it is rather easy to find the determinant


det{A}=det{L}×det{U}=det{U},

since the diagonal elements ofLequal 1. Thus the determinant can be written


det{A}=

N

k= 1

ukk.

The inverse is slightly more difficult. However, with an LU decomposed matrix this reduces
to solving a set of linear equations. To see this, we recall that if the inverse exists then


A−^1 A=I,

the identity matrix. With an LU decomposed matrix we can rewrite the last equation as


LUA−^1 =I.

If we assume that the first column (that is column 1) of the inverse matrix can be written as
a vector with unknown entries


A− 11 =





a− 111
a− 211
...
a−n 11




,

then we have a linear set of equations


LU





a− 111
a− 211
...
a−n 11




=





1

0

...

0




.

In a similar way we can compute the unknow entries of the second column,


LU





a− 121
a− 221
...
a−n 21




=





0

1

...

0




,

and continue till we have solved allnsets of linear equations.
A calculation of the inverse of a matrix could then be implemented in the following way:



  • Set up the matrix to be inverted.

  • Call the LU decomposition function.

Free download pdf