An error of matrix inversion using NumPy

Lou Pecora pecora at anvil.nrl.navy.mil
Wed Apr 4 13:06:59 EDT 2007


In article <1175698343.919351.9710 at o5g2000hsb.googlegroups.com>,
 "lancered" <wangday at gmail.com> wrote:

> Here is the eigenvalues of KK  I obtained:
> 
>  >>> linalg.eigvals(KK)
> array([  1.11748411e+05,   3.67154458e+04,   3.41580846e+04,
>          2.75272440e+04,   2.09790868e+04,   1.86242332e+04,
>          8.68628325e+03,   6.66127732e+03,   6.15547187e+03,
>          4.68626197e+03,   3.17838339e+03,   2.84888045e+03,
>          1.88279736e+03,   1.32427574e+03,   1.04946287e+03,
>          5.79303171e+02,   3.83111876e+02,   4.93826556e-12,
>          1.50263232e-12])
> 
> You are right. The ratio of max/min eigenvalues is 7.4368432669e+016
> Maybe this exceed the of precision of my machine?
> 
> Is there any tricks for me to be able to deal with this matrix
> correctly with
> NumPy?

That sounds large to me, too.  Close to the floating point accuracy.  
The problem is not with NumPy,but with double precision numbers. No 
routine can save you if the condition number is large.  However, several 
people here have noted that you might be able to solve your problem by 
avoiding inverting the matrix in the first place.  In other words, 
depending on your particular problem, there may be other ways to solve 
it beside brute force inversion.  Can you Use a QR or SVD approach?

-- Lou Pecora  (my views are my own) REMOVE THIS to email me.



More information about the Python-list mailing list