xref: /csrg-svn/lib/libm/common_source/j1.c (revision 64990)
148402Sbostic /*-
261308Sbostic  * Copyright (c) 1992, 1993
361308Sbostic  *	The Regents of the University of California.  All rights reserved.
448402Sbostic  *
557151Sbostic  * %sccs.include.redist.c%
634118Sbostic  */
734118Sbostic 
824598Szliu #ifndef lint
9*64990Smckusick static char sccsid[] = "@(#)j1.c	8.2 (Berkeley) 11/30/93";
1034118Sbostic #endif /* not lint */
1124598Szliu 
1224598Szliu /*
1357151Sbostic  * 16 December 1992
1457151Sbostic  * Minor modifications by Peter McIlroy to adapt non-IEEE architecture.
1557151Sbostic  */
1624598Szliu 
1757151Sbostic /*
1857151Sbostic  * ====================================================
1957151Sbostic  * Copyright (C) 1992 by Sun Microsystems, Inc.
2057151Sbostic  *
2157151Sbostic  * Developed at SunPro, a Sun Microsystems, Inc. business.
2257151Sbostic  * Permission to use, copy, modify, and distribute this
2357151Sbostic  * software is freely granted, provided that this notice
2457151Sbostic  * is preserved.
2557151Sbostic  * ====================================================
2657151Sbostic  *
2757151Sbostic  * ******************* WARNING ********************
2857151Sbostic  * This is an alpha version of SunPro's FDLIBM (Freely
2957151Sbostic  * Distributable Math Library) for IEEE double precision
3057151Sbostic  * arithmetic. FDLIBM is a basic math library written
3157151Sbostic  * in C that runs on machines that conform to IEEE
3257151Sbostic  * Standard 754/854. This alpha version is distributed
3357151Sbostic  * for testing purpose. Those who use this software
3457151Sbostic  * should report any bugs to
3557151Sbostic  *
3657151Sbostic  *		fdlibm-comments@sunpro.eng.sun.com
3757151Sbostic  *
3857151Sbostic  * -- K.C. Ng, Oct 12, 1992
3957151Sbostic  * ************************************************
4057151Sbostic  */
4124598Szliu 
4257151Sbostic /* double j1(double x), y1(double x)
4357151Sbostic  * Bessel function of the first and second kinds of order zero.
4457151Sbostic  * Method -- j1(x):
4557151Sbostic  *	1. For tiny x, we use j1(x) = x/2 - x^3/16 + x^5/384 - ...
4657151Sbostic  *	2. Reduce x to |x| since j1(x)=-j1(-x),  and
4757151Sbostic  *	   for x in (0,2)
4857151Sbostic  *		j1(x) = x/2 + x*z*R0/S0,  where z = x*x;
4957151Sbostic  *	   (precision:  |j1/x - 1/2 - R0/S0 |<2**-61.51 )
5057151Sbostic  *	   for x in (2,inf)
5157151Sbostic  * 		j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x1)-q1(x)*sin(x1))
5257151Sbostic  * 		y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
5357151Sbostic  * 	   where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
5457151Sbostic  *	   as follows:
5557151Sbostic  *		cos(x1) =  cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
5657151Sbostic  *			=  1/sqrt(2) * (sin(x) - cos(x))
5757151Sbostic  *		sin(x1) =  sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
5857151Sbostic  *			= -1/sqrt(2) * (sin(x) + cos(x))
5957151Sbostic  * 	   (To avoid cancellation, use
6057151Sbostic  *		sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
6157151Sbostic  * 	    to compute the worse one.)
6257151Sbostic  *
6357151Sbostic  *	3 Special cases
6457151Sbostic  *		j1(nan)= nan
6557151Sbostic  *		j1(0) = 0
6657151Sbostic  *		j1(inf) = 0
6757151Sbostic  *
6857151Sbostic  * Method -- y1(x):
6957151Sbostic  *	1. screen out x<=0 cases: y1(0)=-inf, y1(x<0)=NaN
7057151Sbostic  *	2. For x<2.
7157151Sbostic  *	   Since
7257151Sbostic  *		y1(x) = 2/pi*(j1(x)*(ln(x/2)+Euler)-1/x-x/2+5/64*x^3-...)
7357151Sbostic  *	   therefore y1(x)-2/pi*j1(x)*ln(x)-1/x is an odd function.
7457151Sbostic  *	   We use the following function to approximate y1,
7557151Sbostic  *		y1(x) = x*U(z)/V(z) + (2/pi)*(j1(x)*ln(x)-1/x), z= x^2
7657151Sbostic  *	   where for x in [0,2] (abs err less than 2**-65.89)
7757151Sbostic  *		U(z) = u0 + u1*z + ... + u4*z^4
7857151Sbostic  *		V(z) = 1  + v1*z + ... + v5*z^5
7957151Sbostic  *	   Note: For tiny x, 1/x dominate y1 and hence
8057151Sbostic  *		y1(tiny) = -2/pi/tiny, (choose tiny<2**-54)
8157151Sbostic  *	3. For x>=2.
8257151Sbostic  * 		y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
8357151Sbostic  * 	   where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
8457151Sbostic  *	   by method mentioned above.
8557151Sbostic  */
8624598Szliu 
8757151Sbostic #include <math.h>
8857151Sbostic #include <float.h>
8924598Szliu 
9057151Sbostic #if defined(vax) || defined(tahoe)
9157151Sbostic #define _IEEE	0
9257151Sbostic #else
9357151Sbostic #define _IEEE	1
9457151Sbostic #define infnan(x) (0.0)
9557151Sbostic #endif
9624598Szliu 
9757151Sbostic static double pone(), qone();
9824598Szliu 
9957151Sbostic static double
10057151Sbostic huge    = 1e300,
10157151Sbostic zero    = 0.0,
10257151Sbostic one	= 1.0,
10357151Sbostic invsqrtpi= 5.641895835477562869480794515607725858441e-0001,
10457151Sbostic tpi	= 0.636619772367581343075535053490057448,
10524598Szliu 
10657151Sbostic 	/* R0/S0 on [0,2] */
10757151Sbostic r00 =  -6.250000000000000020842322918309200910191e-0002,
10857151Sbostic r01 =   1.407056669551897148204830386691427791200e-0003,
10957151Sbostic r02 =  -1.599556310840356073980727783817809847071e-0005,
11057151Sbostic r03 =   4.967279996095844750387702652791615403527e-0008,
11157151Sbostic s01 =   1.915375995383634614394860200531091839635e-0002,
11257151Sbostic s02 =   1.859467855886309024045655476348872850396e-0004,
11357151Sbostic s03 =   1.177184640426236767593432585906758230822e-0006,
11457151Sbostic s04 =   5.046362570762170559046714468225101016915e-0009,
11557151Sbostic s05 =   1.235422744261379203512624973117299248281e-0011;
11624598Szliu 
11757151Sbostic #define two_129	6.80564733841876926e+038	/* 2^129 */
11857151Sbostic #define two_m54	5.55111512312578270e-017	/* 2^-54 */
j1(x)11957151Sbostic double j1(x)
12057151Sbostic 	double x;
12157151Sbostic {
12257151Sbostic 	double z, s,c,ss,cc,r,u,v,y;
12357151Sbostic 	y = fabs(x);
12457151Sbostic 	if (!finite(x))			/* Inf or NaN */
12557151Sbostic 		if (_IEEE && x != x)
12657151Sbostic 			return(x);
12757151Sbostic 		else
12857151Sbostic 			return (copysign(x, zero));
12957151Sbostic 	y = fabs(x);
13057151Sbostic 	if (y >= 2)			/* |x| >= 2.0 */
13157151Sbostic 	{
13257151Sbostic 		s = sin(y);
13357151Sbostic 		c = cos(y);
13457151Sbostic 		ss = -s-c;
13557151Sbostic 		cc = s-c;
13657151Sbostic 		if (y < .5*DBL_MAX) {  	/* make sure y+y not overflow */
13757151Sbostic 		    z = cos(y+y);
13857151Sbostic 		    if ((s*c)<zero) cc = z/ss;
13957151Sbostic 		    else 	    ss = z/cc;
14057151Sbostic 		}
14157151Sbostic 	/*
14257151Sbostic 	 * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x)
14357151Sbostic 	 * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x)
14457151Sbostic 	 */
14557151Sbostic #if !defined(vax) && !defined(tahoe)
14657151Sbostic 		if (y > two_129)	 /* x > 2^129 */
14757151Sbostic 			z = (invsqrtpi*cc)/sqrt(y);
14857151Sbostic 		else
14957151Sbostic #endif /* defined(vax) || defined(tahoe) */
15057151Sbostic 		{
15157151Sbostic 		    u = pone(y); v = qone(y);
15257151Sbostic 		    z = invsqrtpi*(u*cc-v*ss)/sqrt(y);
15357151Sbostic 		}
15457151Sbostic 		if (x < 0) return -z;
15557151Sbostic 		else  	 return  z;
15657151Sbostic 	}
15757151Sbostic 	if (y < 7.450580596923828125e-009) {	/* |x|<2**-27 */
15857151Sbostic 	    if(huge+x>one) return 0.5*x;/* inexact if x!=0 necessary */
15957151Sbostic 	}
16057151Sbostic 	z = x*x;
16157151Sbostic 	r =  z*(r00+z*(r01+z*(r02+z*r03)));
16257151Sbostic 	s =  one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05))));
16357151Sbostic 	r *= x;
16457151Sbostic 	return (x*0.5+r/s);
16557151Sbostic }
16624598Szliu 
16757151Sbostic static double u0[5] = {
16857151Sbostic   -1.960570906462389484206891092512047539632e-0001,
16957151Sbostic    5.044387166398112572026169863174882070274e-0002,
17057151Sbostic   -1.912568958757635383926261729464141209569e-0003,
17157151Sbostic    2.352526005616105109577368905595045204577e-0005,
17257151Sbostic    -9.190991580398788465315411784276789663849e-0008,
17357151Sbostic };
17457151Sbostic static double v0[5] = {
17557151Sbostic    1.991673182366499064031901734535479833387e-0002,
17657151Sbostic    2.025525810251351806268483867032781294682e-0004,
17757151Sbostic    1.356088010975162198085369545564475416398e-0006,
17857151Sbostic    6.227414523646214811803898435084697863445e-0009,
17957151Sbostic    1.665592462079920695971450872592458916421e-0011,
18057151Sbostic };
18135679Sbostic 
y1(x)18257151Sbostic double y1(x)
18357151Sbostic 	double x;
18457151Sbostic {
185*64990Smckusick 	double z, s, c, ss, cc, u, v;
18657151Sbostic     /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */
18757151Sbostic 	if (!finite(x))
18857151Sbostic 		if (!_IEEE) return (infnan(EDOM));
18957151Sbostic 		else if (x < 0)
19057151Sbostic 			return(zero/zero);
19157151Sbostic 		else if (x > 0)
19257151Sbostic 			return (0);
19357151Sbostic 		else
19457151Sbostic 			return(x);
19557151Sbostic 	if (x <= 0) {
19657151Sbostic 		if (_IEEE && x == 0) return -one/zero;
19757151Sbostic 		else if(x == 0) return(infnan(-ERANGE));
19857151Sbostic 		else if(_IEEE) return (zero/zero);
19957151Sbostic 		else return(infnan(EDOM));
20057151Sbostic 	}
20157151Sbostic         if (x >= 2)			 /* |x| >= 2.0 */
20257151Sbostic 	{
20357151Sbostic                 s = sin(x);
20457151Sbostic                 c = cos(x);
20557151Sbostic                 ss = -s-c;
20657151Sbostic                 cc = s-c;
20757151Sbostic 		if (x < .5 * DBL_MAX)	/* make sure x+x not overflow */
20857151Sbostic 		{
20957151Sbostic                     z = cos(x+x);
21057151Sbostic                     if ((s*c)>zero) cc = z/ss;
21157151Sbostic                     else            ss = z/cc;
21257151Sbostic                 }
21357151Sbostic         /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0))
21457151Sbostic          * where x0 = x-3pi/4
21557151Sbostic          *      Better formula:
21657151Sbostic          *              cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
21757151Sbostic          *                      =  1/sqrt(2) * (sin(x) - cos(x))
21857151Sbostic          *              sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
21957151Sbostic          *                      = -1/sqrt(2) * (cos(x) + sin(x))
22057151Sbostic          * To avoid cancellation, use
22157151Sbostic          *              sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
22257151Sbostic          * to compute the worse one.
22357151Sbostic          */
22457151Sbostic                 if (_IEEE && x>two_129)
22557151Sbostic 			z = (invsqrtpi*ss)/sqrt(x);
22657151Sbostic                 else {
22757151Sbostic                     u = pone(x); v = qone(x);
22857151Sbostic                     z = invsqrtpi*(u*ss+v*cc)/sqrt(x);
22957151Sbostic                 }
23057151Sbostic                 return z;
23157151Sbostic         }
23257151Sbostic         if (x <= two_m54) {    /* x < 2**-54 */
23357151Sbostic             return (-tpi/x);
23457151Sbostic         }
23557151Sbostic         z = x*x;
23657151Sbostic         u = u0[0]+z*(u0[1]+z*(u0[2]+z*(u0[3]+z*u0[4])));
23757151Sbostic         v = one+z*(v0[0]+z*(v0[1]+z*(v0[2]+z*(v0[3]+z*v0[4]))));
23857151Sbostic         return (x*(u/v) + tpi*(j1(x)*log(x)-one/x));
23957151Sbostic }
24035679Sbostic 
24157151Sbostic /* For x >= 8, the asymptotic expansions of pone is
24257151Sbostic  *	1 + 15/128 s^2 - 4725/2^15 s^4 - ...,	where s = 1/x.
24357151Sbostic  * We approximate pone by
24457151Sbostic  * 	pone(x) = 1 + (R/S)
24557151Sbostic  * where  R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10
24657151Sbostic  * 	  S = 1 + ps0*s^2 + ... + ps4*s^10
24757151Sbostic  * and
24857151Sbostic  *	| pone(x)-1-R/S | <= 2  ** ( -60.06)
24957151Sbostic  */
25035679Sbostic 
25157151Sbostic static double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
25257151Sbostic    0.0,
25357151Sbostic    1.171874999999886486643746274751925399540e-0001,
25457151Sbostic    1.323948065930735690925827997575471527252e+0001,
25557151Sbostic    4.120518543073785433325860184116512799375e+0002,
25657151Sbostic    3.874745389139605254931106878336700275601e+0003,
25757151Sbostic    7.914479540318917214253998253147871806507e+0003,
25824598Szliu };
25957151Sbostic static double ps8[5] = {
26057151Sbostic    1.142073703756784104235066368252692471887e+0002,
26157151Sbostic    3.650930834208534511135396060708677099382e+0003,
26257151Sbostic    3.695620602690334708579444954937638371808e+0004,
26357151Sbostic    9.760279359349508334916300080109196824151e+0004,
26457151Sbostic    3.080427206278887984185421142572315054499e+0004,
26524598Szliu };
26657151Sbostic 
26757151Sbostic static double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
26857151Sbostic    1.319905195562435287967533851581013807103e-0011,
26957151Sbostic    1.171874931906140985709584817065144884218e-0001,
27057151Sbostic    6.802751278684328781830052995333841452280e+0000,
27157151Sbostic    1.083081829901891089952869437126160568246e+0002,
27257151Sbostic    5.176361395331997166796512844100442096318e+0002,
27357151Sbostic    5.287152013633375676874794230748055786553e+0002,
27424598Szliu };
27557151Sbostic static double ps5[5] = {
27657151Sbostic    5.928059872211313557747989128353699746120e+0001,
27757151Sbostic    9.914014187336144114070148769222018425781e+0002,
27857151Sbostic    5.353266952914879348427003712029704477451e+0003,
27957151Sbostic    7.844690317495512717451367787640014588422e+0003,
28057151Sbostic    1.504046888103610723953792002716816255382e+0003,
28124598Szliu };
28257151Sbostic 
28357151Sbostic static double pr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
28457151Sbostic    3.025039161373736032825049903408701962756e-0009,
28557151Sbostic    1.171868655672535980750284752227495879921e-0001,
28657151Sbostic    3.932977500333156527232725812363183251138e+0000,
28757151Sbostic    3.511940355916369600741054592597098912682e+0001,
28857151Sbostic    9.105501107507812029367749771053045219094e+0001,
28957151Sbostic    4.855906851973649494139275085628195457113e+0001,
29024598Szliu };
29157151Sbostic static double ps3[5] = {
29257151Sbostic    3.479130950012515114598605916318694946754e+0001,
29357151Sbostic    3.367624587478257581844639171605788622549e+0002,
29457151Sbostic    1.046871399757751279180649307467612538415e+0003,
29557151Sbostic    8.908113463982564638443204408234739237639e+0002,
29657151Sbostic    1.037879324396392739952487012284401031859e+0002,
29724598Szliu };
29857151Sbostic 
29957151Sbostic static double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
30057151Sbostic    1.077108301068737449490056513753865482831e-0007,
30157151Sbostic    1.171762194626833490512746348050035171545e-0001,
30257151Sbostic    2.368514966676087902251125130227221462134e+0000,
30357151Sbostic    1.224261091482612280835153832574115951447e+0001,
30457151Sbostic    1.769397112716877301904532320376586509782e+0001,
30557151Sbostic    5.073523125888185399030700509321145995160e+0000,
30624598Szliu };
30757151Sbostic static double ps2[5] = {
30857151Sbostic    2.143648593638214170243114358933327983793e+0001,
30957151Sbostic    1.252902271684027493309211410842525120355e+0002,
31057151Sbostic    2.322764690571628159027850677565128301361e+0002,
31157151Sbostic    1.176793732871470939654351793502076106651e+0002,
31257151Sbostic    8.364638933716182492500902115164881195742e+0000,
31324598Szliu };
31424598Szliu 
pone(x)31557151Sbostic static double pone(x)
31657151Sbostic 	double x;
31757151Sbostic {
31857151Sbostic 	double *p,*q,z,r,s;
31957151Sbostic 	if (x >= 8.0) 			   {p = pr8; q= ps8;}
32057151Sbostic 	else if (x >= 4.54545211791992188) {p = pr5; q= ps5;}
32157151Sbostic 	else if (x >= 2.85714149475097656) {p = pr3; q= ps3;}
32257151Sbostic 	else /* if (x >= 2.0) */	   {p = pr2; q= ps2;}
32357151Sbostic 	z = one/(x*x);
32457151Sbostic 	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
32557151Sbostic 	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
32657151Sbostic 	return (one + r/s);
32757151Sbostic }
32857151Sbostic 
32935679Sbostic 
33057151Sbostic /* For x >= 8, the asymptotic expansions of qone is
33157151Sbostic  *	3/8 s - 105/1024 s^3 - ..., where s = 1/x.
33257151Sbostic  * We approximate pone by
33357151Sbostic  * 	qone(x) = s*(0.375 + (R/S))
33457151Sbostic  * where  R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10
33557151Sbostic  * 	  S = 1 + qs1*s^2 + ... + qs6*s^12
33657151Sbostic  * and
33757151Sbostic  *	| qone(x)/s -0.375-R/S | <= 2  ** ( -61.13)
33857151Sbostic  */
33924598Szliu 
34057151Sbostic static double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
34157151Sbostic    0.0,
34257151Sbostic   -1.025390624999927207385863635575804210817e-0001,
34357151Sbostic   -1.627175345445899724355852152103771510209e+0001,
34457151Sbostic   -7.596017225139501519843072766973047217159e+0002,
34557151Sbostic   -1.184980667024295901645301570813228628541e+0004,
34657151Sbostic   -4.843851242857503225866761992518949647041e+0004,
34757151Sbostic };
34857151Sbostic static double qs8[6] = {
34957151Sbostic    1.613953697007229231029079421446916397904e+0002,
35057151Sbostic    7.825385999233484705298782500926834217525e+0003,
35157151Sbostic    1.338753362872495800748094112937868089032e+0005,
35257151Sbostic    7.196577236832409151461363171617204036929e+0005,
35357151Sbostic    6.666012326177764020898162762642290294625e+0005,
35457151Sbostic   -2.944902643038346618211973470809456636830e+0005,
35557151Sbostic };
35624598Szliu 
35757151Sbostic static double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
35857151Sbostic   -2.089799311417640889742251585097264715678e-0011,
35957151Sbostic   -1.025390502413754195402736294609692303708e-0001,
36057151Sbostic   -8.056448281239359746193011295417408828404e+0000,
36157151Sbostic   -1.836696074748883785606784430098756513222e+0002,
36257151Sbostic   -1.373193760655081612991329358017247355921e+0003,
36357151Sbostic   -2.612444404532156676659706427295870995743e+0003,
36457151Sbostic };
36557151Sbostic static double qs5[6] = {
36657151Sbostic    8.127655013843357670881559763225310973118e+0001,
36757151Sbostic    1.991798734604859732508048816860471197220e+0003,
36857151Sbostic    1.746848519249089131627491835267411777366e+0004,
36957151Sbostic    4.985142709103522808438758919150738000353e+0004,
37057151Sbostic    2.794807516389181249227113445299675335543e+0004,
37157151Sbostic   -4.719183547951285076111596613593553911065e+0003,
37257151Sbostic };
37324598Szliu 
37457151Sbostic static double qr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
37557151Sbostic   -5.078312264617665927595954813341838734288e-0009,
37657151Sbostic   -1.025378298208370901410560259001035577681e-0001,
37757151Sbostic   -4.610115811394734131557983832055607679242e+0000,
37857151Sbostic   -5.784722165627836421815348508816936196402e+0001,
37957151Sbostic   -2.282445407376317023842545937526967035712e+0002,
38057151Sbostic   -2.192101284789093123936441805496580237676e+0002,
38157151Sbostic };
38257151Sbostic static double qs3[6] = {
38357151Sbostic    4.766515503237295155392317984171640809318e+0001,
38457151Sbostic    6.738651126766996691330687210949984203167e+0002,
38557151Sbostic    3.380152866795263466426219644231687474174e+0003,
38657151Sbostic    5.547729097207227642358288160210745890345e+0003,
38757151Sbostic    1.903119193388108072238947732674639066045e+0003,
38857151Sbostic   -1.352011914443073322978097159157678748982e+0002,
38957151Sbostic };
39024598Szliu 
39157151Sbostic static double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
39257151Sbostic   -1.783817275109588656126772316921194887979e-0007,
39357151Sbostic   -1.025170426079855506812435356168903694433e-0001,
39457151Sbostic   -2.752205682781874520495702498875020485552e+0000,
39557151Sbostic   -1.966361626437037351076756351268110418862e+0001,
39657151Sbostic   -4.232531333728305108194363846333841480336e+0001,
39757151Sbostic   -2.137192117037040574661406572497288723430e+0001,
39857151Sbostic };
39957151Sbostic static double qs2[6] = {
40057151Sbostic    2.953336290605238495019307530224241335502e+0001,
40157151Sbostic    2.529815499821905343698811319455305266409e+0002,
40257151Sbostic    7.575028348686454070022561120722815892346e+0002,
40357151Sbostic    7.393932053204672479746835719678434981599e+0002,
40457151Sbostic    1.559490033366661142496448853793707126179e+0002,
40557151Sbostic   -4.959498988226281813825263003231704397158e+0000,
40657151Sbostic };
40757151Sbostic 
qone(x)40857151Sbostic static double qone(x)
40957151Sbostic 	double x;
41057151Sbostic {
41157151Sbostic 	double *p,*q, s,r,z;
41257151Sbostic 	if (x >= 8.0)			   {p = qr8; q= qs8;}
41357151Sbostic 	else if (x >= 4.54545211791992188) {p = qr5; q= qs5;}
41457151Sbostic 	else if (x >= 2.85714149475097656) {p = qr3; q= qs3;}
41557151Sbostic 	else /* if (x >= 2.0) */	   {p = qr2; q= qs2;}
41657151Sbostic 	z = one/(x*x);
41757151Sbostic 	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
41857151Sbostic 	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
41957151Sbostic 	return (.375 + r/s)/x;
42024598Szliu }
421