Post Reply 
[WP-34S] DEG and RAD - diffs
06-07-2014, 01:46 AM (This post was last modified: 06-07-2014 01:49 AM by Claudio L..)
Post: #30
RE: [WP-34S] DEG and RAD - diffs
(06-06-2014 10:53 PM)Paul Dale Wrote:  
(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

You'r right, that term won't lose precision.

I looked at my code, and here's where I was losing digits:

// COMPUTE ACOS(X) = ATAN2(SQRT(1-X^2),X)

when x~1 (ACOS(X)~0) I couldn't get all the digits right (this is when the sqrt() brings your digits back).

I should double check my posts, but I don't always have my devel machine with me to look at the code.

Claudio
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
[WP-34S] DEG and RAD - diffs - pito - 06-05-2014, 12:08 AM
RE: DEG and RAD - diffs - Paul Dale - 06-05-2014, 12:53 AM
RE: DEG and RAD - diffs - pito - 06-05-2014, 06:27 AM
RE: [WP-34S] DEG and RAD - diffs - pito - 06-05-2014, 01:38 PM
RE: [WP-34S] DEG and RAD - diffs - Dieter - 06-05-2014, 11:12 AM
RE: [WP-34S] DEG and RAD - diffs - pito - 06-05-2014, 06:04 PM
RE: [WP-34S] DEG and RAD - diffs - pito - 06-05-2014, 07:57 PM
RE: [WP-34S] DEG and RAD - diffs - pito - 06-05-2014, 10:07 PM
RE: [WP-34S] DEG and RAD - diffs - Dieter - 06-06-2014, 05:27 PM
RE: [WP-34S] DEG and RAD - diffs - Claudio L. - 06-07-2014 01:46 AM
RE: [WP-34S] DEG and RAD - diffs - pito - 06-07-2014, 12:57 PM



User(s) browsing this thread: 1 Guest(s)