k_tanf.c revision 152766
12116Sjkh/* k_tanf.c -- float version of k_tan.c 22116Sjkh * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 32116Sjkh */ 42116Sjkh 52116Sjkh/* 62116Sjkh * ==================================================== 7129981Sdas * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved. 82116Sjkh * 92116Sjkh * Permission to use, copy, modify, and distribute this 108870Srgrimes * software is freely granted, provided that this notice 112116Sjkh * is preserved. 122116Sjkh * ==================================================== 132116Sjkh */ 142116Sjkh 15152647Sbde#ifndef INLINE_KERNEL_TANF 162116Sjkh#ifndef lint 1750476Speterstatic char rcsid[] = "$FreeBSD: head/lib/msun/src/k_tanf.c 152766 2005-11-24 13:48:40Z bde $"; 182116Sjkh#endif 19152647Sbde#endif 202116Sjkh 212116Sjkh#include "math.h" 222116Sjkh#include "math_private.h" 23152343Sbde 24152741Sbde/* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */ 25152713Sbdestatic const double 262116SjkhT[] = { 27152741Sbde 0x15554d3418c99f.0p-54, /* 0.333331395030791399758 */ 28152741Sbde 0x1112fd38999f72.0p-55, /* 0.133392002712976742718 */ 29152741Sbde 0x1b54c91d865afe.0p-57, /* 0.0533812378445670393523 */ 30152741Sbde 0x191df3908c33ce.0p-58, /* 0.0245283181166547278873 */ 31152741Sbde 0x185dadfcecf44e.0p-61, /* 0.00297435743359967304927 */ 32152741Sbde 0x1362b9bf971bcd.0p-59, /* 0.00946564784943673166728 */ 332116Sjkh}; 342116Sjkh 35152647Sbde#ifdef INLINE_KERNEL_TANF 36152647Sbdeextern inline 37152647Sbde#endif 3897413Salfredfloat 39152713Sbde__kernel_tandf(double x, int iy) 402116Sjkh{ 41152766Sbde double z,r,w,s; 42152343Sbde 432116Sjkh z = x*x; 442116Sjkh w = z*z; 452116Sjkh /* Break x^5*(T[1]+x^2*T[2]+...) into 46152284Sbde * x^5*(T[1]+x^4*T[3]+x^8*T[5]) + 47152284Sbde * x^5*(x^2*(T[2]+x^4*T[4])) 482116Sjkh */ 49152766Sbde r = T[1]+w*(T[3]+w*T[5]) + z*(T[2]+w*T[4]); 502116Sjkh s = z*x; 51152766Sbde r = (x+s*T[0])+(s*z)*r; 52152766Sbde if(iy==1) return r; 53152766Sbde else return -1.0/r; 542116Sjkh} 55