Complex arg-trig functions
Stephen Montgomery-Smith
stephen at missouri.edu
Tue Aug 14 16:08:46 UTC 2012
On 08/14/2012 05:46 AM, Bruce Evans wrote:
> On Mon, 13 Aug 2012, Stephen Montgomery-Smith wrote:
>
>>
>> if (sqrt_huge+x>one && sqrt_huge+y>one)
>
> x and y can be DBL_MAX, giving overflow.
Why? When x is DBL_MAX, sqrt_huge is so very much smaller than DBL_MAX
that DBL_MAX+sqrt_huge should be DBL_MAX within floating point
precision. So no overflow.
>>>> @ if (ISFINITE(bx) && ISFINITE(by) && (x > RECIP_SQRT_EPSILON_100
>>>> || y > RECIP_SQRT_EPSILON_100)) {
>
> since if bx or by is NaN, then it isn't > RECIP_SQRT_EPSILON_100, and
> if it is Inf then I think handling it the same as DBL_MAX gives the
> correct result.
My original code did this. But for some reason, it didn't work in all
cases. I didn't take note of which cases failed.
> NaNs and Infs now fall through to do_hard_work().
> Wouldn't it be easier to never pass them to do_hard_work()?
It seemed to me that there is a logic behind why the the infs and nans
produce the results they do. I noticed that do_the_hard_work() already
got the answers correct for the real part *rx. Getting the imaginary
part to work as well seemed to me to be the cleanest way to make it
work. (I added all the nan and inf checking after writing the rest of
the code.)
>
> For just setting inexact, try an expression using `tiny'. There are
> many examples to choose from. According to $(grep tiny.*inex *.c):
If you still judge my solution incorrect, then I will look into these
different solutions.
More information about the freebsd-numerics
mailing list