ftp.nice.ch/pub/next/developer/hardware/m68k/libjv.1.0.N.s.tar.gz#/libjv/tan.c

This is tan.c in view mode; [Download] [Up]

static double pid4= 0.7853981633974483096;
static double pid2= 1.5707963267948966192;
static double pi  = 3.1415926535897932384;

double tan(x)
double x;
{
/*
	Routine for the tangent. It puts x in the range 0-pi/4.
	Then it uses a 6,6 Maehly approximation.
	Derived and coded by J.A.M.Vermaseren 21-apr-1992.
*/
	double fmod(),sum,x2;
	int sflag, pflag;

	if ( x < 0 ) { sflag = 1; x = -x; }
	else sflag = 0;
	if ( x >= pi ) x = fmod(x,pi);
	if ( x >= pid2 ) { x = pi - x; sflag = 1 - sflag; }
	if ( x > pid4 ) { pflag = 1; x = pid2 - x; }
	else pflag = 0;
	x2 = x*x;
	sum = x*(-4797.60570220792587597407+x2*(
               615.45028715821815261900+x2*(
               -13.46133040142504243340+x2*
                 0.03590005535592163977)))/(
             -4797.60570220792579574817+x2*(
              2214.65218789418096945538+x2*(
              -111.99796607144895992639+x2)));
	if ( pflag ) sum = 1./sum;
	if ( sflag ) return(-sum);
	else return(sum);
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.