upiterbarg / mpmath

Automatically exported from code.google.com/p/mpmath
Other
0 stars 0 forks source link

Determinant and inverse calculation is wrong #229

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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. 

What steps will reproduce the problem?
#========================
from __future__ import division
import numpy as np
import sympy.mpmath as 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]
#========================

What is the expected output? What do you see instead?

The output is :
3.4638706823j
0
(0.0 + 3.46387068230212j)

Expected output:
3.4638706823j
(0.0 + 3.46387068230212j)
(0.0 + 3.46387068230212j)

What version of the product are you using? On what operating system?
0.17, ubuntu

Please provide any additional information below.

The same problem occurs when trying to calculate the inverse of the matrix. 

Original issue reported on code.google.com by Sameer.G...@gmail.com on 18 Aug 2012 at 4:34