Determinant of Large Matrix

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Wed Jun 6 20:48:55 EDT 2007


On Wed, 06 Jun 2007 04:10:43 -0700, James Stroud wrote:

> Hello All,
> 
> I'm using numpy to calculate determinants of matrices that look like 
> this (13x13):

[snip matrix]

> For this matrix, I'm getting this with numpy:
> 
>   2774532095.9999971
> 
> But I have a feeling I'm exceeding the capacity of floats here. Does 
> anyone have an idea for how to treat this? Is it absurd to think I could 
> get a determinant of this matrix? Is there a python package that could 
> help me?

Is there a particular reason you think there is a problem? The determinant
given is pretty close to the integer 2774532096. Assuming that is the
correct value, the difference between:

2.7745320960000000e9 and
2.7745320959999971e9

gives a relative error of 1.0311731312618234e-13 percent. How much
precision were you after? :-)

I suspect that if there is a problem with the matrix, it is less likely
to be because of the size of floats and more likely that the matrix is
ill-conditioned. 

I don't know if numpy will calculate the condition number of the matrix,
or estimate it. If it does, do so -- a large condition number == trouble.

http://en.wikipedia.org/wiki/Condition_number

Another way to see if the matrix is ill-conditioned is to make a small
perturbation to it (say, change two or three of the entries by 0.0001 or
so), then calculate the determinate. If the result is radically different,
then the matrix is probably ill-conditioned and there is likely no help
for you except numerical black magic and/or using a different matrix.


-- 
Steven.




More information about the Python-list mailing list