[Numpy-discussion] matrix inversion

Alan G Isaac alan.isaac@gmail....
Wed Aug 10 20:06:41 CDT 2011


On 8/10/2011 8:50 PM, jp d wrote:
> i am trying to invert matrices like this:
> [[ 0.01643777 -0.13539939  0.11946689]
>   [ 0.12479926  0.01210898 -0.09217618]
>   [-0.13050087  0.07575163  0.01144993]]

> in perl using Math::MatrixReal;
> and in various online calculators i get
> [  2.472715991745  3.680743681735 -3.831392002314 ]
> [ -4.673105249083 -5.348238625096 -5.703193038649 ]
> [  2.733966489601 -6.567940452290 -5.936617926811 ]

> using python , numpy and linalg.inv (or linalg.pinv) i get  a divergent answer
> [[  6.79611151e+07   1.01163031e+08   1.05303510e+08]
>   [  1.01163057e+08   1.50585545e+08   1.56748838e+08]
>   [  1.05303548e+08   1.56748831e+08   1.63164381e+08]]

Please demonstrate with code::

     >>> m = np.mat([[ 0.01643777,-0.13539939, 0.11946689],[
         0.12479926, 0.01210898,-0.09217618 ],[-0.13050087,
         0.07575163, 0.01144993]])
     >>> m.I
     matrix([[ -2.60023901e+08,  -3.87056678e+08,  -4.02898472e+08],
             [ -3.87056814e+08,  -5.76150592e+08,  -5.99731775e+08],
             [ -4.02898597e+08,  -5.99731775e+08,  -6.24278108e+08]])

Thank you,
Alan Isaac




More information about the NumPy-Discussion mailing list