Error in linalg.inv ??
Robert Kern
robert.kern at gmail.com
Sat Jun 6 17:15:01 EDT 2009
On 2009-06-06 00:34, Ajith Kumar wrote:
> Hello,
> I ran the following code (Using Debian 5.0)
>
> from numpy import *
Please ask numpy questions on the numpy mailing list, not here:
http://www.scipy.org/Mailing_Lists
> 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 ?
You have a very singular matrix (2*a[1] - a[0] == a[2]). You cannot invert it
numerically and expect sensible results.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list