Use of C99 extra long double math functions after r236148
Stephen Montgomery-Smith
stephen at missouri.edu
Sun Aug 12 23:04:08 UTC 2012
Bruce and I have continued a discussion at
http://www.freebsd.org/cgi/query-pr.cgi?pr=170206.
I sure wish we could have a mailing list like freebsd-numerics to have
these discussions. Then we could do things like change the subject
line, so that we didn't have to follow everything.
The idea of when you add a bunch of numbers that you start with the
smallest first - I can see that being effective when all the numbers
have the same signs. But I can also see it being quite disastrous when
the numbers have different signs.
I am trying to avoid "catastrophic loss of relative error" whereas you
guys all seem to be after that last little bit of ULP. I guess it is a
different mind set.
If you are adding four numbers that are all positive, and you fail to
add them from smallest to largest, the worst you will get is to increase
your ULP to something like 4.
But if you have numbers of different signs, like
-1, 1, 1e-100
you definitely want to add the numbers of largest absolute value before
you add the number with smallest absolute value. If you add from
smallest to largest (either in the absolute value sense, or in the
signed sense), you get a relative error of infinity.
That is what I mean by "catastrophic loss of relative error."
I remember having this long argument with Steve about how a ULP of 10
seemed just fine to me.
And for most applications, when you compute clog(z), and |z| is close to
1, but z is not close to one, almost always you are not going to know
the real and imaginary part of z exactly (it will be the result of some
other computation), and so the huge relative error in computing clog(z)
will represent a true lack of knowledge, not some artifact of the
computational method.
Indeed, that is why, even if I could compute clog(z) perfectly, I would
never use clog to compute casinh(z) using the formula
clog(z+csqrt(z*z+1)). This is because I also wouldn't have a good bound
on |z+sqrt(z*z+1)|-1.
All this talk about not wanting to be on the wrong part of the Riemann
surface just seems like you are living in dream land. You could always
come up with some kind of difficult analytic function for which near
perfect resolution is going to be made difficult. For example,
catanh(z) - I*PI/4
will never be calculable with good accuracy for |z| close to 1, unless
you write a very special function for it.
More information about the freebsd-numerics
mailing list