Re: Efficiency of math.h
From: *** T. Winter (***.Winter_at_cwi.nl)
Date: 02/26/04
- Next message: *** T. Winter: "Re: Efficiency of math.h"
- Previous message: nrk: "Re: strtoul bug (was Fibonacci number)"
- In reply to: E. Robert Tisdale: "Re: Efficiency of math.h"
- Next in thread: E. Robert Tisdale: "Re: Efficiency of math.h"
- Reply: E. Robert Tisdale: "Re: Efficiency of math.h"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 26 Feb 2004 00:38:27 GMT
In article <403D0A18.5030204@jpl.nasa.gov> E.Robert.Tisdale@jpl.nasa.gov writes:
> CBFalconer wrote:
...
> > Not if you want speed you don't.
> > With some slight trigonometry,
> > you should be able to convert cos(angle) into tan(angle).
> > Use this as input to an arctan(value) routine,
> > which can in turn be built in various ways.
> > One uses a leveled Tschebychev approximation over 0 to 1.
>
> Not if you want speed you don't.
>
> This method requires reading a bunch of high precision
> floating-point numbers from system memory
> which can actually require more time than computing
> Taylor coefficients in registers on-the-fly.
Yup, you are clueless.
1. Calculating Taylor coefficients on the fly requires division, which
is on most processors much slower than multiplication.
2. The number of coefficients required in a Tschebychev approximation is
less than the number of Taylor coefficients needed. For instance,
to get a good sine in double precision on [0, pi/2] you can use only
6 terms of the Tschebychev expansion of (sin(x)/x - 1). (This
formula to get good relative precision near x = 0.)
-- *** t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131 home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~***/
- Next message: *** T. Winter: "Re: Efficiency of math.h"
- Previous message: nrk: "Re: strtoul bug (was Fibonacci number)"
- In reply to: E. Robert Tisdale: "Re: Efficiency of math.h"
- Next in thread: E. Robert Tisdale: "Re: Efficiency of math.h"
- Reply: E. Robert Tisdale: "Re: Efficiency of math.h"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]