HP 35S: Hyperbolics Bug?

07242015, 10:45 AM
Post: #1




HP 35S: Hyperbolics Bug?
Do the hyperbolic functions suffer from similar inaccuracy near certain critical values as do the trig functions?


07242015, 11:14 AM
Post: #2




RE: HP 35S: Hyperbolics Bug?  
07242015, 11:27 AM
Post: #3




RE: HP 35S: Hyperbolics Bug?
It would be surprising. The hyperbolics don't have the same nasty cases as the circular trigonometric functions. There are still concerns but they aren't so insidious as with the circular functions.
The näive formula for \( cosh(x) = \frac{e^x + e^{x}}{2} \) is stable across the entire domain. The näive formula for \( sinh(x) = \frac{e^x  e^{x}}{2} \) isn't. It encounters cancellation issues as x > 0. This would be the place I'd go hunting for accuracy loss both for sinh and tanh. The 34S uses \( sinh(x) = \frac{(e^x  1)(e^x + 1)}{2 e^x}, x < \frac{1}{2} \) which is stable so long as the accurate builtin function for \( e^x  1 \) is used. Outside of this domain, the näive formula works fine. Tanh can be expressed as \( \frac{sinh}{cosh} \), however the 34S uses the alternative \( tanh(x) = \frac{e^{2x}1}{e^{2x}+1} = \frac{e^{2x}1}{e^{2x}1 + 2} \) which is more stable but does risk overflow for large x. For the inverse hyperbolic functions, \( cosh^{1}(x) = log \left( x + \sqrt{x^2+1} \right) \) is straightforward again. Arcsinh and arctanh require some care for x near zero. They can be stably calculated with the use of the \( ln1p(x) = ln(1 + x) \) function: \[ \\sinh^{1}(x) = ln1p \left( x \left(1 + \frac{x}{\sqrt{x^2+1}+1} \right) \right)\\ \\tanh^{1}(x) = \frac{ln1p \left( \frac{2x}{1x} \right)}{2} \] Assuming I got all of the formulas correct  Pauli 

07242015, 12:14 PM
(This post was last modified: 07252015 04:23 AM by Marcio.)
Post: #4




RE: HP 35S: Hyperbolics Bug?
(07242015 11:27 AM)Paul Dale Wrote: It would be surprising. The hyperbolics don't have the same nasty cases as the circular trigonometric functions. There are still concerns but they aren't so insidious as with the circular functions. If I remember correctly, I played with these functions quite a bit a while ago and couldn't find any loss of accuracy inside the working limits of the 35s. It seems the loss of precision pops up when you use complex numbers to calculate SIN or COS:. \[ cos(x) = \frac{e^{ix} + e^{ix}}{2} \] Even so, in order for this problem to appear, the argument must be really small (for example, 1E7) and the result multiplied by its inverse (1E7). Marcio 

07242015, 01:22 PM
Post: #5




RE: HP 35S: Hyperbolics Bug?
(07242015 10:45 AM)Gerald H Wrote: Do the hyperbolic functions suffer from similar inaccuracy near certain critical values as do the trig functions? TANH(x) for 30000 <= x produces an OVERFLOW but gives 1 as a result. Cheers Thomas 

07242015, 01:33 PM
(This post was last modified: 07242015 01:51 PM by Marcio.)
Post: #6




RE: HP 35S: Hyperbolics Bug?
The overflow message is wrong but the result is right, that is bug 13, which also mentions that SINH and COSH will return incorrect results for large values. Would anybody be kind enough as to provide some examples?
Thanks Marcio 

07242015, 03:57 PM
Post: #7




RE: HP 35S: Hyperbolics Bug?
(07242015 01:33 PM)Marcio Wrote: Would anybody be kind enough as to provide some examples? SINH 25000 = OVERFLOW > 1E500 SINH 30000 = OVERFLOW  >3E499 Quote:What seems to happen when the argument is greater than 29999.999... is that the the mantissa is kept and the characteristic is changed to 499. 

07242015, 04:49 PM
(This post was last modified: 07252015 04:24 AM by Marcio.)
Post: #8




RE: HP 35S: Hyperbolics Bug?
(07242015 03:57 PM)Thomas Klemm Wrote:(07242015 01:33 PM)Marcio Wrote: Would anybody be kind enough as to provide some examples? I think this one is a bit common. The Prime will output similar results. Powerful computing environments such as MATLAB and others will return 'infinity' as a result, which might be what the 35s is trying to do here. 

07252015, 04:22 AM
Post: #9




RE: HP 35S: Hyperbolics Bug?  
« Next Oldest  Next Newest »

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