New guy and programming problem
09-01-2018, 04:28 PM (This post was last modified: 09-01-2018 04:35 PM by Thomas Klemm.)
Post: #30
 Thomas Klemm Senior Member Posts: 1,804 Joined: Dec 2013
RE: New guy and programming problem
(09-01-2018 03:18 PM)sasa Wrote:  Even result is good enough, there is still too much trouble to get accurate result to the last significant digit with arguments near 90 degree.

For sin(0.00025°) WolframAlpha gives:

4.3633231299719786898764073194250596667396107572873548... × 10^-6

The HP-41C returns:

4.363323130e-06

This result is correctly rounded to the last digit.

Then we square the rounded number and get:

1.90385887367929969 × 10^-11

The HP-41C returns:

1.903858874e-11

Again the result is rounded correctly.

Last thing to do is to multiply the number by 2:

3.807717748 × 10^-11

Which is exactly what the HP-41C returns:

3.807717748e-11

As we can see the HP-41C rounds these intermediate results correctly.

The problem with the cancelation when calculating $$1-sin(x)$$ is not related to the accuracy of calculating $$sin(x)$$ for $$x$$ close to $$90°$$.

Similar to Albert's trick we can multiply $$\sqrt{1+x^2}-1$$ by $$\frac{\sqrt{1+x^2}+1}{\sqrt{1+x^2}+1}=1$$ and get:

\begin{align*} \sqrt{1+x^2}-1 &= \sqrt{1+x^2}-1 \cdot \frac{\sqrt{1+x^2}+1}{\sqrt{1+x^2}+1} \\ &= \frac{(\sqrt{1+x^2}-1)(\sqrt{1+x^2}+1)}{\sqrt{1+x^2}+1} \\ &= \frac{1+x^2-1}{\sqrt{1+x^2}+1} \\ &= \frac{x^2}{\sqrt{1+x^2}+1} \end{align*}

And again cancelation for small $$x$$ is avoided.
 « Next Oldest | Next Newest »

 Messages In This Thread New guy and programming problem - Skirmitch - 08-27-2017, 06:18 AM RE: New guy and programming problem - Dieter - 08-27-2017, 03:15 PM RE: New guy and programming problem - Gerson W. Barbosa - 08-27-2017, 05:12 PM RE: New guy and programming problem - Dieter - 08-27-2017, 05:43 PM RE: New guy and programming problem - Paul Dale - 08-27-2017, 11:12 PM RE: New guy and programming problem - Dieter - 08-28-2017, 06:13 PM RE: New guy and programming problem - Paul Dale - 08-29-2017, 04:22 AM RE: New guy and programming problem - Garth Wilson - 08-27-2017, 09:14 PM RE: New guy and programming problem - Vtile - 09-01-2018, 07:28 PM RE: New guy and programming problem - John Keith - 08-27-2017, 05:52 PM RE: New guy and programming problem - Dieter - 08-27-2017, 06:28 PM RE: New guy and programming problem - Gerson W. Barbosa - 08-27-2017, 06:03 PM RE: New guy and programming problem - Dieter - 08-27-2017, 06:11 PM RE: New guy and programming problem - Gerson W. Barbosa - 08-27-2017, 06:23 PM RE: New guy and programming problem - pier4r - 08-27-2017, 07:52 PM RE: New guy and programming problem - Jlouis - 08-28-2017, 10:55 AM RE: New guy and programming problem - Skirmitch - 08-27-2017, 06:04 PM RE: New guy and programming problem - Skirmitch - 08-28-2017, 01:44 AM RE: New guy and programming problem - Paul Dale - 08-28-2017, 01:58 AM RE: New guy and programming problem - Skirmitch - 08-28-2017, 02:25 AM RE: New guy and programming problem - Paul Dale - 08-28-2017, 05:31 AM RE: New guy and programming problem - Skirmitch - 08-28-2017, 07:14 AM RE: New guy and programming problem - ndzied1 - 08-28-2017, 03:43 AM RE: New guy and programming problem - Paul Dale - 08-28-2017, 07:28 AM RE: New guy and programming problem - Logan - 08-28-2017, 02:20 PM RE: New guy and programming problem - Skirmitch - 08-28-2017, 06:11 PM RE: New guy and programming problem - Logan - 08-28-2017, 06:13 PM RE: New guy and programming problem - Thomas Klemm - 09-01-2018, 12:23 PM RE: New guy and programming problem - Albert Chan - 09-01-2018, 02:16 PM RE: New guy and programming problem - Albert Chan - 09-02-2018, 06:14 PM RE: New guy and programming problem - Albert Chan - 09-02-2018, 09:21 PM RE: New guy and programming problem - sasa - 09-01-2018, 03:18 PM RE: New guy and programming problem - Albert Chan - 09-01-2018, 05:20 PM RE: New guy and programming problem - sasa - 09-01-2018, 05:33 PM RE: New guy and programming problem - Thomas Klemm - 09-01-2018 04:28 PM RE: New guy and programming problem - Thomas Klemm - 09-02-2018, 07:33 PM RE: New guy and programming problem - Thomas Klemm - 09-02-2018, 09:33 PM RE: New guy and programming problem - Vtile - 09-02-2018, 09:40 PM RE: New guy and programming problem - Albert Chan - 09-03-2018, 10:32 PM

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