k_tanf.c revision 152870
12116Sjkh/* k_tanf.c -- float version of k_tan.c 22116Sjkh * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3152870Sbde * Optimized by Bruce D. Evans. 42116Sjkh */ 52116Sjkh 62116Sjkh/* 72116Sjkh * ==================================================== 8129981Sdas * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved. 92116Sjkh * 102116Sjkh * Permission to use, copy, modify, and distribute this 118870Srgrimes * software is freely granted, provided that this notice 122116Sjkh * is preserved. 132116Sjkh * ==================================================== 142116Sjkh */ 152116Sjkh 16152870Sbde#ifndef INLINE_KERNEL_TANDF 172116Sjkh#ifndef lint 1850476Speterstatic char rcsid[] = "$FreeBSD: head/lib/msun/src/k_tanf.c 152870 2005-11-28 05:35:32Z bde $"; 192116Sjkh#endif 20152647Sbde#endif 212116Sjkh 222116Sjkh#include "math.h" 232116Sjkh#include "math_private.h" 24152343Sbde 25152741Sbde/* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */ 26152713Sbdestatic const double 272116SjkhT[] = { 28152741Sbde 0x15554d3418c99f.0p-54, /* 0.333331395030791399758 */ 29152741Sbde 0x1112fd38999f72.0p-55, /* 0.133392002712976742718 */ 30152741Sbde 0x1b54c91d865afe.0p-57, /* 0.0533812378445670393523 */ 31152741Sbde 0x191df3908c33ce.0p-58, /* 0.0245283181166547278873 */ 32152741Sbde 0x185dadfcecf44e.0p-61, /* 0.00297435743359967304927 */ 33152741Sbde 0x1362b9bf971bcd.0p-59, /* 0.00946564784943673166728 */ 342116Sjkh}; 352116Sjkh 36152870Sbde#ifdef INLINE_KERNEL_TANDF 37152647Sbdeextern inline 38152647Sbde#endif 3997413Salfredfloat 40152713Sbde__kernel_tandf(double x, int iy) 412116Sjkh{ 42152766Sbde double z,r,w,s; 43152343Sbde 442116Sjkh z = x*x; 452116Sjkh w = z*z; 462116Sjkh /* Break x^5*(T[1]+x^2*T[2]+...) into 47152284Sbde * x^5*(T[1]+x^4*T[3]+x^8*T[5]) + 48152284Sbde * x^5*(x^2*(T[2]+x^4*T[4])) 492116Sjkh */ 50152870Sbde r = (T[1]+w*(T[3]+w*T[5])) + z*(T[2]+w*T[4]); 512116Sjkh s = z*x; 52152766Sbde r = (x+s*T[0])+(s*z)*r; 53152766Sbde if(iy==1) return r; 54152766Sbde else return -1.0/r; 552116Sjkh} 56