Error in linalg.inv ??

A

Ajith Kumar

Hello,
I ran the following code (Using Debian 5.0)

from numpy import *
a = arange(1.,10.)
b = reshape(a, [3,3])
c = linalg.inv(b)
print b
print c
print dot(b,c)
print dot(c,b)

And the result is

[[ 1. 2. 3.]
[ 4. 5. 6.]
[ 7. 8. 9.]]

[[ 3.15221191e+15 -6.30442381e+15 3.15221191e+15]
[ -6.30442381e+15 1.26088476e+16 -6.30442381e+15]
[ 3.15221191e+15 -6.30442381e+15 3.15221191e+15]]

[[-0.5 -1. -1. ]
[-1. -2. 2. ]
[-1.5 -3. 1. ]]

[[ 5.5 8. 10.5]
[ 3. 0. -3. ]
[ -1. 0. -3. ]]

NOT the identity matrix. Any help ?

Thanks

Ajith Kumar
 
J

John Machin

Hello,
 I ran the following code (Using Debian 5.0)

from numpy import *
a = arange(1.,10.)
b = reshape(a, [3,3])
c = linalg.inv(b)
print b
print c
print dot(b,c)
print dot(c,b)

And the result is

[[ 1.  2.  3.]
 [ 4.  5.  6.]
 [ 7.  8.  9.]]

[[  3.15221191e+15  -6.30442381e+15   3.15221191e+15]
 [ -6.30442381e+15   1.26088476e+16  -6.30442381e+15]
 [  3.15221191e+15  -6.30442381e+15   3.15221191e+15]]

[[-0.5 -1.  -1. ]
 [-1.  -2.   2. ]
 [-1.5 -3.   1. ]]

[[  5.5   8.   10.5]
 [  3.    0.   -3. ]
 [ -1.    0.   -3. ]]

NOT the identity matrix. Any help ?

It's a longer time than I care to divulge since I took courses in
matrix algebra, but I do have a vague recollection that if determinant
(B) is zero, inverse(B) is not defined ... seeing the rows and columns
in B are linear (as are those of C), IIRC that means the determinants
are zero, and you are out of luck.

Are you ignoring exceptions? Is that _exactly_ what you typed in?
Try running it again, print the calculated determinants of B and C,
and tell what version of (a) numpy (b) Python you are using.

Isn't there a mailing list for numpy?

HTH,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top