Determinant and inverse calculation is wrong

37 views
Skip to first unread message

Sameer Grover

unread,
Aug 25, 2012, 11:19:40 PM8/25/12
to mpm...@googlegroups.com
I have a complex 2X2 matrix for which I'd like to calculate the determinant.  mpmath's det function gives a determinant of zero even though the matrix is non-singular.

We can get the correct value by multiplying term-by-term. Consider the code:

#======================== from __future__ import division import numpy as np import mpmath m3 = np.matrix([[ 5.18895807e-12 +0.00000000e+00j, 1.92716917e+11 +0.00000000e+00j], [ 0.00000000e+00 -1.93643371e-11j, 0.00000000e+00 -5.16413237e+10j]]) m = mpmath.matrix(m3) print np.linalg.det(m3) print mpmath.det(m) print m[0,0]*m[1,1]- m[1,0]*m[0,1] #========================

The output is : 3.4638706823j
0
(0.0 + 3.46387068230212j)
mpmath's det function gives a determinant of zero even though the matrix is non-singular. We get the correct value by multiplying term-by-term. This happens for any value of the precision. Can somebody confirm this bug?

I have made a bug report (Issue#229).

Thank you.

Regards,
Sameer

Fredrik Johansson

unread,
Aug 29, 2012, 2:38:30 AM8/29/12
to mpm...@googlegroups.com
Hi Sameer,
Yep. Definitely a problem with the way LU_decomp detects matrices
being singular.

> I have made a bug report (Issue#229).

Thanks.

Fredrik

Sameer Grover

unread,
Aug 29, 2012, 10:54:03 AM8/29/12
to mpm...@googlegroups.com
Thanks for the confirmation.

Sameer
Reply all
Reply to author
Forward
0 new messages