[WP-34S] DEG and RAD - diffs
06-06-2014, 10:53 PM
Post: #29
 Paul Dale Senior Member Posts: 1,757 Joined: Dec 2013
RE: [WP-34S] DEG and RAD - diffs
(06-06-2014 07:53 PM)Claudio L. Wrote:  Also, when x is close to zero, doing sqrt(1+x^2) is really bad for precision. The x^2 "spreads" your useful digits throughout your exponent range, then the square root compresses them back, and you lost about half of them at the end (see what I meant with "small angles are tougher on precision loss").

Huh??

For z near one, $$\sqrt{z}$$ is always closer to one than z is. So yes, you will lose some least significant digits but the result is accurate within your working precision. Hence, $$\sqrt{1+x^2}$$ for small x has no accuracy problems by itself, the answer will approach unity much faster than x approaches zero.

If, on the other hand, you have something along the lines of $$\sqrt{1+x^2}-1$$, then the story is completely different. Here, there is a cancellation of digits and loss of precision due to the $$-1$$. However, these situations are rarely insurmountable. In this case, I'd use the transformation (assuming my algebra is good):

$$\sqrt{1+x^2}-1 = \frac{x^2}{\sqrt{1+x^2}+1}$$

which doesn't involve any cancellation. The actual transformation required will depend on the exact formula being evaluated of course.

- Pauli
 « Next Oldest | Next Newest »