New guy and programming problem

09012018, 04:28 PM
(This post was last modified: 09012018 04:35 PM by Thomas Klemm.)
Post: #30




RE: New guy and programming problem
(09012018 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 HP41C returns: 4.363323130e06 This result is correctly rounded to the last digit. Then we square the rounded number and get: 1.90385887367929969 × 10^11 The HP41C returns: 1.903858874e11 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 HP41C returns: 3.807717748e11 As we can see the HP41C rounds these intermediate results correctly. The problem with the cancelation when calculating \(1sin(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^21}{\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 »

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