#583 incorrect matrix inversion

closed
nobody
None
5
2004-07-16
2004-07-10
Anonymous
No

invert matrix mistake:

Maxima 5.9.0.9beta1 http://maxima.sourceforge.net
Using Lisp Kyoto Common Lisp GCL 2.6.2 (aka GCL)
Distributed under the GNU Public License. See the file
COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function
bug_report()
provides bug reporting information.
(%i1) matrix([1,0,0],[-.3,1,0],[0,-.3,1]);
[ 1 0 0 ]
[ ]
(%o1) [ - 0.3 1 0 ]
[ ]
[ 0 - 0.3 1 ]
(%i2) invert(%o1);
[ 1 0 0 ]
[ ]
(%o2) [ - 288387008 1 0 ]
[ ]
[ 288385392 - 288386992 1 ]
(%i3) %o1.%o2;
[
1 0 0 ]
[
]
(%o3) [ - 2.883870083E+8 1.0 0.0 ]
[
]
[ 3.749014944E+8 - 2.883869923E+8 1.0 ]

Discussion

  • Barton Willis
    Barton Willis
    2004-07-12

    Logged In: YES
    user_id=895922

    'invert' might work okay for big floats:

    (%i1) mbf : matrix([1,0,0],[-.3b0,1,0],[0,-.3b0,1])$
    (%i2) invert(mbf) . mbf;
    (%o2) MATRIX([1,0,0],[0.0B0,1,0],[0.0B0,0.0B0,1])

    As you observed, 'invert' is bad on doubles

    (%i3) mf : matrix([1,0,0],[-.3,1,0],[0,-.3,1])$
    (%i4) invert(mf) . mf;

    (%o4) MATRIX([1.0,0.0,0],[-2.838562723E+8,1.0,0],
    [3.690126848E+8,-2.838562563E+8,1])

    Yikes! look at this

    (%i5) mf : float(mf)$
    (%i6) invert(mf) . mf;

    (%o6) MATRIX([1.29999994926991,-
    1.299999695619457,0.99999954906586],
    [-1.299999019218249,1.299998596467495,-
    0.99999870356435],
    [1.299997700235895,-
    1.29999726057511,0.99999763259577])

    Barton

     
  • Raymond Toy
    Raymond Toy
    2004-07-12

    Logged In: YES
    user_id=28849

    Could this be a gcl problem?

    I get the expected results from clisp 2.33 and cmucl. (On
    Solaris):

    MATRIX([1,0,0],[0.3,1,0],[0.09,0.3,1])

    And the product is the identity matrix.

     
  • Raymond Toy
    Raymond Toy
    2004-07-16

    • status: open --> closed