[racket] matrix-solve and approximation errors

From: Laurent (laurent.orseau at gmail.com)
Date: Wed Apr 16 05:10:26 EDT 2014

I've just been bitten by a bad case of floating-point error with
`matrix-solve` (and a bad CPU that has some floating-point issues):

(let ([n 0.8200000000000001 #;(+ (* .9 .9)(* .1 .1))])
  (matrix-solve
   (matrix [[ 1  0 .9 1]
            [ 0  1 .1 1]
            [.9 .1  n 1]
            [ 1  1  1 0]])
   (col-matrix [0 0 0 1])))
; -> (array #[#[0.0] #[0.5] #[0.0] #[-0.5]])

But clearly here M×X≠B, as is easily seen on the last row.
I've seen other situations where the approximation leads to an approximate
solution (which is okay of course), but this is the first case I see where
the result is completely off.

I have no idea if anything can be done about it, though (apart from
throwing my computer through the window and buy a better one).

Laurent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140416/f674a18c/attachment.html>

Posted on the users mailing list.