On Nov 3, 3:48 pm, Martin Eisenberg <martin.eisenb
...@udo.edu> wrote:
> Thomas M. Hermann wrote:
> > On Nov 2, 10:30 am, Peter Seibel <peter.sei
...@gmail.com> wrote:
> >> probs[i] = probs[i] * (1 - prob)
> > Convert this line to :
> > probs[i] = probs[i] - probs[i] * prob
> >> probs[i] = probs[i] / (1 - prob)
> > Convert this line to :
> > probs[i] = probs[i] * (1 + prob) / (1 - prob*prob)
> > The little experiment I ran indicated that the roundoff errors
> > should cancel out with those modification.
> Is that transformation in the lore or has anyone written about it?
> Martin
> --
> Quidquid latine scriptum est, altum videtur.
It just something I came up with be devising a little, flawed,
experiment in javascript. I ran it on
http://www.arachnoid.com/javascript/interactiveJavaScript.html It started like this.
function roundoff_error(exact,approximate) {
return Math.abs( approximate/exact - 1.0 );
}
function foo(x,y) {
return x/(1-y);
}
function bar(x,y) {
return x*(1-y);
}
function main()
{
x=0.1;
y=0.2;
print("Roundoff error : " + roundoff_error(x,foo(bar(x,y),y)));
}
And the output was
Roundoff error : 2.220446049250313e-16
I think I got the idea for playing algebraic games from mucking around
in BLAS code or maybe it was something I read, regardless, I played
around with the equations until I found something that didn't exhibit
roundoff error for various x and y. The result was:
function foo(x,y)
{
return x*(1+y)/(1-y*y);
}
function bar(x,y)
{
return x-x*y;
}
I didn't want to spend a great deal of time verifying this, so I
didn't try a great number of inputs. In the process of writing this
reply, I just checked x=0.1 and y=0.22 which resulted in a roundoff
error of 1.1102230246251565e-16.
I didn't do anything formal, I was just doing a quick experiment with
some algebraic manipulation. Obviously, the quick adjective should be
replaced with flawed.
Tom H.