www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/22/03:22:37

Date: Sun, 22 Dec 1996 09:57:29 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: djgpp AT delorie DOT com
Subject: Re: Is DJGPP that efficient?
Message-ID: <Pine.SUN.3.91.961222095655.29376W-100000@is>
MIME-Version: 1.0

On Fri, 20 Dec 1996, Francois Charton wrote:

> for x between 0 and PI/2, cos(x) can be approximated by
> 
>   x2=x*x;
>   co=1.0+x2*(x2*0.03705 - 0.4967);
> 
> with over three decimal place precision
> 
> and by
>   x2=x*x;
>   co=1.0+x2*(-0.4999999963 + x2*(0.0416666418 + x2*(-0.0013888397 + 
> x2*(0.0000247609 - x2*0.0000002605))));
>  
> with over 8 decimal places (this one is actually the function that most 
> pocket calculators use)

If you only need 3 decimal places of accuracy, use a pre-computed table of
values.  Any serious general-purpose fp code cannot assume that the
argument is between 0 and PI/2, and most of the time of the library
functions is spent in the so-called argument reduction process (which
brings the argument to a narrow region around 0 where a simple
approximation can be used). 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019