Re: Efficiency of math.h

From: Christian Bau (christian.bau_at_cbau.freeserve.co.uk)
Date: 02/26/04


Date: Thu, 26 Feb 2004 07:53:38 +0000

In article <403D3050.9060709@jpl.nasa.gov>,
 "E. Robert Tisdale" <E.Robert.Tisdale@jpl.nasa.gov> wrote:

> Christian Bau wrote:
>
> > The fastest approach would be to split the argument range into two
> > parts, abs(x) <= c and abs(x) >= c for some suitably chosen c,
> > probably somewhere around 0.7 or 0.8. For abs (x) <= c, approximate acos
> > x by a polynomial of the form (pi - ax - bx^3 - cx^5...). For x > c,
> > define f(z) = acos(1 - z^2). Approximate f(z) by a polynomial of the
> > form ax + bx^3 + cx^5 + dx^7. Calculate acos(x) = f(sqrt(1 - x)).
> > For x < -c use acos(x) = pi() - acos(-x) = pi() - f(sqrt(1 + x)).
> > Take a higher polynomial depending on how much precision you want.
> > Finding the coefficients is left as an exercise to the reader :)
> >
> > The substitution z = sqrt(1-x) nicely catches the behavior of acos x
> > for abs(x) close to 1, where the first derivative is unbounded
> > and avoids excessive rounding errors.
>
> Have you every implemented and tested this "algorithm"?
> If so please publish it here so that we can "benchmark" it
> against our C library implementations of acos. I'll bet you $1.00 that
> I can find one that beats your implementation.

Just recently I read something about the typical troll's methods: Demand
documentation, references, everything from others. Always refuse to
provide the same yourself.

So you ask me to invest considerable amount of time to implement an
algorithm for acos, then you do a web search, and all for one dollar?
***.

Lets do it the other way round: You publish ANY implementation of acos
in C, and I bet you UK?20,000 that I can beat it. I have a Macintosh at
home, so we will run speed tests on a PowerPC with a Macintosh G4, using
CodeWarrior 7 for MacOS as the compiler. 64 bit double precision, error
less than 1ulp for the whole range are required, so the only thing to be
measured is speed.

Twenthy thousand pounds makes it worth my while, hurts you enough, and I
am quite confident that I can beat anything you can find.