125c28e83SPiotr Jasiukajtis /* 225c28e83SPiotr Jasiukajtis * CDDL HEADER START 325c28e83SPiotr Jasiukajtis * 425c28e83SPiotr Jasiukajtis * The contents of this file are subject to the terms of the 525c28e83SPiotr Jasiukajtis * Common Development and Distribution License (the "License"). 625c28e83SPiotr Jasiukajtis * You may not use this file except in compliance with the License. 725c28e83SPiotr Jasiukajtis * 825c28e83SPiotr Jasiukajtis * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 925c28e83SPiotr Jasiukajtis * or http://www.opensolaris.org/os/licensing. 1025c28e83SPiotr Jasiukajtis * See the License for the specific language governing permissions 1125c28e83SPiotr Jasiukajtis * and limitations under the License. 1225c28e83SPiotr Jasiukajtis * 1325c28e83SPiotr Jasiukajtis * When distributing Covered Code, include this CDDL HEADER in each 1425c28e83SPiotr Jasiukajtis * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1525c28e83SPiotr Jasiukajtis * If applicable, add the following below this CDDL HEADER, with the 1625c28e83SPiotr Jasiukajtis * fields enclosed by brackets "[]" replaced with your own identifying 1725c28e83SPiotr Jasiukajtis * information: Portions Copyright [yyyy] [name of copyright owner] 1825c28e83SPiotr Jasiukajtis * 1925c28e83SPiotr Jasiukajtis * CDDL HEADER END 2025c28e83SPiotr Jasiukajtis */ 2125c28e83SPiotr Jasiukajtis 2225c28e83SPiotr Jasiukajtis /* 2325c28e83SPiotr Jasiukajtis * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 2425c28e83SPiotr Jasiukajtis */ 2525c28e83SPiotr Jasiukajtis /* 2625c28e83SPiotr Jasiukajtis * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 2725c28e83SPiotr Jasiukajtis * Use is subject to license terms. 2825c28e83SPiotr Jasiukajtis */ 2925c28e83SPiotr Jasiukajtis 3025c28e83SPiotr Jasiukajtis /* 3125c28e83SPiotr Jasiukajtis * Floating point Bessel's function of the first and second kinds 3225c28e83SPiotr Jasiukajtis * of order zero: j0(x),y0(x); 3325c28e83SPiotr Jasiukajtis * 3425c28e83SPiotr Jasiukajtis * Special cases: 3525c28e83SPiotr Jasiukajtis * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; 3625c28e83SPiotr Jasiukajtis * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. 3725c28e83SPiotr Jasiukajtis */ 3825c28e83SPiotr Jasiukajtis 39*ddc0e0b5SRichard Lowe #pragma weak __j0 = j0 40*ddc0e0b5SRichard Lowe #pragma weak __y0 = y0 4125c28e83SPiotr Jasiukajtis 4225c28e83SPiotr Jasiukajtis #include "libm.h" 4325c28e83SPiotr Jasiukajtis #include "libm_protos.h" 4425c28e83SPiotr Jasiukajtis #include <math.h> 4525c28e83SPiotr Jasiukajtis #include <values.h> 4625c28e83SPiotr Jasiukajtis 4725c28e83SPiotr Jasiukajtis #define GENERIC double 4825c28e83SPiotr Jasiukajtis static const GENERIC 4925c28e83SPiotr Jasiukajtis zero = 0.0, 5025c28e83SPiotr Jasiukajtis small = 1.0e-5, 5125c28e83SPiotr Jasiukajtis tiny = 1.0e-18, 5225c28e83SPiotr Jasiukajtis one = 1.0, 5325c28e83SPiotr Jasiukajtis eight = 8.0, 5425c28e83SPiotr Jasiukajtis invsqrtpi = 5.641895835477562869480794515607725858441e-0001, 5525c28e83SPiotr Jasiukajtis tpi = 0.636619772367581343075535053490057448; 5625c28e83SPiotr Jasiukajtis 5725c28e83SPiotr Jasiukajtis static GENERIC pzero(GENERIC), qzero(GENERIC); 5825c28e83SPiotr Jasiukajtis static const GENERIC r0[4] = { /* [1.e-5, 1.28] */ 5925c28e83SPiotr Jasiukajtis -2.500000000000003622131880894830476755537e-0001, 6025c28e83SPiotr Jasiukajtis 1.095597547334830263234433855932375353303e-0002, 6125c28e83SPiotr Jasiukajtis -1.819734750463320921799187258987098087697e-0004, 6225c28e83SPiotr Jasiukajtis 9.977001946806131657544212501069893930846e-0007, 6325c28e83SPiotr Jasiukajtis }; 6425c28e83SPiotr Jasiukajtis static const GENERIC s0[4] = { /* [1.e-5, 1.28] */ 6525c28e83SPiotr Jasiukajtis 1.0, 6625c28e83SPiotr Jasiukajtis 1.867609810662950169966782360588199673741e-0002, 6725c28e83SPiotr Jasiukajtis 1.590389206181565490878430827706972074208e-0004, 6825c28e83SPiotr Jasiukajtis 6.520867386742583632375520147714499522721e-0007, 6925c28e83SPiotr Jasiukajtis }; 7025c28e83SPiotr Jasiukajtis static const GENERIC r1[9] = { /* [1.28,8] */ 7125c28e83SPiotr Jasiukajtis 9.999999999999999942156495584397047660949e-0001, 7225c28e83SPiotr Jasiukajtis -2.389887722731319130476839836908143731281e-0001, 7325c28e83SPiotr Jasiukajtis 1.293359476138939027791270393439493640570e-0002, 7425c28e83SPiotr Jasiukajtis -2.770985642343140122168852400228563364082e-0004, 7525c28e83SPiotr Jasiukajtis 2.905241575772067678086738389169625218912e-0006, 7625c28e83SPiotr Jasiukajtis -1.636846356264052597969042009265043251279e-0008, 7725c28e83SPiotr Jasiukajtis 5.072306160724884775085431059052611737827e-0011, 7825c28e83SPiotr Jasiukajtis -8.187060730684066824228914775146536139112e-0014, 7925c28e83SPiotr Jasiukajtis 5.422219326959949863954297860723723423842e-0017, 8025c28e83SPiotr Jasiukajtis }; 8125c28e83SPiotr Jasiukajtis static const GENERIC s1[9] = { /* [1.28,8] */ 8225c28e83SPiotr Jasiukajtis 1.0, 8325c28e83SPiotr Jasiukajtis 1.101122772686807702762104741932076228349e-0002, 8425c28e83SPiotr Jasiukajtis 6.140169310641649223411427764669143978228e-0005, 8525c28e83SPiotr Jasiukajtis 2.292035877515152097976946119293215705250e-0007, 8625c28e83SPiotr Jasiukajtis 6.356910426504644334558832036362219583789e-0010, 8725c28e83SPiotr Jasiukajtis 1.366626326900219555045096999553948891401e-0012, 8825c28e83SPiotr Jasiukajtis 2.280399586866739522891837985560481180088e-0015, 8925c28e83SPiotr Jasiukajtis 2.801559820648939665270492520004836611187e-0018, 9025c28e83SPiotr Jasiukajtis 2.073101088320349159764410261466350732968e-0021, 9125c28e83SPiotr Jasiukajtis }; 9225c28e83SPiotr Jasiukajtis 9325c28e83SPiotr Jasiukajtis GENERIC 9425c28e83SPiotr Jasiukajtis j0(GENERIC x) { 9525c28e83SPiotr Jasiukajtis GENERIC z, s, c, ss, cc, r, u, v, ox; 9625c28e83SPiotr Jasiukajtis int i; 9725c28e83SPiotr Jasiukajtis 9825c28e83SPiotr Jasiukajtis if (isnan(x)) 9925c28e83SPiotr Jasiukajtis return (x*x); /* + -> * for Cheetah */ 10025c28e83SPiotr Jasiukajtis ox = x; 10125c28e83SPiotr Jasiukajtis x = fabs(x); 10225c28e83SPiotr Jasiukajtis if (x > 8.0) { 10325c28e83SPiotr Jasiukajtis if (!finite(x)) 10425c28e83SPiotr Jasiukajtis return (zero); 10525c28e83SPiotr Jasiukajtis s = sin(x); 10625c28e83SPiotr Jasiukajtis c = cos(x); 10725c28e83SPiotr Jasiukajtis /* 10825c28e83SPiotr Jasiukajtis * j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0)) 10925c28e83SPiotr Jasiukajtis * where x0 = x-pi/4 11025c28e83SPiotr Jasiukajtis * Better formula: 11125c28e83SPiotr Jasiukajtis * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) 11225c28e83SPiotr Jasiukajtis * = 1/sqrt(2) * (cos(x) + sin(x)) 11325c28e83SPiotr Jasiukajtis * sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4) 11425c28e83SPiotr Jasiukajtis * = 1/sqrt(2) * (sin(x) - cos(x)) 11525c28e83SPiotr Jasiukajtis * To avoid cancellation, use 11625c28e83SPiotr Jasiukajtis * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) 11725c28e83SPiotr Jasiukajtis * to compute the worse one. 11825c28e83SPiotr Jasiukajtis */ 11925c28e83SPiotr Jasiukajtis if (x > 8.9e307) { /* x+x may overflow */ 12025c28e83SPiotr Jasiukajtis ss = s-c; 12125c28e83SPiotr Jasiukajtis cc = s+c; 12225c28e83SPiotr Jasiukajtis } else if (signbit(s) != signbit(c)) { 12325c28e83SPiotr Jasiukajtis ss = s - c; 12425c28e83SPiotr Jasiukajtis cc = -cos(x+x)/ss; 12525c28e83SPiotr Jasiukajtis } else { 12625c28e83SPiotr Jasiukajtis cc = s + c; 12725c28e83SPiotr Jasiukajtis ss = -cos(x+x)/cc; 12825c28e83SPiotr Jasiukajtis } 12925c28e83SPiotr Jasiukajtis /* 13025c28e83SPiotr Jasiukajtis * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) 13125c28e83SPiotr Jasiukajtis * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) 13225c28e83SPiotr Jasiukajtis */ 13325c28e83SPiotr Jasiukajtis if (x > 1.0e40) z = (invsqrtpi*cc)/sqrt(x); 13425c28e83SPiotr Jasiukajtis else { 13525c28e83SPiotr Jasiukajtis u = pzero(x); v = qzero(x); 13625c28e83SPiotr Jasiukajtis z = invsqrtpi*(u*cc-v*ss)/sqrt(x); 13725c28e83SPiotr Jasiukajtis } 13825c28e83SPiotr Jasiukajtis /* force to pass SVR4 even the result is wrong (sign) */ 13925c28e83SPiotr Jasiukajtis if (x > X_TLOSS) 14025c28e83SPiotr Jasiukajtis return (_SVID_libm_err(ox, z, 34)); 14125c28e83SPiotr Jasiukajtis else 14225c28e83SPiotr Jasiukajtis return (z); 14325c28e83SPiotr Jasiukajtis } 14425c28e83SPiotr Jasiukajtis if (x <= small) { 14525c28e83SPiotr Jasiukajtis if (x <= tiny) 14625c28e83SPiotr Jasiukajtis return (one-x); 14725c28e83SPiotr Jasiukajtis else 14825c28e83SPiotr Jasiukajtis return (one-x*x*0.25); 14925c28e83SPiotr Jasiukajtis } 15025c28e83SPiotr Jasiukajtis z = x*x; 15125c28e83SPiotr Jasiukajtis if (x <= 1.28) { 15225c28e83SPiotr Jasiukajtis r = r0[0]+z*(r0[1]+z*(r0[2]+z*r0[3])); 15325c28e83SPiotr Jasiukajtis s = s0[0]+z*(s0[1]+z*(s0[2]+z*s0[3])); 15425c28e83SPiotr Jasiukajtis return (one + z*(r/s)); 15525c28e83SPiotr Jasiukajtis } else { 15625c28e83SPiotr Jasiukajtis for (r = r1[8], s = s1[8], i = 7; i >= 0; i--) { 15725c28e83SPiotr Jasiukajtis r = r*z + r1[i]; 15825c28e83SPiotr Jasiukajtis s = s*z + s1[i]; 15925c28e83SPiotr Jasiukajtis } 16025c28e83SPiotr Jasiukajtis return (r/s); 16125c28e83SPiotr Jasiukajtis } 16225c28e83SPiotr Jasiukajtis } 16325c28e83SPiotr Jasiukajtis 16425c28e83SPiotr Jasiukajtis static const GENERIC u0[13] = { 16525c28e83SPiotr Jasiukajtis -7.380429510868722526754723020704317641941e-0002, 16625c28e83SPiotr Jasiukajtis 1.772607102684869924301459663049874294814e-0001, 16725c28e83SPiotr Jasiukajtis -1.524370666542713828604078090970799356306e-0002, 16825c28e83SPiotr Jasiukajtis 4.650819100693891757143771557629924591915e-0004, 16925c28e83SPiotr Jasiukajtis -7.125768872339528975036316108718239946022e-0006, 17025c28e83SPiotr Jasiukajtis 6.411017001656104598327565004771515257146e-0008, 17125c28e83SPiotr Jasiukajtis -3.694275157433032553021246812379258781665e-0010, 17225c28e83SPiotr Jasiukajtis 1.434364544206266624252820889648445263842e-0012, 17325c28e83SPiotr Jasiukajtis -3.852064731859936455895036286874139896861e-0015, 17425c28e83SPiotr Jasiukajtis 7.182052899726138381739945881914874579696e-0018, 17525c28e83SPiotr Jasiukajtis -9.060556574619677567323741194079797987200e-0021, 17625c28e83SPiotr Jasiukajtis 7.124435467408860515265552217131230511455e-0024, 17725c28e83SPiotr Jasiukajtis -2.709726774636397615328813121715432044771e-0027, 17825c28e83SPiotr Jasiukajtis }; 17925c28e83SPiotr Jasiukajtis static const GENERIC v0[5] = { 18025c28e83SPiotr Jasiukajtis 1.0, 18125c28e83SPiotr Jasiukajtis 4.678678931512549002587702477349214886475e-0003, 18225c28e83SPiotr Jasiukajtis 9.486828955529948534822800829497565178985e-0006, 18325c28e83SPiotr Jasiukajtis 1.001495929158861646659010844136682454906e-0008, 18425c28e83SPiotr Jasiukajtis 4.725338116256021660204443235685358593611e-0012, 18525c28e83SPiotr Jasiukajtis }; 18625c28e83SPiotr Jasiukajtis 18725c28e83SPiotr Jasiukajtis GENERIC 18825c28e83SPiotr Jasiukajtis y0(GENERIC x) { 18925c28e83SPiotr Jasiukajtis GENERIC z, /* d, */ s, c, ss, cc, u, v; 19025c28e83SPiotr Jasiukajtis int i; 19125c28e83SPiotr Jasiukajtis 19225c28e83SPiotr Jasiukajtis if (isnan(x)) 19325c28e83SPiotr Jasiukajtis return (x*x); /* + -> * for Cheetah */ 19425c28e83SPiotr Jasiukajtis if (x <= zero) { 19525c28e83SPiotr Jasiukajtis if (x == zero) 19625c28e83SPiotr Jasiukajtis /* d= -one/(x-x); */ 19725c28e83SPiotr Jasiukajtis return (_SVID_libm_err(x, x, 8)); 19825c28e83SPiotr Jasiukajtis else 19925c28e83SPiotr Jasiukajtis /* d = zero/(x-x); */ 20025c28e83SPiotr Jasiukajtis return (_SVID_libm_err(x, x, 9)); 20125c28e83SPiotr Jasiukajtis } 20225c28e83SPiotr Jasiukajtis if (x > 8.0) { 20325c28e83SPiotr Jasiukajtis if (!finite(x)) 20425c28e83SPiotr Jasiukajtis return (zero); 20525c28e83SPiotr Jasiukajtis s = sin(x); 20625c28e83SPiotr Jasiukajtis c = cos(x); 20725c28e83SPiotr Jasiukajtis /* 20825c28e83SPiotr Jasiukajtis * j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0)) 20925c28e83SPiotr Jasiukajtis * where x0 = x-pi/4 21025c28e83SPiotr Jasiukajtis * Better formula: 21125c28e83SPiotr Jasiukajtis * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) 21225c28e83SPiotr Jasiukajtis * = 1/sqrt(2) * (cos(x) + sin(x)) 21325c28e83SPiotr Jasiukajtis * sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4) 21425c28e83SPiotr Jasiukajtis * = 1/sqrt(2) * (sin(x) - cos(x)) 21525c28e83SPiotr Jasiukajtis * To avoid cancellation, use 21625c28e83SPiotr Jasiukajtis * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) 21725c28e83SPiotr Jasiukajtis * to compute the worse one. 21825c28e83SPiotr Jasiukajtis */ 21925c28e83SPiotr Jasiukajtis if (x > 8.9e307) { /* x+x may overflow */ 22025c28e83SPiotr Jasiukajtis ss = s-c; 22125c28e83SPiotr Jasiukajtis cc = s+c; 22225c28e83SPiotr Jasiukajtis } else if (signbit(s) != signbit(c)) { 22325c28e83SPiotr Jasiukajtis ss = s - c; 22425c28e83SPiotr Jasiukajtis cc = -cos(x+x)/ss; 22525c28e83SPiotr Jasiukajtis } else { 22625c28e83SPiotr Jasiukajtis cc = s + c; 22725c28e83SPiotr Jasiukajtis ss = -cos(x+x)/cc; 22825c28e83SPiotr Jasiukajtis } 22925c28e83SPiotr Jasiukajtis /* 23025c28e83SPiotr Jasiukajtis * j0(x) = 1/sqrt(pi*x) * (P(0,x)*cc - Q(0,x)*ss) 23125c28e83SPiotr Jasiukajtis * y0(x) = 1/sqrt(pi*x) * (P(0,x)*ss + Q(0,x)*cc) 23225c28e83SPiotr Jasiukajtis */ 23325c28e83SPiotr Jasiukajtis if (x > 1.0e40) 23425c28e83SPiotr Jasiukajtis z = (invsqrtpi*ss)/sqrt(x); 23525c28e83SPiotr Jasiukajtis else 23625c28e83SPiotr Jasiukajtis z = invsqrtpi*(pzero(x)*ss+qzero(x)*cc)/sqrt(x); 23725c28e83SPiotr Jasiukajtis if (x > X_TLOSS) 23825c28e83SPiotr Jasiukajtis return (_SVID_libm_err(x, z, 35)); 23925c28e83SPiotr Jasiukajtis else 24025c28e83SPiotr Jasiukajtis return (z); 24125c28e83SPiotr Jasiukajtis 24225c28e83SPiotr Jasiukajtis } 24325c28e83SPiotr Jasiukajtis if (x <= tiny) { 24425c28e83SPiotr Jasiukajtis return (u0[0] + tpi*log(x)); 24525c28e83SPiotr Jasiukajtis } 24625c28e83SPiotr Jasiukajtis z = x*x; 24725c28e83SPiotr Jasiukajtis for (u = u0[12], i = 11; i >= 0; i--) u = u*z + u0[i]; 24825c28e83SPiotr Jasiukajtis v = v0[0]+z*(v0[1]+z*(v0[2]+z*(v0[3]+z*v0[4]))); 24925c28e83SPiotr Jasiukajtis return (u/v + tpi*(j0(x)*log(x))); 25025c28e83SPiotr Jasiukajtis } 25125c28e83SPiotr Jasiukajtis 25225c28e83SPiotr Jasiukajtis static const GENERIC pr[7] = { /* [8 -- inf] pzero 6550 */ 25325c28e83SPiotr Jasiukajtis .4861344183386052721391238447e5, 25425c28e83SPiotr Jasiukajtis .1377662549407112278133438945e6, 25525c28e83SPiotr Jasiukajtis .1222466364088289731869114004e6, 25625c28e83SPiotr Jasiukajtis .4107070084315176135583353374e5, 25725c28e83SPiotr Jasiukajtis .5026073801860637125889039915e4, 25825c28e83SPiotr Jasiukajtis .1783193659125479654541542419e3, 25925c28e83SPiotr Jasiukajtis .88010344055383421691677564e0, 26025c28e83SPiotr Jasiukajtis }; 26125c28e83SPiotr Jasiukajtis static const GENERIC ps[7] = { /* [8 -- inf] pzero 6550 */ 26225c28e83SPiotr Jasiukajtis .4861344183386052721414037058e5, 26325c28e83SPiotr Jasiukajtis .1378196632630384670477582699e6, 26425c28e83SPiotr Jasiukajtis .1223967185341006542748936787e6, 26525c28e83SPiotr Jasiukajtis .4120150243795353639995862617e5, 26625c28e83SPiotr Jasiukajtis .5068271181053546392490184353e4, 26725c28e83SPiotr Jasiukajtis .1829817905472769960535671664e3, 26825c28e83SPiotr Jasiukajtis 1.0, 26925c28e83SPiotr Jasiukajtis }; 27025c28e83SPiotr Jasiukajtis static const GENERIC huge = 1.0e10; 27125c28e83SPiotr Jasiukajtis 27225c28e83SPiotr Jasiukajtis static GENERIC 27325c28e83SPiotr Jasiukajtis pzero(GENERIC x) { 27425c28e83SPiotr Jasiukajtis GENERIC s, r, t, z; 27525c28e83SPiotr Jasiukajtis int i; 27625c28e83SPiotr Jasiukajtis if (x > huge) 27725c28e83SPiotr Jasiukajtis return (one); 27825c28e83SPiotr Jasiukajtis t = eight/x; z = t*t; 27925c28e83SPiotr Jasiukajtis r = pr[5]+z*pr[6]; 28025c28e83SPiotr Jasiukajtis s = ps[5]+z; 28125c28e83SPiotr Jasiukajtis for (i = 4; i >= 0; i--) { 28225c28e83SPiotr Jasiukajtis r = r*z + pr[i]; 28325c28e83SPiotr Jasiukajtis s = s*z + ps[i]; 28425c28e83SPiotr Jasiukajtis } 28525c28e83SPiotr Jasiukajtis return (r/s); 28625c28e83SPiotr Jasiukajtis } 28725c28e83SPiotr Jasiukajtis 28825c28e83SPiotr Jasiukajtis static const GENERIC qr[7] = { /* [8 -- inf] qzero 6950 */ 28925c28e83SPiotr Jasiukajtis -.1731210995701068539185611951e3, 29025c28e83SPiotr Jasiukajtis -.5522559165936166961235240613e3, 29125c28e83SPiotr Jasiukajtis -.5604935606637346590614529613e3, 29225c28e83SPiotr Jasiukajtis -.2200430300226009379477365011e3, 29325c28e83SPiotr Jasiukajtis -.323869355375648849771296746e2, 29425c28e83SPiotr Jasiukajtis -.14294979207907956223499258e1, 29525c28e83SPiotr Jasiukajtis -.834690374102384988158918e-2, 29625c28e83SPiotr Jasiukajtis }; 29725c28e83SPiotr Jasiukajtis static const GENERIC qs[7] = { /* [8 -- inf] qzero 6950 */ 29825c28e83SPiotr Jasiukajtis .1107975037248683865326709645e5, 29925c28e83SPiotr Jasiukajtis .3544581680627082674651471873e5, 30025c28e83SPiotr Jasiukajtis .3619118937918394132179019059e5, 30125c28e83SPiotr Jasiukajtis .1439895563565398007471485822e5, 30225c28e83SPiotr Jasiukajtis .2190277023344363955930226234e4, 30325c28e83SPiotr Jasiukajtis .106695157020407986137501682e3, 30425c28e83SPiotr Jasiukajtis 1.0, 30525c28e83SPiotr Jasiukajtis }; 30625c28e83SPiotr Jasiukajtis 30725c28e83SPiotr Jasiukajtis static GENERIC 30825c28e83SPiotr Jasiukajtis qzero(GENERIC x) { 30925c28e83SPiotr Jasiukajtis GENERIC s, r, t, z; 31025c28e83SPiotr Jasiukajtis int i; 31125c28e83SPiotr Jasiukajtis if (x > huge) 31225c28e83SPiotr Jasiukajtis return (-0.125/x); 31325c28e83SPiotr Jasiukajtis t = eight/x; z = t*t; 31425c28e83SPiotr Jasiukajtis r = qr[5]+z*qr[6]; 31525c28e83SPiotr Jasiukajtis s = qs[5]+z; 31625c28e83SPiotr Jasiukajtis for (i = 4; i >= 0; i--) { 31725c28e83SPiotr Jasiukajtis r = r*z + qr[i]; 31825c28e83SPiotr Jasiukajtis s = s*z + qs[i]; 31925c28e83SPiotr Jasiukajtis } 32025c28e83SPiotr Jasiukajtis return (t*(r/s)); 32125c28e83SPiotr Jasiukajtis } 322