<div dir="ltr">Forgot to mention that with the true value of n=0.82, this of course returns the correct solution:<br>(let ([n 0.82 #;(+ (* .9 .9)(* .1 .1))])<br> (matrix-solve<br> (matrix [[ 1 0 .9 1]<br> [ 0 1 .1 1]<br>
[.9 .1 n 1]<br> [ 1 1 1 0]])<br> (col-matrix [0 0 0 1])))<br>; -> (array #[#[0.38] #[0.4866666666666667] #[0.13333333333333333] #[-0.5]])<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, Apr 16, 2014 at 11:10 AM, Laurent <span dir="ltr"><<a href="mailto:laurent.orseau@gmail.com" target="_blank">laurent.orseau@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div><div>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):<br><br>(let ([n 0.8200000000000001 #;(+ (* .9 .9)(* .1 .1))])<br>
(matrix-solve<br> (matrix [[ 1 0 .9 1]<br> [ 0 1 .1 1]<br> [.9 .1 n 1]<br> [ 1 1 1 0]])<br> (col-matrix [0 0 0 1])))<br>; -> (array #[#[0.0] #[0.5] #[0.0] #[-0.5]])<br><br></div>
But clearly here M×X≠B, as is easily seen on the last row.<br></div>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.<br>
<br>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).<span class="HOEnZb"><font color="#888888"><br><br></font></span></div><span class="HOEnZb"><font color="#888888">Laurent<br>
</font></span></div>
</blockquote></div><br></div>