help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Same .m file: different results with different versions of Octave


From: Judd Storrs
Subject: Re: Same .m file: different results with different versions of Octave
Date: Wed, 21 Apr 2010 18:48:21 -0400

On Wed, Apr 21, 2010 at 2:20 PM, Judd Storrs <address@hidden> wrote:
> Here's an updated patch and c99 test code for the bug that was
> reported. I removed the pre-determined threshold and instead check for
> overflow of den but only for the real component, the same code works

Ok, final tweak:

Re[tanh(a+bi)] = sinh(a)*cosh(a) / (sinh(a)^2 + cos(b)^2)

The previous patch assumed that (sinh(a)^2 + cos(b)^2) overflows
before sinh(a)*cosh(a). Theoretically the numerator will overflow
before the denominator for some values of b. This is because |sinh(x)|
< |cosh(x)|. If cos(b)^2 happens to be zero, then the numerator should
be expected to overflow first. Both have to be tested because if
cos(b)^2 == 1 then the denominator should be expected to overflow
first (because |tanh(a+0i)| =< 1).

Some guesstimating indicates that to get this to actually happen for
any floating point number would require something near 256-bit
floating point if everything else is perfect. In any case it's an easy
fix and doesn't affect runtime (at least not that I can measure).


--judd

Attachment: glibc-ctanh-5.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]