13a8617a8SJordan K. Hubbard /* k_tanf.c -- float version of k_tan.c 23a8617a8SJordan K. Hubbard * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 33a8617a8SJordan K. Hubbard */ 43a8617a8SJordan K. Hubbard 53a8617a8SJordan K. Hubbard /* 63a8617a8SJordan K. Hubbard * ==================================================== 773fbb89dSDavid Schultz * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved. 83a8617a8SJordan K. Hubbard * 93a8617a8SJordan K. Hubbard * Permission to use, copy, modify, and distribute this 103a8617a8SJordan K. Hubbard * software is freely granted, provided that this notice 113a8617a8SJordan K. Hubbard * is preserved. 123a8617a8SJordan K. Hubbard * ==================================================== 133a8617a8SJordan K. Hubbard */ 143a8617a8SJordan K. Hubbard 154ce51209SBruce Evans #ifndef INLINE_KERNEL_TANF 163a8617a8SJordan K. Hubbard #ifndef lint 177f3dea24SPeter Wemm static char rcsid[] = "$FreeBSD$"; 183a8617a8SJordan K. Hubbard #endif 194ce51209SBruce Evans #endif 203a8617a8SJordan K. Hubbard 213a8617a8SJordan K. Hubbard #include "math.h" 223a8617a8SJordan K. Hubbard #include "math_private.h" 23e96c4fd9SBruce Evans 2416638b55SBruce Evans /* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */ 2594a5f9beSBruce Evans static const double 263a8617a8SJordan K. Hubbard T[] = { 2716638b55SBruce Evans 0x15554d3418c99f.0p-54, /* 0.333331395030791399758 */ 2816638b55SBruce Evans 0x1112fd38999f72.0p-55, /* 0.133392002712976742718 */ 2916638b55SBruce Evans 0x1b54c91d865afe.0p-57, /* 0.0533812378445670393523 */ 3016638b55SBruce Evans 0x191df3908c33ce.0p-58, /* 0.0245283181166547278873 */ 3116638b55SBruce Evans 0x185dadfcecf44e.0p-61, /* 0.00297435743359967304927 */ 3216638b55SBruce Evans 0x1362b9bf971bcd.0p-59, /* 0.00946564784943673166728 */ 333a8617a8SJordan K. Hubbard }; 343a8617a8SJordan K. Hubbard 354ce51209SBruce Evans #ifdef INLINE_KERNEL_TANF 364ce51209SBruce Evans extern inline 374ce51209SBruce Evans #endif 3859b19ff1SAlfred Perlstein float 3994a5f9beSBruce Evans __kernel_tandf(double x, int iy) 403a8617a8SJordan K. Hubbard { 4194a5f9beSBruce Evans double z,r,v,w,s; 423a8617a8SJordan K. Hubbard int32_t ix,hx; 43e96c4fd9SBruce Evans 443a8617a8SJordan K. Hubbard GET_FLOAT_WORD(hx,x); 45e96c4fd9SBruce Evans ix = hx&0x7fffffff; 463a8617a8SJordan K. Hubbard z = x*x; 473a8617a8SJordan K. Hubbard w = z*z; 483a8617a8SJordan K. Hubbard /* Break x^5*(T[1]+x^2*T[2]+...) into 49c01611e4SBruce Evans * x^5*(T[1]+x^4*T[3]+x^8*T[5]) + 50c01611e4SBruce Evans * x^5*(x^2*(T[2]+x^4*T[4])) 513a8617a8SJordan K. Hubbard */ 52c01611e4SBruce Evans r = T[1]+w*(T[3]+w*T[5]); 53c01611e4SBruce Evans v = z*(T[2]+w*T[4]); 543a8617a8SJordan K. Hubbard s = z*x; 5594a5f9beSBruce Evans r = z*s*(r+v); 563a8617a8SJordan K. Hubbard r += T[0]*s; 573a8617a8SJordan K. Hubbard w = x+r; 583a8617a8SJordan K. Hubbard if(iy==1) return w; 5994a5f9beSBruce Evans else return -1.0/w; 603a8617a8SJordan K. Hubbard } 61