k_tanf.c revision 152766
1285101Semaste/* k_tanf.c -- float version of k_tan.c
2285101Semaste * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3285101Semaste */
4285101Semaste
5285101Semaste/*
6285101Semaste * ====================================================
7285101Semaste * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
8285101Semaste *
9285101Semaste * Permission to use, copy, modify, and distribute this
10285101Semaste * software is freely granted, provided that this notice
11285101Semaste * is preserved.
12285101Semaste * ====================================================
13285101Semaste */
14296417Sdim
15285101Semaste#ifndef INLINE_KERNEL_TANF
16285101Semaste#ifndef lint
17285101Semastestatic char rcsid[] = "$FreeBSD: head/lib/msun/src/k_tanf.c 152766 2005-11-24 13:48:40Z bde $";
18285101Semaste#endif
19285101Semaste#endif
20285101Semaste
21285101Semaste#include "math.h"
22285101Semaste#include "math_private.h"
23285101Semaste
24285101Semaste/* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */
25285101Semastestatic const double
26285101SemasteT[] =  {
27285101Semaste  0x15554d3418c99f.0p-54,	/* 0.333331395030791399758 */
28285101Semaste  0x1112fd38999f72.0p-55,	/* 0.133392002712976742718 */
29285101Semaste  0x1b54c91d865afe.0p-57,	/* 0.0533812378445670393523 */
30285101Semaste  0x191df3908c33ce.0p-58,	/* 0.0245283181166547278873 */
31285101Semaste  0x185dadfcecf44e.0p-61,	/* 0.00297435743359967304927 */
32285101Semaste  0x1362b9bf971bcd.0p-59,	/* 0.00946564784943673166728 */
33285101Semaste};
34285101Semaste
35285101Semaste#ifdef INLINE_KERNEL_TANF
36285101Semasteextern inline
37285101Semaste#endif
38285101Semastefloat
39285101Semaste__kernel_tandf(double x, int iy)
40285101Semaste{
41285101Semaste	double z,r,w,s;
42285101Semaste
43285101Semaste	z	=  x*x;
44285101Semaste	w 	=  z*z;
45285101Semaste    /* Break x^5*(T[1]+x^2*T[2]+...) into
46285101Semaste     *	  x^5*(T[1]+x^4*T[3]+x^8*T[5]) +
47285101Semaste     *	  x^5*(x^2*(T[2]+x^4*T[4]))
48285101Semaste     */
49285101Semaste	r = T[1]+w*(T[3]+w*T[5]) + z*(T[2]+w*T[4]);
50285101Semaste	s = z*x;
51285101Semaste	r = (x+s*T[0])+(s*z)*r;
52285101Semaste	if(iy==1) return r;
53285101Semaste	else return -1.0/r;
54285101Semaste}
55285101Semaste