15b2ba9d3SPiotr Jasiukajtis /*
25b2ba9d3SPiotr Jasiukajtis * CDDL HEADER START
35b2ba9d3SPiotr Jasiukajtis *
45b2ba9d3SPiotr Jasiukajtis * The contents of this file are subject to the terms of the
55b2ba9d3SPiotr Jasiukajtis * Common Development and Distribution License (the "License").
65b2ba9d3SPiotr Jasiukajtis * You may not use this file except in compliance with the License.
75b2ba9d3SPiotr Jasiukajtis *
85b2ba9d3SPiotr Jasiukajtis * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95b2ba9d3SPiotr Jasiukajtis * or http://www.opensolaris.org/os/licensing.
105b2ba9d3SPiotr Jasiukajtis * See the License for the specific language governing permissions
115b2ba9d3SPiotr Jasiukajtis * and limitations under the License.
125b2ba9d3SPiotr Jasiukajtis *
135b2ba9d3SPiotr Jasiukajtis * When distributing Covered Code, include this CDDL HEADER in each
145b2ba9d3SPiotr Jasiukajtis * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155b2ba9d3SPiotr Jasiukajtis * If applicable, add the following below this CDDL HEADER, with the
165b2ba9d3SPiotr Jasiukajtis * fields enclosed by brackets "[]" replaced with your own identifying
175b2ba9d3SPiotr Jasiukajtis * information: Portions Copyright [yyyy] [name of copyright owner]
185b2ba9d3SPiotr Jasiukajtis *
195b2ba9d3SPiotr Jasiukajtis * CDDL HEADER END
205b2ba9d3SPiotr Jasiukajtis */
215b2ba9d3SPiotr Jasiukajtis
225b2ba9d3SPiotr Jasiukajtis /*
235b2ba9d3SPiotr Jasiukajtis * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
245b2ba9d3SPiotr Jasiukajtis */
255b2ba9d3SPiotr Jasiukajtis /*
265b2ba9d3SPiotr Jasiukajtis * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
275b2ba9d3SPiotr Jasiukajtis * Use is subject to license terms.
285b2ba9d3SPiotr Jasiukajtis */
295b2ba9d3SPiotr Jasiukajtis
305b2ba9d3SPiotr Jasiukajtis /*
315b2ba9d3SPiotr Jasiukajtis * Floating point Bessel's function of the first and second kinds
325b2ba9d3SPiotr Jasiukajtis * of order zero: j0(x),y0(x);
335b2ba9d3SPiotr Jasiukajtis *
345b2ba9d3SPiotr Jasiukajtis * Special cases:
355b2ba9d3SPiotr Jasiukajtis * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal;
365b2ba9d3SPiotr Jasiukajtis * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal.
375b2ba9d3SPiotr Jasiukajtis */
385b2ba9d3SPiotr Jasiukajtis
39*a9d3dcd5SRichard Lowe #pragma weak __j0l = j0l
40*a9d3dcd5SRichard Lowe #pragma weak __y0l = y0l
415b2ba9d3SPiotr Jasiukajtis
425b2ba9d3SPiotr Jasiukajtis #include "libm.h"
435b2ba9d3SPiotr Jasiukajtis #include "longdouble.h"
445b2ba9d3SPiotr Jasiukajtis
455b2ba9d3SPiotr Jasiukajtis #define GENERIC long double
465b2ba9d3SPiotr Jasiukajtis static const GENERIC
475b2ba9d3SPiotr Jasiukajtis zero = 0.0L,
485b2ba9d3SPiotr Jasiukajtis small = 1.0e-9L,
495b2ba9d3SPiotr Jasiukajtis tiny = 1.0e-38L,
505b2ba9d3SPiotr Jasiukajtis one = 1.0L,
515b2ba9d3SPiotr Jasiukajtis five = 5.0L,
525b2ba9d3SPiotr Jasiukajtis eight = 8.0L,
535b2ba9d3SPiotr Jasiukajtis invsqrtpi= 5.641895835477562869480794515607725858441e-0001L,
545b2ba9d3SPiotr Jasiukajtis tpi = 0.636619772367581343075535053490057448L;
555b2ba9d3SPiotr Jasiukajtis
565b2ba9d3SPiotr Jasiukajtis static GENERIC pzero(GENERIC);
575b2ba9d3SPiotr Jasiukajtis static GENERIC qzero(GENERIC);
585b2ba9d3SPiotr Jasiukajtis
595b2ba9d3SPiotr Jasiukajtis static GENERIC r0[7] = {
605b2ba9d3SPiotr Jasiukajtis -2.499999999999999999999999999999998934492e-0001L,
615b2ba9d3SPiotr Jasiukajtis 1.272657927360049786327618451133763714880e-0002L,
625b2ba9d3SPiotr Jasiukajtis -2.694499763712963276900636693400659600898e-0004L,
635b2ba9d3SPiotr Jasiukajtis 2.724877475058977576903234070919616447883e-0006L,
645b2ba9d3SPiotr Jasiukajtis -1.432617103214330236967477495393076320281e-0008L,
655b2ba9d3SPiotr Jasiukajtis 3.823248804080079168706683540513792224471e-0011L,
665b2ba9d3SPiotr Jasiukajtis -4.183174277567983647337568504286313665065e-0014L,
675b2ba9d3SPiotr Jasiukajtis };
685b2ba9d3SPiotr Jasiukajtis static GENERIC s0[7] = {
695b2ba9d3SPiotr Jasiukajtis 1.0e0L,
705b2ba9d3SPiotr Jasiukajtis 1.159368290559800854689526195462884666395e-0002L,
715b2ba9d3SPiotr Jasiukajtis 6.629397597394973383009743876169946772559e-0005L,
725b2ba9d3SPiotr Jasiukajtis 2.426779981394054406305431142501735094340e-0007L,
735b2ba9d3SPiotr Jasiukajtis 6.097663491248511069094400469635449749883e-0010L,
745b2ba9d3SPiotr Jasiukajtis 1.017019133340929220238747413216052224036e-0012L,
755b2ba9d3SPiotr Jasiukajtis 9.012593179306197579518374581969371278481e-0016L,
765b2ba9d3SPiotr Jasiukajtis };
775b2ba9d3SPiotr Jasiukajtis
785b2ba9d3SPiotr Jasiukajtis GENERIC
j0l(x)795b2ba9d3SPiotr Jasiukajtis j0l(x) GENERIC x;{
805b2ba9d3SPiotr Jasiukajtis GENERIC z, s,c,ss,cc,r,u,v;
815b2ba9d3SPiotr Jasiukajtis int i;
825b2ba9d3SPiotr Jasiukajtis
835b2ba9d3SPiotr Jasiukajtis if (isnanl(x)) return x+x;
845b2ba9d3SPiotr Jasiukajtis x = fabsl(x);
855b2ba9d3SPiotr Jasiukajtis if (x > 1.28L) {
865b2ba9d3SPiotr Jasiukajtis if (!finitel(x)) return zero;
875b2ba9d3SPiotr Jasiukajtis s = sinl(x);
885b2ba9d3SPiotr Jasiukajtis c = cosl(x);
895b2ba9d3SPiotr Jasiukajtis /*
905b2ba9d3SPiotr Jasiukajtis * j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0))
915b2ba9d3SPiotr Jasiukajtis * where x0 = x-pi/4
925b2ba9d3SPiotr Jasiukajtis * Better formula:
935b2ba9d3SPiotr Jasiukajtis * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
945b2ba9d3SPiotr Jasiukajtis * = 1/sqrt(2) * (cos(x) + sin(x))
955b2ba9d3SPiotr Jasiukajtis * sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4)
965b2ba9d3SPiotr Jasiukajtis * = 1/sqrt(2) * (sin(x) - cos(x))
975b2ba9d3SPiotr Jasiukajtis * To avoid cancellation, use
985b2ba9d3SPiotr Jasiukajtis * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
995b2ba9d3SPiotr Jasiukajtis * to compute the worse one.
1005b2ba9d3SPiotr Jasiukajtis */
1015b2ba9d3SPiotr Jasiukajtis if (x>1.0e2450L) { /* x+x may overflow */
1025b2ba9d3SPiotr Jasiukajtis ss = s-c;
1035b2ba9d3SPiotr Jasiukajtis cc = s+c;
1045b2ba9d3SPiotr Jasiukajtis } else if (signbitl(s) != signbitl(c)) {
1055b2ba9d3SPiotr Jasiukajtis ss = s - c;
1065b2ba9d3SPiotr Jasiukajtis cc = -cosl(x+x)/ss;
1075b2ba9d3SPiotr Jasiukajtis } else {
1085b2ba9d3SPiotr Jasiukajtis cc = s + c;
1095b2ba9d3SPiotr Jasiukajtis ss = -cosl(x+x)/cc;
1105b2ba9d3SPiotr Jasiukajtis }
1115b2ba9d3SPiotr Jasiukajtis /*
1125b2ba9d3SPiotr Jasiukajtis * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
1135b2ba9d3SPiotr Jasiukajtis * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
1145b2ba9d3SPiotr Jasiukajtis */
1155b2ba9d3SPiotr Jasiukajtis if (x>1.0e120L) return (invsqrtpi*cc)/sqrtl(x);
1165b2ba9d3SPiotr Jasiukajtis u = pzero(x); v = qzero(x);
1175b2ba9d3SPiotr Jasiukajtis return invsqrtpi*(u*cc-v*ss)/sqrtl(x);
1185b2ba9d3SPiotr Jasiukajtis }
1195b2ba9d3SPiotr Jasiukajtis if (x<=small) {
1205b2ba9d3SPiotr Jasiukajtis if (x<=tiny) return one-x;
1215b2ba9d3SPiotr Jasiukajtis else return one-x*x*0.25L;
1225b2ba9d3SPiotr Jasiukajtis }
1235b2ba9d3SPiotr Jasiukajtis z = x*x;
1245b2ba9d3SPiotr Jasiukajtis r = r0[6]; s = s0[6];
1255b2ba9d3SPiotr Jasiukajtis for(i=5;i>=0;i--) {
1265b2ba9d3SPiotr Jasiukajtis r = r*z + r0[i];
1275b2ba9d3SPiotr Jasiukajtis s = s*z + s0[i];
1285b2ba9d3SPiotr Jasiukajtis }
1295b2ba9d3SPiotr Jasiukajtis return(one+z*(r/s));
1305b2ba9d3SPiotr Jasiukajtis }
1315b2ba9d3SPiotr Jasiukajtis
1325b2ba9d3SPiotr Jasiukajtis static const GENERIC u0[8] = {
1335b2ba9d3SPiotr Jasiukajtis -7.380429510868722527434392794848301631220e-0002L,
1345b2ba9d3SPiotr Jasiukajtis 1.766855559625940791857536949301981816513e-0001L,
1355b2ba9d3SPiotr Jasiukajtis -1.386470722701047923235553251240162839408e-0002L,
1365b2ba9d3SPiotr Jasiukajtis 3.520149242724811578636970811631224862615e-0004L,
1375b2ba9d3SPiotr Jasiukajtis -3.978599663243790049853642275624951870025e-0006L,
1385b2ba9d3SPiotr Jasiukajtis 2.228801153263957224547222556806915479763e-0008L,
1395b2ba9d3SPiotr Jasiukajtis -6.121246764298785018658597179498837316177e-0011L,
1405b2ba9d3SPiotr Jasiukajtis 6.677103629722678833475965810525587396596e-0014L,
1415b2ba9d3SPiotr Jasiukajtis };
1425b2ba9d3SPiotr Jasiukajtis static const GENERIC v0[8] = {
1435b2ba9d3SPiotr Jasiukajtis 1.0e0L,
1445b2ba9d3SPiotr Jasiukajtis 1.247164416539111311571676766127767127970e-0002L,
1455b2ba9d3SPiotr Jasiukajtis 7.829144749639791500052900281489367443576e-0005L,
1465b2ba9d3SPiotr Jasiukajtis 3.247126540422245330511218321013360336606e-0007L,
1475b2ba9d3SPiotr Jasiukajtis 9.750516724789499678567062572549568447869e-0010L,
1485b2ba9d3SPiotr Jasiukajtis 2.156713223173591212250543390258458098776e-0012L,
1495b2ba9d3SPiotr Jasiukajtis 3.322169561597890004231482431236452752624e-0015L,
1505b2ba9d3SPiotr Jasiukajtis 2.821213295314000924252226486305726805093e-0018L,
1515b2ba9d3SPiotr Jasiukajtis };
1525b2ba9d3SPiotr Jasiukajtis
1535b2ba9d3SPiotr Jasiukajtis GENERIC
y0l(x)1545b2ba9d3SPiotr Jasiukajtis y0l(x) GENERIC x;{
1555b2ba9d3SPiotr Jasiukajtis GENERIC z, s,c,ss,cc,u,v;
1565b2ba9d3SPiotr Jasiukajtis int i;
1575b2ba9d3SPiotr Jasiukajtis volatile GENERIC d;
1585b2ba9d3SPiotr Jasiukajtis
1595b2ba9d3SPiotr Jasiukajtis if (isnanl(x)) return x+x;
1605b2ba9d3SPiotr Jasiukajtis if (x <= zero) {
1615b2ba9d3SPiotr Jasiukajtis if (x == zero)
1625b2ba9d3SPiotr Jasiukajtis d= -one/(x-x);
1635b2ba9d3SPiotr Jasiukajtis else
1645b2ba9d3SPiotr Jasiukajtis d = zero/(x-x);
1655b2ba9d3SPiotr Jasiukajtis }
1665b2ba9d3SPiotr Jasiukajtis #ifdef lint
1675b2ba9d3SPiotr Jasiukajtis d = d;
1685b2ba9d3SPiotr Jasiukajtis #endif
1695b2ba9d3SPiotr Jasiukajtis if (x > 1.28L) {
1705b2ba9d3SPiotr Jasiukajtis if (!finitel(x)) return zero;
1715b2ba9d3SPiotr Jasiukajtis s = sinl(x);
1725b2ba9d3SPiotr Jasiukajtis c = cosl(x);
1735b2ba9d3SPiotr Jasiukajtis /*
1745b2ba9d3SPiotr Jasiukajtis * j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0))
1755b2ba9d3SPiotr Jasiukajtis * where x0 = x-pi/4
1765b2ba9d3SPiotr Jasiukajtis * Better formula:
1775b2ba9d3SPiotr Jasiukajtis * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
1785b2ba9d3SPiotr Jasiukajtis * = 1/sqrt(2) * (cos(x) + sin(x))
1795b2ba9d3SPiotr Jasiukajtis * sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4)
1805b2ba9d3SPiotr Jasiukajtis * = 1/sqrt(2) * (sin(x) - cos(x))
1815b2ba9d3SPiotr Jasiukajtis * To avoid cancellation, use
1825b2ba9d3SPiotr Jasiukajtis * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
1835b2ba9d3SPiotr Jasiukajtis * to compute the worse one.
1845b2ba9d3SPiotr Jasiukajtis */
1855b2ba9d3SPiotr Jasiukajtis if (x>1.0e2450L) { /* x+x may overflow */
1865b2ba9d3SPiotr Jasiukajtis ss = s-c;
1875b2ba9d3SPiotr Jasiukajtis cc = s+c;
1885b2ba9d3SPiotr Jasiukajtis } else if (signbitl(s) != signbitl(c)) {
1895b2ba9d3SPiotr Jasiukajtis ss = s - c;
1905b2ba9d3SPiotr Jasiukajtis cc = -cosl(x+x)/ss;
1915b2ba9d3SPiotr Jasiukajtis } else {
1925b2ba9d3SPiotr Jasiukajtis cc = s + c;
1935b2ba9d3SPiotr Jasiukajtis ss = -cosl(x+x)/cc;
1945b2ba9d3SPiotr Jasiukajtis }
1955b2ba9d3SPiotr Jasiukajtis /*
1965b2ba9d3SPiotr Jasiukajtis * j0(x) = 1/sqrt(pi*x) * (P(0,x)*cc - Q(0,x)*ss)
1975b2ba9d3SPiotr Jasiukajtis * y0(x) = 1/sqrt(pi*x) * (P(0,x)*ss + Q(0,x)*cc)
1985b2ba9d3SPiotr Jasiukajtis */
1995b2ba9d3SPiotr Jasiukajtis if (x>1.0e120L) return (invsqrtpi*ss)/sqrtl(x);
2005b2ba9d3SPiotr Jasiukajtis return invsqrtpi*(pzero(x)*ss+qzero(x)*cc)/sqrtl(x);
2015b2ba9d3SPiotr Jasiukajtis
2025b2ba9d3SPiotr Jasiukajtis }
2035b2ba9d3SPiotr Jasiukajtis if (x<=tiny) {
2045b2ba9d3SPiotr Jasiukajtis return (u0[0] + tpi*logl(x));
2055b2ba9d3SPiotr Jasiukajtis }
2065b2ba9d3SPiotr Jasiukajtis z = x*x;
2075b2ba9d3SPiotr Jasiukajtis u = u0[7]; v = v0[7];
2085b2ba9d3SPiotr Jasiukajtis for(i=6;i>=0;i--) {
2095b2ba9d3SPiotr Jasiukajtis u = u*z + u0[i];
2105b2ba9d3SPiotr Jasiukajtis v = v*z + v0[i];
2115b2ba9d3SPiotr Jasiukajtis }
2125b2ba9d3SPiotr Jasiukajtis return(u/v + tpi*(j0l(x)*logl(x)));
2135b2ba9d3SPiotr Jasiukajtis }
2145b2ba9d3SPiotr Jasiukajtis
2155b2ba9d3SPiotr Jasiukajtis static const GENERIC pr0[12] = { /* [16 -- inf] */
2165b2ba9d3SPiotr Jasiukajtis 9.999999999999999999999999999999999997515e-0001L,
2175b2ba9d3SPiotr Jasiukajtis 1.065981615377273376425365823967550598358e+0003L,
2185b2ba9d3SPiotr Jasiukajtis 4.390991200927588978306374718984240719130e+0005L,
2195b2ba9d3SPiotr Jasiukajtis 9.072086218607986711847069407339321363103e+0007L,
2205b2ba9d3SPiotr Jasiukajtis 1.022552886177375367408408501046461671528e+0010L,
2215b2ba9d3SPiotr Jasiukajtis 6.420766912243658241570635854089597269031e+0011L,
2225b2ba9d3SPiotr Jasiukajtis 2.206451725126933913591080211081242266908e+0013L,
2235b2ba9d3SPiotr Jasiukajtis 3.928369596816895077363705478743346298368e+0014L,
2245b2ba9d3SPiotr Jasiukajtis 3.258159928874124597286701119721482876596e+0015L,
2255b2ba9d3SPiotr Jasiukajtis 1.025715808134188978860679130140685101348e+0016L,
2265b2ba9d3SPiotr Jasiukajtis 7.537170874795721255796001687024031280685e+0015L,
2275b2ba9d3SPiotr Jasiukajtis -1.579413901450157332307745586004207687796e+0014L,
2285b2ba9d3SPiotr Jasiukajtis };
2295b2ba9d3SPiotr Jasiukajtis static const GENERIC ps0[11] = {
2305b2ba9d3SPiotr Jasiukajtis 1.0e0L,
2315b2ba9d3SPiotr Jasiukajtis 1.066051927877273376425365823967550512687e+0003L,
2325b2ba9d3SPiotr Jasiukajtis 4.391739647168381592399173804329266353038e+0005L,
2335b2ba9d3SPiotr Jasiukajtis 9.075162261801343671805658294123888867884e+0007L,
2345b2ba9d3SPiotr Jasiukajtis 1.023186118519904751819581912075985995058e+0010L,
2355b2ba9d3SPiotr Jasiukajtis 6.427861860414223746340515376512730275061e+0011L,
2365b2ba9d3SPiotr Jasiukajtis 2.210861503237823589735481303627993406235e+0013L,
2375b2ba9d3SPiotr Jasiukajtis 3.943247335784292905915956840901818177989e+0014L,
2385b2ba9d3SPiotr Jasiukajtis 3.283720976777545142150200110647270004481e+0015L,
2395b2ba9d3SPiotr Jasiukajtis 1.045346918812754048903645641538728986759e+0016L,
2405b2ba9d3SPiotr Jasiukajtis 8.043455468065618900750599584291193680463e+0015L,
2415b2ba9d3SPiotr Jasiukajtis };
2425b2ba9d3SPiotr Jasiukajtis static const GENERIC pr1[12] = { /* [8 -- 16] */
2435b2ba9d3SPiotr Jasiukajtis 9.999999999999999999999784422701108683618e-0001L,
2445b2ba9d3SPiotr Jasiukajtis 6.796098532948334207755488692777907062894e+0002L,
2455b2ba9d3SPiotr Jasiukajtis 1.840036112605722168824530758797169836042e+0005L,
2465b2ba9d3SPiotr Jasiukajtis 2.598490483191916637264894340635847598122e+0007L,
2475b2ba9d3SPiotr Jasiukajtis 2.105774863242707025525730249472054578523e+0009L,
2485b2ba9d3SPiotr Jasiukajtis 1.015822044230542426666314997796944979959e+0011L,
2495b2ba9d3SPiotr Jasiukajtis 2.931557457008110436764077699944189071875e+0012L,
2505b2ba9d3SPiotr Jasiukajtis 4.962885121125457633655259224179322808824e+0013L,
2515b2ba9d3SPiotr Jasiukajtis 4.705424055148223269155430598563351566279e+0014L,
2525b2ba9d3SPiotr Jasiukajtis 2.294439854910747229152056080910427001110e+0015L,
2535b2ba9d3SPiotr Jasiukajtis 4.905531843137486691500950019322475458629e+0015L,
2545b2ba9d3SPiotr Jasiukajtis 3.187543169710339218793442542845735994565e+0015L,
2555b2ba9d3SPiotr Jasiukajtis };
2565b2ba9d3SPiotr Jasiukajtis static const GENERIC ps1[14] = {
2575b2ba9d3SPiotr Jasiukajtis 1.0e0L,
2585b2ba9d3SPiotr Jasiukajtis 6.796801657948334207754571576066758180288e+0002L,
2595b2ba9d3SPiotr Jasiukajtis 1.840512891201300567325421059826676366447e+0005L,
2605b2ba9d3SPiotr Jasiukajtis 2.599777028312918975306252167127695075221e+0007L,
2615b2ba9d3SPiotr Jasiukajtis 2.107582572771047636846811284634244892537e+0009L,
2625b2ba9d3SPiotr Jasiukajtis 1.017275794694156108975782763889979940348e+0011L,
2635b2ba9d3SPiotr Jasiukajtis 2.938487645192463845428059755454762316011e+0012L,
2645b2ba9d3SPiotr Jasiukajtis 4.982512164735557054521042916182317924466e+0013L,
2655b2ba9d3SPiotr Jasiukajtis 4.737639900153703274792677468264564361437e+0014L,
2665b2ba9d3SPiotr Jasiukajtis 2.323398719123742743524249528275097100646e+0015L,
2675b2ba9d3SPiotr Jasiukajtis 5.033419107069210577868909797896984419391e+0015L,
2685b2ba9d3SPiotr Jasiukajtis 3.409036105931068609601317076759804716059e+0015L,
2695b2ba9d3SPiotr Jasiukajtis 7.505655364352679737585745147753521662166e+0013L,
2705b2ba9d3SPiotr Jasiukajtis -9.976837153983688250780198248297109118313e+0012L,
2715b2ba9d3SPiotr Jasiukajtis };
2725b2ba9d3SPiotr Jasiukajtis static const GENERIC pr2[12] = { /* [5 -- 8 ] */
2735b2ba9d3SPiotr Jasiukajtis 9.999999999999999937857236789277366320220e-0001L,
2745b2ba9d3SPiotr Jasiukajtis 3.692848765268649571651602420376358849214e+0002L,
2755b2ba9d3SPiotr Jasiukajtis 5.373022067535476576926715900057760985410e+0004L,
2765b2ba9d3SPiotr Jasiukajtis 4.038738891191314969971504035057219430725e+0006L,
2775b2ba9d3SPiotr Jasiukajtis 1.728285706306940523397385566659762646999e+0008L,
2785b2ba9d3SPiotr Jasiukajtis 4.375400819645889911158688737206054788534e+0009L,
2795b2ba9d3SPiotr Jasiukajtis 6.598950418204912408375591217782088567076e+0010L,
2805b2ba9d3SPiotr Jasiukajtis 5.827182039183238492480275401520072793783e+0011L,
2815b2ba9d3SPiotr Jasiukajtis 2.884222642913492390887572414999490975844e+0012L,
2825b2ba9d3SPiotr Jasiukajtis 7.373278873797767721932837830628688632775e+0012L,
2835b2ba9d3SPiotr Jasiukajtis 8.338295457568973761205077964397969230489e+0012L,
2845b2ba9d3SPiotr Jasiukajtis 2.911383183467288345772308817209806922143e+0012L,
2855b2ba9d3SPiotr Jasiukajtis };
2865b2ba9d3SPiotr Jasiukajtis static const GENERIC ps2[14] = {
2875b2ba9d3SPiotr Jasiukajtis 1.0e0L,
2885b2ba9d3SPiotr Jasiukajtis 3.693551890268649477288896267171993213102e+0002L,
2895b2ba9d3SPiotr Jasiukajtis 5.375607880998361502474715133828068514297e+0004L,
2905b2ba9d3SPiotr Jasiukajtis 4.042477764024108249744998862572786367328e+0006L,
2915b2ba9d3SPiotr Jasiukajtis 1.731069838737016956685839588670132939513e+0008L,
2925b2ba9d3SPiotr Jasiukajtis 4.387147674049898778738226585935491417728e+0009L,
2935b2ba9d3SPiotr Jasiukajtis 6.628058659620653765349556940567715258165e+0010L,
2945b2ba9d3SPiotr Jasiukajtis 5.869659904164177740471685856367322160664e+0011L,
2955b2ba9d3SPiotr Jasiukajtis 2.919839445622817017058977559638969436383e+0012L,
2965b2ba9d3SPiotr Jasiukajtis 7.535314897696671402628203718612309253907e+0012L,
2975b2ba9d3SPiotr Jasiukajtis 8.696355561452933775773309859748610658935e+0012L,
2985b2ba9d3SPiotr Jasiukajtis 3.216155103141537221173601557697083216257e+0012L,
2995b2ba9d3SPiotr Jasiukajtis 4.756857081068942248246880159213789086363e+0010L,
3005b2ba9d3SPiotr Jasiukajtis -3.496356619666608032231074866481472824067e+0009L,
3015b2ba9d3SPiotr Jasiukajtis };
3025b2ba9d3SPiotr Jasiukajtis static const GENERIC pr3[13] = { /* [3.5 -- 5 ] */
3035b2ba9d3SPiotr Jasiukajtis 9.999999999999916693107285612398196588247e-0001L,
3045b2ba9d3SPiotr Jasiukajtis 2.263975921282917721194425320484974336945e+0002L,
3055b2ba9d3SPiotr Jasiukajtis 1.994358386744245848889492762781484199966e+0004L,
3065b2ba9d3SPiotr Jasiukajtis 8.980067458430542243559962493831661323168e+0005L,
3075b2ba9d3SPiotr Jasiukajtis 2.282213787521372663705567756420087553508e+0007L,
3085b2ba9d3SPiotr Jasiukajtis 3.409784374889063618250288699908375135923e+0008L,
3095b2ba9d3SPiotr Jasiukajtis 3.024380857401448589254343517589811711108e+0009L,
3105b2ba9d3SPiotr Jasiukajtis 1.571110368046740246895071721443082286379e+0010L,
3115b2ba9d3SPiotr Jasiukajtis 4.603187020243604632153685300463160593768e+0010L,
3125b2ba9d3SPiotr Jasiukajtis 7.087196453409712719449549280664058793403e+0010L,
3135b2ba9d3SPiotr Jasiukajtis 5.046196021776346356803687409644239065041e+0010L,
3145b2ba9d3SPiotr Jasiukajtis 1.287758439080165765709154276618854799932e+0010L,
3155b2ba9d3SPiotr Jasiukajtis 5.900679773415023433787846658096813590784e+0008L,
3165b2ba9d3SPiotr Jasiukajtis };
3175b2ba9d3SPiotr Jasiukajtis static const GENERIC ps3[13] = {
3185b2ba9d3SPiotr Jasiukajtis 1.0e0L,
3195b2ba9d3SPiotr Jasiukajtis 2.264679046282855061328604619231774747116e+0002L,
3205b2ba9d3SPiotr Jasiukajtis 1.995939523988944553755653255389812103448e+0004L,
3215b2ba9d3SPiotr Jasiukajtis 8.993853144706348727038389967490183236820e+0005L,
3225b2ba9d3SPiotr Jasiukajtis 2.288326099634588843906989983704795468773e+0007L,
3235b2ba9d3SPiotr Jasiukajtis 3.424967100255240885169240956804790118282e+0008L,
3245b2ba9d3SPiotr Jasiukajtis 3.046311797972463991368023759640028910016e+0009L,
3255b2ba9d3SPiotr Jasiukajtis 1.589614961932826812790222479700797224003e+0010L,
3265b2ba9d3SPiotr Jasiukajtis 4.692406624527744816497089139325073939927e+0010L,
3275b2ba9d3SPiotr Jasiukajtis 7.320486495902008912866462849073108323948e+0010L,
3285b2ba9d3SPiotr Jasiukajtis 5.345945972828978289935309597742981360994e+0010L,
3295b2ba9d3SPiotr Jasiukajtis 1.444033091910423754121309915092247171008e+0010L,
3305b2ba9d3SPiotr Jasiukajtis 7.987714685115314668378957273824383610525e+0008L,
3315b2ba9d3SPiotr Jasiukajtis };
3325b2ba9d3SPiotr Jasiukajtis static const GENERIC pr4[13] = { /* [2.5, 3.5] */
3335b2ba9d3SPiotr Jasiukajtis 9.999999999986736677961118722747757712260e-0001L,
3345b2ba9d3SPiotr Jasiukajtis 1.453824980703800559037873123568378845663e+0002L,
3355b2ba9d3SPiotr Jasiukajtis 8.097327216430682288267610447006508661032e+0003L,
3365b2ba9d3SPiotr Jasiukajtis 2.273847252038264370231169686380192662135e+0005L,
3375b2ba9d3SPiotr Jasiukajtis 3.561056728046211111354759998976985449622e+0006L,
3385b2ba9d3SPiotr Jasiukajtis 3.244933588800096378434627029369680378599e+0007L,
3395b2ba9d3SPiotr Jasiukajtis 1.740112392860717950376210038908476792588e+0008L,
3405b2ba9d3SPiotr Jasiukajtis 5.426170187455893285197878563881579269524e+0008L,
3415b2ba9d3SPiotr Jasiukajtis 9.490107486454362321004377336020526281371e+0008L,
3425b2ba9d3SPiotr Jasiukajtis 8.688872439428470049801714121070005313806e+0008L,
3435b2ba9d3SPiotr Jasiukajtis 3.673315853166437222811910656900123215515e+0008L,
3445b2ba9d3SPiotr Jasiukajtis 5.577770470359303305164877446339693270239e+0007L,
3455b2ba9d3SPiotr Jasiukajtis 1.540438642031689641308197880181291865714e+0006L,
3465b2ba9d3SPiotr Jasiukajtis };
3475b2ba9d3SPiotr Jasiukajtis static const GENERIC ps4[13] = { /* [2.5, 3.5] */
3485b2ba9d3SPiotr Jasiukajtis 1.0e0L,
3495b2ba9d3SPiotr Jasiukajtis 1.454528105698159439773035951959131799816e+0002L,
3505b2ba9d3SPiotr Jasiukajtis 8.107442215200392397172179900434987859618e+0003L,
3515b2ba9d3SPiotr Jasiukajtis 2.279390393778242887574177096606328994140e+0005L,
3525b2ba9d3SPiotr Jasiukajtis 3.576251625592252008424781111770934135844e+0006L,
3535b2ba9d3SPiotr Jasiukajtis 3.267909499056932631405942058670933813863e+0007L,
3545b2ba9d3SPiotr Jasiukajtis 1.760021515330805537499778238099704648805e+0008L,
3555b2ba9d3SPiotr Jasiukajtis 5.525553787667353981242060222587465726729e+0008L,
3565b2ba9d3SPiotr Jasiukajtis 9.769870295912820457889384082671269328511e+0008L,
3575b2ba9d3SPiotr Jasiukajtis 9.110582071004774279226905629624018008454e+0008L,
3585b2ba9d3SPiotr Jasiukajtis 3.981857678621955599371967680343918454345e+0008L,
3595b2ba9d3SPiotr Jasiukajtis 6.482404686230769399073192961667697036706e+0007L,
3605b2ba9d3SPiotr Jasiukajtis 2.210046943095878402443535460329391782298e+0006L,
3615b2ba9d3SPiotr Jasiukajtis };
3625b2ba9d3SPiotr Jasiukajtis static const GENERIC pr5[13] = { /* [1.777..., 2.5] */
3635b2ba9d3SPiotr Jasiukajtis 9.999999999114986107951817871144655880699e-0001L,
3645b2ba9d3SPiotr Jasiukajtis 9.252583736048588342568344570315435947614e+0001L,
3655b2ba9d3SPiotr Jasiukajtis 3.218726757856078715214631502407386264637e+0003L,
3665b2ba9d3SPiotr Jasiukajtis 5.554009964621111656479588505862577040831e+0004L,
3675b2ba9d3SPiotr Jasiukajtis 5.269993115643664338253196944523510290175e+0005L,
3685b2ba9d3SPiotr Jasiukajtis 2.874613773778430691192912190618220544575e+0006L,
3695b2ba9d3SPiotr Jasiukajtis 9.133538151103658353874146919613442436035e+0006L,
3705b2ba9d3SPiotr Jasiukajtis 1.673067041410338922825193013077354249193e+0007L,
3715b2ba9d3SPiotr Jasiukajtis 1.706913873848398011744790289200151840498e+0007L,
3725b2ba9d3SPiotr Jasiukajtis 9.067766583853288534551600235576747618679e+0006L,
3735b2ba9d3SPiotr Jasiukajtis 2.216746733457884568532695355036338655872e+0006L,
3745b2ba9d3SPiotr Jasiukajtis 1.945753880802872541235703812722344514405e+0005L,
3755b2ba9d3SPiotr Jasiukajtis 3.132374412921948071539195638885330951749e+0003L,
3765b2ba9d3SPiotr Jasiukajtis };
3775b2ba9d3SPiotr Jasiukajtis static const GENERIC ps5[13] = { /* [1.777..., 2.5] */
3785b2ba9d3SPiotr Jasiukajtis 1.0e0L,
3795b2ba9d3SPiotr Jasiukajtis 9.259614983862181118883831670990340052982e+0001L,
3805b2ba9d3SPiotr Jasiukajtis 3.225125275462903384842124075132609290304e+0003L,
3815b2ba9d3SPiotr Jasiukajtis 5.575705362829101545292760055941855246492e+0004L,
3825b2ba9d3SPiotr Jasiukajtis 5.306049863037087855496170121958448492522e+0005L,
3835b2ba9d3SPiotr Jasiukajtis 2.907060758873509564309729903109018597215e+0006L,
3845b2ba9d3SPiotr Jasiukajtis 9.298059206584995898298257827131208539289e+0006L,
3855b2ba9d3SPiotr Jasiukajtis 1.720391071006963176836108026556547062980e+0007L,
3865b2ba9d3SPiotr Jasiukajtis 1.782614812922865190479394509487941920612e+0007L,
3875b2ba9d3SPiotr Jasiukajtis 9.708016389605273153536452032839879950155e+0006L,
3885b2ba9d3SPiotr Jasiukajtis 2.476495084688170096480215640962175140027e+0006L,
3895b2ba9d3SPiotr Jasiukajtis 2.363200660365585759668077790194604917187e+0005L,
3905b2ba9d3SPiotr Jasiukajtis 4.803239569848196077121203575704356936731e+0003L,
3915b2ba9d3SPiotr Jasiukajtis };
3925b2ba9d3SPiotr Jasiukajtis static const GENERIC pr6[13] = { /* [1.28, 1.777...] */
3935b2ba9d3SPiotr Jasiukajtis 9.999999969777095495998606925524322559556e-0001L,
3945b2ba9d3SPiotr Jasiukajtis 5.825486719466194430503283824096872219216e+0001L,
3955b2ba9d3SPiotr Jasiukajtis 1.248155491637757281915184824965379905380e+0003L,
3965b2ba9d3SPiotr Jasiukajtis 1.302093199842358609321338417071710477615e+0004L,
3975b2ba9d3SPiotr Jasiukajtis 7.353835804186292782840961999810543016039e+0004L,
3985b2ba9d3SPiotr Jasiukajtis 2.356471661113686180549195092555751341757e+0005L,
3995b2ba9d3SPiotr Jasiukajtis 4.350553267429009581632987060942780847101e+0005L,
4005b2ba9d3SPiotr Jasiukajtis 4.588762661876600638719159826652389418235e+0005L,
4015b2ba9d3SPiotr Jasiukajtis 2.675796398548523436544221045225290128611e+0005L,
4025b2ba9d3SPiotr Jasiukajtis 8.077649557108971388298292919988449940464e+0004L,
4035b2ba9d3SPiotr Jasiukajtis 1.117640459221306873519068741664054573776e+0004L,
4045b2ba9d3SPiotr Jasiukajtis 5.544400072396814695175787511557757885585e+0002L,
4055b2ba9d3SPiotr Jasiukajtis 5.072550541191480498431289089905822910718e+0000L,
4065b2ba9d3SPiotr Jasiukajtis };
4075b2ba9d3SPiotr Jasiukajtis static const GENERIC ps6[13] = { /* [1.28, 1.777...] */
4085b2ba9d3SPiotr Jasiukajtis 1.0e0L,
4095b2ba9d3SPiotr Jasiukajtis 5.832517925357165050639075848183613063291e+0001L,
4105b2ba9d3SPiotr Jasiukajtis 1.252144364743592128171256104364976466898e+0003L,
4115b2ba9d3SPiotr Jasiukajtis 1.310300234342216813579118022415585740772e+0004L,
4125b2ba9d3SPiotr Jasiukajtis 7.434667697093812197817292154032863632923e+0004L,
4135b2ba9d3SPiotr Jasiukajtis 2.398706595587719165726469002404004614711e+0005L,
4145b2ba9d3SPiotr Jasiukajtis 4.472737517625103157004869372427480602511e+0005L,
4155b2ba9d3SPiotr Jasiukajtis 4.786313523337761975294171429067037723611e+0005L,
4165b2ba9d3SPiotr Jasiukajtis 2.851161872872731228472536061865365370192e+0005L,
4175b2ba9d3SPiotr Jasiukajtis 8.891648269899148412331918021801385815586e+0004L,
4185b2ba9d3SPiotr Jasiukajtis 1.297097489535351517572978123584751042287e+0004L,
4195b2ba9d3SPiotr Jasiukajtis 7.096761640545975756202184143400469812618e+0002L,
4205b2ba9d3SPiotr Jasiukajtis 8.378049338590233325977702401733340820351e+0000L,
4215b2ba9d3SPiotr Jasiukajtis };
4225b2ba9d3SPiotr Jasiukajtis static const GENERIC sixteen = 16.0L;
4235b2ba9d3SPiotr Jasiukajtis static const GENERIC huge = 1.0e30L;
4245b2ba9d3SPiotr Jasiukajtis
pzero(x)4255b2ba9d3SPiotr Jasiukajtis static GENERIC pzero(x)
4265b2ba9d3SPiotr Jasiukajtis GENERIC x;
4275b2ba9d3SPiotr Jasiukajtis {
4285b2ba9d3SPiotr Jasiukajtis GENERIC s,r,t,z;
4295b2ba9d3SPiotr Jasiukajtis int i;
4305b2ba9d3SPiotr Jasiukajtis if (x>huge) return one;
4315b2ba9d3SPiotr Jasiukajtis t = one/x; z = t*t;
4325b2ba9d3SPiotr Jasiukajtis if (x>sixteen) {
4335b2ba9d3SPiotr Jasiukajtis r = z*pr0[11]+pr0[10]; s = ps0[10];
4345b2ba9d3SPiotr Jasiukajtis for (i=9;i>=0;i--) {
4355b2ba9d3SPiotr Jasiukajtis r = z*r + pr0[i];
4365b2ba9d3SPiotr Jasiukajtis s = z*s + ps0[i];
4375b2ba9d3SPiotr Jasiukajtis }
4385b2ba9d3SPiotr Jasiukajtis } else if (x > eight) {
4395b2ba9d3SPiotr Jasiukajtis r = pr1[11]; s = ps1[11]+z*(ps1[12]+z*ps1[13]);
4405b2ba9d3SPiotr Jasiukajtis for (i=10;i>=0;i--) {
4415b2ba9d3SPiotr Jasiukajtis r = z*r + pr1[i];
4425b2ba9d3SPiotr Jasiukajtis s = z*s + ps1[i];
4435b2ba9d3SPiotr Jasiukajtis }
4445b2ba9d3SPiotr Jasiukajtis } else if (x > five) { /* x > 5.0 */
4455b2ba9d3SPiotr Jasiukajtis r = pr2[11]; s = ps2[11]+z*(ps2[12]+z*ps2[13]);
4465b2ba9d3SPiotr Jasiukajtis for (i=10;i>=0;i--) {
4475b2ba9d3SPiotr Jasiukajtis r = z*r + pr2[i];
4485b2ba9d3SPiotr Jasiukajtis s = z*s + ps2[i];
4495b2ba9d3SPiotr Jasiukajtis }
4505b2ba9d3SPiotr Jasiukajtis } else if (x>3.5L) {
4515b2ba9d3SPiotr Jasiukajtis r = pr3[12]; s = ps3[12];
4525b2ba9d3SPiotr Jasiukajtis for (i=11;i>=0;i--) {
4535b2ba9d3SPiotr Jasiukajtis r = z*r + pr3[i];
4545b2ba9d3SPiotr Jasiukajtis s = z*s + ps3[i];
4555b2ba9d3SPiotr Jasiukajtis }
4565b2ba9d3SPiotr Jasiukajtis } else if (x>2.5L) {
4575b2ba9d3SPiotr Jasiukajtis r = pr4[12]; s = ps4[12];
4585b2ba9d3SPiotr Jasiukajtis for (i=11;i>=0;i--) {
4595b2ba9d3SPiotr Jasiukajtis r = z*r + pr4[i];
4605b2ba9d3SPiotr Jasiukajtis s = z*s + ps4[i];
4615b2ba9d3SPiotr Jasiukajtis }
4625b2ba9d3SPiotr Jasiukajtis } else if (x> (1.0L/0.5625L)) {
4635b2ba9d3SPiotr Jasiukajtis r = pr5[12]; s = ps5[12];
4645b2ba9d3SPiotr Jasiukajtis for (i=11;i>=0;i--) {
4655b2ba9d3SPiotr Jasiukajtis r = z*r + pr5[i];
4665b2ba9d3SPiotr Jasiukajtis s = z*s + ps5[i];
4675b2ba9d3SPiotr Jasiukajtis }
4685b2ba9d3SPiotr Jasiukajtis } else { /* assume x > 1.28 */
4695b2ba9d3SPiotr Jasiukajtis r = pr6[12]; s = ps6[12];
4705b2ba9d3SPiotr Jasiukajtis for (i=11;i>=0;i--) {
4715b2ba9d3SPiotr Jasiukajtis r = z*r + pr6[i];
4725b2ba9d3SPiotr Jasiukajtis s = z*s + ps6[i];
4735b2ba9d3SPiotr Jasiukajtis }
4745b2ba9d3SPiotr Jasiukajtis }
4755b2ba9d3SPiotr Jasiukajtis return r/s;
4765b2ba9d3SPiotr Jasiukajtis }
4775b2ba9d3SPiotr Jasiukajtis
4785b2ba9d3SPiotr Jasiukajtis
4795b2ba9d3SPiotr Jasiukajtis static const GENERIC qr0[12] = { /* [16, inf] */
4805b2ba9d3SPiotr Jasiukajtis -1.249999999999999999999999999999999972972e-0001L,
4815b2ba9d3SPiotr Jasiukajtis -1.425179595545670577414395762503991596897e+0002L,
4825b2ba9d3SPiotr Jasiukajtis -6.312499645625970845534460257936222407219e+0004L,
4835b2ba9d3SPiotr Jasiukajtis -1.411374326457208384315121243698814446848e+0007L,
4845b2ba9d3SPiotr Jasiukajtis -1.735034212758873581410984757860787252842e+0009L,
4855b2ba9d3SPiotr Jasiukajtis -1.199777647512789489421826342485055280680e+0011L,
4865b2ba9d3SPiotr Jasiukajtis -4.596025334081655714499860409699100373644e+0012L,
4875b2ba9d3SPiotr Jasiukajtis -9.262525628201284107792924477031653399187e+0013L,
4885b2ba9d3SPiotr Jasiukajtis -8.858394728685039245344398842180662867639e+0014L,
4895b2ba9d3SPiotr Jasiukajtis -3.267527953687534887623740622709505972113e+0015L,
4905b2ba9d3SPiotr Jasiukajtis -2.664222971186311967587129347029450062019e+0015L,
4915b2ba9d3SPiotr Jasiukajtis 3.442464060723987869585180095344504100204e+0014L,
4925b2ba9d3SPiotr Jasiukajtis };
4935b2ba9d3SPiotr Jasiukajtis static const GENERIC qs0[11] = {
4945b2ba9d3SPiotr Jasiukajtis 1.0e0L,
4955b2ba9d3SPiotr Jasiukajtis 1.140729613936536461931516610003185687881e+0003L,
4965b2ba9d3SPiotr Jasiukajtis 5.056665510442299351009198186490085803580e+0005L,
4975b2ba9d3SPiotr Jasiukajtis 1.132041763825642787943941650522718199115e+0008L,
4985b2ba9d3SPiotr Jasiukajtis 1.394570111872581606392620678214246479767e+0010L,
4995b2ba9d3SPiotr Jasiukajtis 9.677945218152264789534431079563744378421e+0011L,
5005b2ba9d3SPiotr Jasiukajtis 3.731140327851536828225143058896348502096e+0013L,
5015b2ba9d3SPiotr Jasiukajtis 7.612785951064869291722846681020881676410e+0014L,
5025b2ba9d3SPiotr Jasiukajtis 7.476077016406764891730191004811863975940e+0015L,
5035b2ba9d3SPiotr Jasiukajtis 2.951246482613592035421503427100393831709e+0016L,
5045b2ba9d3SPiotr Jasiukajtis 3.108361803691811711136854587074302034901e+0016L,
5055b2ba9d3SPiotr Jasiukajtis };
5065b2ba9d3SPiotr Jasiukajtis static const GENERIC qr1[12] = { /* [8, 16 ] */
5075b2ba9d3SPiotr Jasiukajtis -1.249999999999999999997949010383433818157e-0001L,
5085b2ba9d3SPiotr Jasiukajtis -9.051215166393822640636752244895124126934e+0001L,
5095b2ba9d3SPiotr Jasiukajtis -2.620782703428148837671179031904208303947e+0004L,
5105b2ba9d3SPiotr Jasiukajtis -3.975571261553504457766177974508785790884e+0006L,
5115b2ba9d3SPiotr Jasiukajtis -3.479029330759311306270072218074074994090e+0008L,
5125b2ba9d3SPiotr Jasiukajtis -1.823955008124268573036216746186239829089e+0010L,
5135b2ba9d3SPiotr Jasiukajtis -5.765932697111801375765156029221568664435e+0011L,
5145b2ba9d3SPiotr Jasiukajtis -1.079843680798742592954002192417934779114e+0013L,
5155b2ba9d3SPiotr Jasiukajtis -1.146893630504592739082205764611581332897e+0014L,
5165b2ba9d3SPiotr Jasiukajtis -6.367016059683898464936104447282880704182e+0014L,
5175b2ba9d3SPiotr Jasiukajtis -1.583109041961213490464459111903484209098e+0015L,
5185b2ba9d3SPiotr Jasiukajtis -1.230149555764242473103128650135795639412e+0015L,
5195b2ba9d3SPiotr Jasiukajtis };
5205b2ba9d3SPiotr Jasiukajtis static const GENERIC qs1[14] = {
5215b2ba9d3SPiotr Jasiukajtis 1.0e0L,
5225b2ba9d3SPiotr Jasiukajtis 7.246831508115058112438579847778014458432e+0002L,
5235b2ba9d3SPiotr Jasiukajtis 2.100854184439168518399383786306927037611e+0005L,
5245b2ba9d3SPiotr Jasiukajtis 3.192636418837951507430188285940994235122e+0007L,
5255b2ba9d3SPiotr Jasiukajtis 2.801558443383354674538443461124434216152e+0009L,
5265b2ba9d3SPiotr Jasiukajtis 1.475026997664373739293483927250653467487e+0011L,
5275b2ba9d3SPiotr Jasiukajtis 4.694486824913954608552363821799927145318e+0012L,
5285b2ba9d3SPiotr Jasiukajtis 8.890350100919200250838438709601547334021e+0013L,
5295b2ba9d3SPiotr Jasiukajtis 9.626844429082905144874701068760469752067e+0014L,
5305b2ba9d3SPiotr Jasiukajtis 5.541110744600460773528263862687521642140e+0015L,
5315b2ba9d3SPiotr Jasiukajtis 1.486500494789452556727470329232123096563e+0016L,
5325b2ba9d3SPiotr Jasiukajtis 1.415840104845959400365430773732093899210e+0016L,
5335b2ba9d3SPiotr Jasiukajtis 1.780866095241517418081312567239682336483e+0015L,
5345b2ba9d3SPiotr Jasiukajtis -2.359230917384889357887631544079990129494e+0014L,
5355b2ba9d3SPiotr Jasiukajtis };
5365b2ba9d3SPiotr Jasiukajtis static const GENERIC qr2[12] = { /* [5, 8] */
5375b2ba9d3SPiotr Jasiukajtis -1.249999999999999531937744362527772181614e-0001L,
5385b2ba9d3SPiotr Jasiukajtis -4.944373897356969774839375977239241573966e+0001L,
5395b2ba9d3SPiotr Jasiukajtis -7.728449175433465285314261650078450473909e+0003L,
5405b2ba9d3SPiotr Jasiukajtis -6.262574329612752346336901434651220705903e+0005L,
5415b2ba9d3SPiotr Jasiukajtis -2.900948220220943306027235217424380672732e+0007L,
5425b2ba9d3SPiotr Jasiukajtis -7.988719647634192770463917157562874119535e+0008L,
5435b2ba9d3SPiotr Jasiukajtis -1.318228171927181389547760026626357012375e+0010L,
5445b2ba9d3SPiotr Jasiukajtis -1.282439773983029245309263271945424928196e+0011L,
5455b2ba9d3SPiotr Jasiukajtis -7.050925570827818040186149940257918845138e+0011L,
5465b2ba9d3SPiotr Jasiukajtis -2.021751882573871990004205616874202684429e+0012L,
5475b2ba9d3SPiotr Jasiukajtis -2.592939962400668552384333900573812635658e+0012L,
5485b2ba9d3SPiotr Jasiukajtis -1.038267109518891262840601514932972850326e+0012L,
5495b2ba9d3SPiotr Jasiukajtis };
5505b2ba9d3SPiotr Jasiukajtis static const GENERIC qs2[14] = {
5515b2ba9d3SPiotr Jasiukajtis 1.0e0L,
5525b2ba9d3SPiotr Jasiukajtis 3.961358492885570003202784022894248952116e+0002L,
5535b2ba9d3SPiotr Jasiukajtis 6.205788738864701882828752634586510926968e+0004L,
5545b2ba9d3SPiotr Jasiukajtis 5.045715603932670286550673813011764406749e+0006L,
5555b2ba9d3SPiotr Jasiukajtis 2.349248611362658323353343389430968751429e+0008L,
5565b2ba9d3SPiotr Jasiukajtis 6.520244524415828635917683553721880063911e+0009L,
5575b2ba9d3SPiotr Jasiukajtis 1.089111211223507719337067159886281887722e+0011L,
5585b2ba9d3SPiotr Jasiukajtis 1.080406000905359867958779409414903018610e+0012L,
5595b2ba9d3SPiotr Jasiukajtis 6.135645280895514703514154680623769562148e+0012L,
5605b2ba9d3SPiotr Jasiukajtis 1.862433040246625874245867151368643668215e+0013L,
5615b2ba9d3SPiotr Jasiukajtis 2.667780805786648888840777888702193708994e+0013L,
5625b2ba9d3SPiotr Jasiukajtis 1.394401107289087774765300711809313112824e+0013L,
5635b2ba9d3SPiotr Jasiukajtis 1.093247500616320375562898297156722445484e+0012L,
5645b2ba9d3SPiotr Jasiukajtis -7.228875530378928722826604216491493780775e+0010L,
5655b2ba9d3SPiotr Jasiukajtis };
5665b2ba9d3SPiotr Jasiukajtis static const GENERIC qr3[13] = { /* [3.5 5] */
5675b2ba9d3SPiotr Jasiukajtis -1.249999999999473067748420379578481661075e-0001L,
5685b2ba9d3SPiotr Jasiukajtis -3.044549048635289351913574324803250977998e+0001L,
5695b2ba9d3SPiotr Jasiukajtis -2.890081140649769078496693003524681440869e+0003L,
5705b2ba9d3SPiotr Jasiukajtis -1.404922456817202235879343275330529107684e+0005L,
5715b2ba9d3SPiotr Jasiukajtis -3.862746614385573443518177403617349281869e+0006L,
5725b2ba9d3SPiotr Jasiukajtis -6.257517309110249049201133708911155047689e+0007L,
5735b2ba9d3SPiotr Jasiukajtis -6.031451330920839916987079782727323477520e+0008L,
5745b2ba9d3SPiotr Jasiukajtis -3.411542405173830611454025765755854382346e+0009L,
5755b2ba9d3SPiotr Jasiukajtis -1.089392478149726672133014498723021526099e+0010L,
5765b2ba9d3SPiotr Jasiukajtis -1.824934078420210941290140903415956782726e+0010L,
5775b2ba9d3SPiotr Jasiukajtis -1.400780278304358710423481070486939531139e+0010L,
5785b2ba9d3SPiotr Jasiukajtis -3.716484136064917363926635716743771092093e+0009L,
5795b2ba9d3SPiotr Jasiukajtis -1.397591075296425529970434890954904331580e+0008L,
5805b2ba9d3SPiotr Jasiukajtis };
5815b2ba9d3SPiotr Jasiukajtis static const GENERIC qs3[13] = {
5825b2ba9d3SPiotr Jasiukajtis 1.0e0L,
5835b2ba9d3SPiotr Jasiukajtis 2.441498613904962049391000187014945858042e+0002L,
5845b2ba9d3SPiotr Jasiukajtis 2.326188882072370711500164222341514337043e+0004L,
5855b2ba9d3SPiotr Jasiukajtis 1.137138213121231338494977104659239578165e+0006L,
5865b2ba9d3SPiotr Jasiukajtis 3.152918070735662728722998452605364253517e+0007L,
5875b2ba9d3SPiotr Jasiukajtis 5.172877993426507259314270488444013595108e+0008L,
5885b2ba9d3SPiotr Jasiukajtis 5.083086439731669807455961078856470774115e+0009L,
5895b2ba9d3SPiotr Jasiukajtis 2.961842732066434123119325521139476909941e+0010L,
5905b2ba9d3SPiotr Jasiukajtis 9.912185866862440735829781856081353151390e+0010L,
5915b2ba9d3SPiotr Jasiukajtis 1.793560561251622234430564181567297983598e+0011L,
5925b2ba9d3SPiotr Jasiukajtis 1.577090119341228122525265108497940403073e+0011L,
5935b2ba9d3SPiotr Jasiukajtis 5.509910306780166194333889999985463681636e+0010L,
5945b2ba9d3SPiotr Jasiukajtis 4.761691134078874491202320181517936758141e+0009L,
5955b2ba9d3SPiotr Jasiukajtis };
5965b2ba9d3SPiotr Jasiukajtis static const GENERIC qr4[13] = { /* [2.5 3.5] */
5975b2ba9d3SPiotr Jasiukajtis -1.249999999928567734339745043490705340835e-0001L,
5985b2ba9d3SPiotr Jasiukajtis -1.967201748731419063051601624435565528481e+0001L,
5995b2ba9d3SPiotr Jasiukajtis -1.186329146714562236407099740615528170707e+0003L,
6005b2ba9d3SPiotr Jasiukajtis -3.607736959222941810356301491152457934060e+0004L,
6015b2ba9d3SPiotr Jasiukajtis -6.119200717978104904932828468575194267125e+0005L,
6025b2ba9d3SPiotr Jasiukajtis -6.037847781158358226670305078652205586384e+0006L,
6035b2ba9d3SPiotr Jasiukajtis -3.503558153336140359700536720393565984740e+0007L,
6045b2ba9d3SPiotr Jasiukajtis -1.180196478268225718757218523746787309773e+0008L,
6055b2ba9d3SPiotr Jasiukajtis -2.221860232085134915841426363505169680528e+0008L,
6065b2ba9d3SPiotr Jasiukajtis -2.173372505452747585296176761701746236760e+0008L,
6075b2ba9d3SPiotr Jasiukajtis -9.649364865061237558517730539506568013963e+0007L,
6085b2ba9d3SPiotr Jasiukajtis -1.465429227847933034546039640094862650385e+0007L,
6095b2ba9d3SPiotr Jasiukajtis -3.083003197920262085170581866246663380607e+0005L,
6105b2ba9d3SPiotr Jasiukajtis };
6115b2ba9d3SPiotr Jasiukajtis static const GENERIC qs4[13] = { /* [2.5 3.5] */
6125b2ba9d3SPiotr Jasiukajtis 1.0e0L,
6135b2ba9d3SPiotr Jasiukajtis 1.579620773732259142752614142139986854055e+0002L,
6145b2ba9d3SPiotr Jasiukajtis 9.581372220329138733203879503753685054968e+0003L,
6155b2ba9d3SPiotr Jasiukajtis 2.939598672379108095776114131010825885308e+0005L,
6165b2ba9d3SPiotr Jasiukajtis 5.052183049314542218630341818692588448168e+0006L,
6175b2ba9d3SPiotr Jasiukajtis 5.083497695595206639433839326338971980149e+0007L,
6185b2ba9d3SPiotr Jasiukajtis 3.036385361800553388049719014005099206516e+0008L,
6195b2ba9d3SPiotr Jasiukajtis 1.067826481452753409910563785161661492137e+0009L,
6205b2ba9d3SPiotr Jasiukajtis 2.145644125557118044720741775125319669272e+0009L,
6215b2ba9d3SPiotr Jasiukajtis 2.324115615959719949363946673491552216799e+0009L,
6225b2ba9d3SPiotr Jasiukajtis 1.223262962112070757966959855619847011146e+0009L,
6235b2ba9d3SPiotr Jasiukajtis 2.569765553318495423738478585947110270709e+0008L,
6245b2ba9d3SPiotr Jasiukajtis 1.354744744299227127897905787732636565504e+0007L,
6255b2ba9d3SPiotr Jasiukajtis };
6265b2ba9d3SPiotr Jasiukajtis static const GENERIC qr5[13] = { /* [1.777.., 2.5] */
6275b2ba9d3SPiotr Jasiukajtis -1.249999995936639697637680428174576069971e-0001L,
6285b2ba9d3SPiotr Jasiukajtis -1.260846055371311453485891923426489068315e+0001L,
6295b2ba9d3SPiotr Jasiukajtis -4.772398467544467480801174330290141578895e+0002L,
6305b2ba9d3SPiotr Jasiukajtis -8.939852599990298486613760833996490599724e+0003L,
6315b2ba9d3SPiotr Jasiukajtis -9.184070787149542050979542226446134243197e+0004L,
6325b2ba9d3SPiotr Jasiukajtis -5.406038945018274458362637897739280435171e+0005L,
6335b2ba9d3SPiotr Jasiukajtis -1.845896544705190261018653728678171084418e+0006L,
6345b2ba9d3SPiotr Jasiukajtis -3.613616990680809501878667570653308071547e+0006L,
6355b2ba9d3SPiotr Jasiukajtis -3.908782978135693252252557720414348623779e+0006L,
6365b2ba9d3SPiotr Jasiukajtis -2.173711022517323927109138170588442768176e+0006L,
6375b2ba9d3SPiotr Jasiukajtis -5.431253130679918485836408549007856244495e+0005L,
6385b2ba9d3SPiotr Jasiukajtis -4.591098546452684510082591587275940765959e+0004L,
6395b2ba9d3SPiotr Jasiukajtis -5.244711364168207806835520057792229646578e+0002L,
6405b2ba9d3SPiotr Jasiukajtis };
6415b2ba9d3SPiotr Jasiukajtis static const GENERIC qs5[13] = { /* [1.777.., 2.5] */
6425b2ba9d3SPiotr Jasiukajtis 1.0e0L,
6435b2ba9d3SPiotr Jasiukajtis 1.014536210851290878350892750972474861447e+0002L,
6445b2ba9d3SPiotr Jasiukajtis 3.875547510687135314064434160096139681076e+0003L,
6455b2ba9d3SPiotr Jasiukajtis 7.361913122670079814955259281995617732580e+0004L,
6465b2ba9d3SPiotr Jasiukajtis 7.720288944218771126581086539585529314636e+0005L,
6475b2ba9d3SPiotr Jasiukajtis 4.681529554446752496404431433608306558038e+0006L,
6485b2ba9d3SPiotr Jasiukajtis 1.667882621940503925455031252308367745820e+0007L,
6495b2ba9d3SPiotr Jasiukajtis 3.469403153761399881888272620855305156241e+0007L,
6505b2ba9d3SPiotr Jasiukajtis 4.096992047964210711867089384719947863019e+0007L,
6515b2ba9d3SPiotr Jasiukajtis 2.596804755829217449311530735959560630554e+0007L,
6525b2ba9d3SPiotr Jasiukajtis 7.983933774697889238154465064019410763845e+0006L,
6535b2ba9d3SPiotr Jasiukajtis 9.818133816979900819087242425280757938152e+0005L,
6545b2ba9d3SPiotr Jasiukajtis 3.061083930868694396013541535670745443560e+0004L,
6555b2ba9d3SPiotr Jasiukajtis };
6565b2ba9d3SPiotr Jasiukajtis
6575b2ba9d3SPiotr Jasiukajtis static const GENERIC qr6[13] = { /* [1.28, 1.777..] */
6585b2ba9d3SPiotr Jasiukajtis -1.249999881577289001807137282824929082771e-0001L,
6595b2ba9d3SPiotr Jasiukajtis -7.998273510053110759610810594119533619282e+0000L,
6605b2ba9d3SPiotr Jasiukajtis -1.872481955335172543369089617771565632719e+0002L,
6615b2ba9d3SPiotr Jasiukajtis -2.122116786726300805079874003303799646812e+0003L,
6625b2ba9d3SPiotr Jasiukajtis -1.293850285839529282503178263484773478457e+0004L,
6635b2ba9d3SPiotr Jasiukajtis -4.445024742266316181033354192262529356093e+0004L,
6645b2ba9d3SPiotr Jasiukajtis -8.730161378334357767668344467356505347070e+0004L,
6655b2ba9d3SPiotr Jasiukajtis -9.706222895172078442801444972505315054736e+0004L,
6665b2ba9d3SPiotr Jasiukajtis -5.896325518259858270165531513618195321041e+0004L,
6675b2ba9d3SPiotr Jasiukajtis -1.823172034368108822276420827074668832233e+0004L,
6685b2ba9d3SPiotr Jasiukajtis -2.509304178635055926638833040337472387175e+0003L,
6695b2ba9d3SPiotr Jasiukajtis -1.156608965715779237316769828941729964099e+0002L,
6705b2ba9d3SPiotr Jasiukajtis -7.028005789650731396887346826397785210442e-0001L,
6715b2ba9d3SPiotr Jasiukajtis };
6725b2ba9d3SPiotr Jasiukajtis static const GENERIC qs6[13] = { /* [1.28, 1.777..] */
6735b2ba9d3SPiotr Jasiukajtis 1.0e0L,
6745b2ba9d3SPiotr Jasiukajtis 6.457211085058064845601261321277721075900e+0001L,
6755b2ba9d3SPiotr Jasiukajtis 1.534005216588011210342824555136008682950e+0003L,
6765b2ba9d3SPiotr Jasiukajtis 1.777217999176441782593357660462379097171e+0004L,
6775b2ba9d3SPiotr Jasiukajtis 1.118372652642469468091084810263231199696e+0005L,
6785b2ba9d3SPiotr Jasiukajtis 4.015242433858461813142365748386473605294e+0005L,
6795b2ba9d3SPiotr Jasiukajtis 8.377081045517098645448616514388280497673e+0005L,
6805b2ba9d3SPiotr Jasiukajtis 1.011495020008010352575398009604164287337e+0006L,
6815b2ba9d3SPiotr Jasiukajtis 6.886722075290430568652227875200208955970e+0005L,
6825b2ba9d3SPiotr Jasiukajtis 2.504735189948021472047157148613171956537e+0005L,
6835b2ba9d3SPiotr Jasiukajtis 4.408138920171044846941001844352009817062e+0004L,
6845b2ba9d3SPiotr Jasiukajtis 3.105572178072115145673058722853640854884e+0003L,
6855b2ba9d3SPiotr Jasiukajtis 5.588294821118916113437396504573817033678e+0001L,
6865b2ba9d3SPiotr Jasiukajtis };
qzero(x)6875b2ba9d3SPiotr Jasiukajtis static GENERIC qzero(x)
6885b2ba9d3SPiotr Jasiukajtis GENERIC x;
6895b2ba9d3SPiotr Jasiukajtis {
6905b2ba9d3SPiotr Jasiukajtis GENERIC s,r,t,z;
6915b2ba9d3SPiotr Jasiukajtis int i;
6925b2ba9d3SPiotr Jasiukajtis if (x>huge) return -0.125L/x;
6935b2ba9d3SPiotr Jasiukajtis t = one/x; z = t*t;
6945b2ba9d3SPiotr Jasiukajtis if (x>sixteen) {
6955b2ba9d3SPiotr Jasiukajtis r = z*qr0[11]+qr0[10]; s = qs0[10];
6965b2ba9d3SPiotr Jasiukajtis for (i=9;i>=0;i--) {
6975b2ba9d3SPiotr Jasiukajtis r = z*r + qr0[i];
6985b2ba9d3SPiotr Jasiukajtis s = z*s + qs0[i];
6995b2ba9d3SPiotr Jasiukajtis }
7005b2ba9d3SPiotr Jasiukajtis } else if (x>eight) {
7015b2ba9d3SPiotr Jasiukajtis r = qr1[11]; s = qs1[11]+z*(qs1[12]+z*qs1[13]);
7025b2ba9d3SPiotr Jasiukajtis for (i=10;i>=0;i--) {
7035b2ba9d3SPiotr Jasiukajtis r = z*r + qr1[i];
7045b2ba9d3SPiotr Jasiukajtis s = z*s + qs1[i];
7055b2ba9d3SPiotr Jasiukajtis }
7065b2ba9d3SPiotr Jasiukajtis } else if (x>five) { /* assume x > 5.0 */
7075b2ba9d3SPiotr Jasiukajtis r = qr2[11]; s = qs2[11]+z*(qs2[12]+z*qs2[13]);
7085b2ba9d3SPiotr Jasiukajtis for (i=10;i>=0;i--) {
7095b2ba9d3SPiotr Jasiukajtis r = z*r + qr2[i];
7105b2ba9d3SPiotr Jasiukajtis s = z*s + qs2[i];
7115b2ba9d3SPiotr Jasiukajtis }
7125b2ba9d3SPiotr Jasiukajtis } else if (x>3.5L) {
7135b2ba9d3SPiotr Jasiukajtis r = qr3[12]; s = qs3[12];
7145b2ba9d3SPiotr Jasiukajtis for (i=11;i>=0;i--) {
7155b2ba9d3SPiotr Jasiukajtis r = z*r + qr3[i];
7165b2ba9d3SPiotr Jasiukajtis s = z*s + qs3[i];
7175b2ba9d3SPiotr Jasiukajtis }
7185b2ba9d3SPiotr Jasiukajtis } else if (x>2.5L) {
7195b2ba9d3SPiotr Jasiukajtis r = qr4[12]; s = qs4[12];
7205b2ba9d3SPiotr Jasiukajtis for (i=11;i>=0;i--) {
7215b2ba9d3SPiotr Jasiukajtis r = z*r + qr4[i];
7225b2ba9d3SPiotr Jasiukajtis s = z*s + qs4[i];
7235b2ba9d3SPiotr Jasiukajtis }
7245b2ba9d3SPiotr Jasiukajtis } else if (x> (1.0L/0.5625L)) {
7255b2ba9d3SPiotr Jasiukajtis r = qr5[12]; s = qs5[12];
7265b2ba9d3SPiotr Jasiukajtis for (i=11;i>=0;i--) {
7275b2ba9d3SPiotr Jasiukajtis r = z*r + qr5[i];
7285b2ba9d3SPiotr Jasiukajtis s = z*s + qs5[i];
7295b2ba9d3SPiotr Jasiukajtis }
7305b2ba9d3SPiotr Jasiukajtis } else { /* assume x > 1.28 */
7315b2ba9d3SPiotr Jasiukajtis r = qr6[12]; s = qs6[12];
7325b2ba9d3SPiotr Jasiukajtis for (i=11;i>=0;i--) {
7335b2ba9d3SPiotr Jasiukajtis r = z*r + qr6[i];
7345b2ba9d3SPiotr Jasiukajtis s = z*s + qs6[i];
7355b2ba9d3SPiotr Jasiukajtis }
7365b2ba9d3SPiotr Jasiukajtis }
7375b2ba9d3SPiotr Jasiukajtis return t*(r/s);
7385b2ba9d3SPiotr Jasiukajtis }
739