Jos van Kan (j.van...@math.tudelft.nl) wrote:
: Using your form one can obtain an accuracy of 0.0007 across the interval
: [-pi/2, pi/2] with
: cos (x) ~ 0.995 - 0.4995 x^2 + 0.0367 x^4
: If you program that straightforward
: function MyCos (x:real):real;
: begin
: x:= sqr(x);
: MyCos := 0.995 + x*(-0.4995 + 0.0367 * x)
: end;
: you achieve a speedup of a factor 3 with respect to the library cosine.
: (if you DONT use the 80x87, otherwise its only a factor 2)
: Maybe there's somewhat more to be gained by using integer arithmetic.
I store my arguments of the cosine as longints with
2^32 = pi,
0 = 0,
-(2^32) = -pi
So what would be the best implementation of the function above with
this representation of the argument?
Thanks in advance for any help.
--
=============================================================================
Dipl. Phys. Hans L. Trautenberg Universitaet Regensburg
Institut fuer Experimentelle und Angewandte Physik
phone (49) 941 943 2466 Polymerphysik
fax (49) 941 943 3196 D-93040 Regensburg
e-mail hans.trautenb...@physik.uni-regensburg.de Germany
privat
phone (49) 941 949211 Flurstr. 14
fax (49) 941 930792 D-92348 Berg
Germany
=============================================================================