[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Catastrophic Cancellation
From: |
A. Kalten |
Subject: |
Catastrophic Cancellation |
Date: |
Tue, 1 Jul 2008 17:50:10 -0400 |
Just to spread some awareness of the pitfalls of floating point
calculations, I urge everyone to try this simple test. At the
octave prompt enter:
x=-4e-8:1e-10:4e-8;
for i=1:length(x)
y(i)=(1-cos(x(i)))/x(i)/x(i);
endfor
plot(x,y)
Hopefully, the results should surprise, or even shock, you.
Also try rewriting the above function as: y(i)=1/x(i)/x(i)-cos(x(i))/x(i)/x(i)
For more info, the link is here:
http://www.cs.princeton.edu/introcs/lectures/9scientific.pdf
AK
- Catastrophic Cancellation,
A. Kalten <=
- Re: Catastrophic Cancellation, A. Kalten, 2008/07/02
- Re: Catastrophic Cancellation, Jordi GutiƩrrez Hermoso, 2008/07/02
- Re: Catastrophic Cancellation, Sergei Steshenko, 2008/07/02
- Re: Catastrophic Cancellation, A. Kalten, 2008/07/02
- Re: Catastrophic Cancellation, Sergei Steshenko, 2008/07/03
- Re: Catastrophic Cancellation, Rob Mahurin, 2008/07/03
- Re: Catastrophic Cancellation, Sergei Steshenko, 2008/07/04
Re: Catastrophic Cancellation, Francesco Potorti`, 2008/07/03