j0l.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. /* j0l.c
  2. *
  3. * Bessel function of order zero
  4. *
  5. *
  6. *
  7. * SYNOPSIS:
  8. *
  9. * long double x, y, j0l();
  10. *
  11. * y = j0l( x );
  12. *
  13. *
  14. *
  15. * DESCRIPTION:
  16. *
  17. * Returns Bessel function of first kind, order zero of the argument.
  18. *
  19. * The domain is divided into the intervals [0, 9] and
  20. * (9, infinity). In the first interval the rational approximation
  21. * is (x^2 - r^2) (x^2 - s^2) (x^2 - t^2) P7(x^2) / Q8(x^2),
  22. * where r, s, t are the first three zeros of the function.
  23. * In the second interval the expansion is in terms of the
  24. * modulus M0(x) = sqrt(J0(x)^2 + Y0(x)^2) and phase P0(x)
  25. * = atan(Y0(x)/J0(x)). M0 is approximated by sqrt(1/x)P7(1/x)/Q7(1/x).
  26. * The approximation to J0 is M0 * cos(x - pi/4 + 1/x P5(1/x^2)/Q6(1/x^2)).
  27. *
  28. *
  29. * ACCURACY:
  30. *
  31. * Absolute error:
  32. * arithmetic domain # trials peak rms
  33. * IEEE 0, 30 100000 2.8e-19 7.4e-20
  34. *
  35. *
  36. */
  37. /* y0l.c
  38. *
  39. * Bessel function of the second kind, order zero
  40. *
  41. *
  42. *
  43. * SYNOPSIS:
  44. *
  45. * double x, y, y0l();
  46. *
  47. * y = y0l( x );
  48. *
  49. *
  50. *
  51. * DESCRIPTION:
  52. *
  53. * Returns Bessel function of the second kind, of order
  54. * zero, of the argument.
  55. *
  56. * The domain is divided into the intervals [0, 5>, [5,9> and
  57. * [9, infinity). In the first interval a rational approximation
  58. * R(x) is employed to compute y0(x) = R(x) + 2/pi * log(x) * j0(x).
  59. *
  60. * In the second interval, the approximation is
  61. * (x - p)(x - q)(x - r)(x - s)P7(x)/Q7(x)
  62. * where p, q, r, s are zeros of y0(x).
  63. *
  64. * The third interval uses the same approximations to modulus
  65. * and phase as j0(x), whence y0(x) = modulus * sin(phase).
  66. *
  67. * ACCURACY:
  68. *
  69. * Absolute error, when y0(x) < 1; else relative error:
  70. *
  71. * arithmetic domain # trials peak rms
  72. * IEEE 0, 30 100000 3.4e-19 7.6e-20
  73. *
  74. */
  75. /* Copyright 1994 by Stephen L. Moshier (moshier@world.std.com). */
  76. #include <math.h>
  77. /*
  78. j0(x) = (x^2-JZ1)(x^2-JZ2)(x^2-JZ3)P(x**2)/Q(x**2)
  79. 0 <= x <= 9
  80. Relative error
  81. n=7, d=8
  82. Peak error = 8.49e-22
  83. Relative error spread = 2.2e-3
  84. */
  85. #if UNK
  86. static long double j0n[8] = {
  87. 1.296848754518641770562E0L,
  88. -3.239201943301299801018E3L,
  89. 3.490002040733471400107E6L,
  90. -2.076797068740966813173E9L,
  91. 7.283696461857171054941E11L,
  92. -1.487926133645291056388E14L,
  93. 1.620335009643150402368E16L,
  94. -7.173386747526788067407E17L,
  95. };
  96. static long double j0d[8] = {
  97. /* 1.000000000000000000000E0L,*/
  98. 2.281959869176887763845E3L,
  99. 2.910386840401647706984E6L,
  100. 2.608400226578100610991E9L,
  101. 1.752689035792859338860E12L,
  102. 8.879132373286001289461E14L,
  103. 3.265560832845194013669E17L,
  104. 7.881340554308432241892E19L,
  105. 9.466475654163919450528E21L,
  106. };
  107. #endif
  108. #if IBMPC
  109. static short j0n[] = {
  110. 0xf759,0x4208,0x23d6,0xa5ff,0x3fff, XPD
  111. 0xa9a8,0xe62b,0x3b28,0xca73,0xc00a, XPD
  112. 0xfe10,0xb608,0x4829,0xd503,0x4014, XPD
  113. 0x008c,0x7b60,0xd119,0xf792,0xc01d, XPD
  114. 0x943a,0x69b7,0x36ca,0xa996,0x4026, XPD
  115. 0x1b0b,0x6331,0x7add,0x8753,0xc02e, XPD
  116. 0x4018,0xad26,0x71ba,0xe643,0x4034, XPD
  117. 0xb96c,0xc486,0xfb95,0x9f47,0xc03a, XPD
  118. };
  119. static short j0d[] = {
  120. /*0x0000,0x0000,0x0000,0x8000,0x3fff, XPD*/
  121. 0xbdfe,0xc832,0x5b9f,0x8e9f,0x400a, XPD
  122. 0xe1a0,0x923f,0xcb5c,0xb1a2,0x4014, XPD
  123. 0x66d2,0x93fe,0x0762,0x9b79,0x401e, XPD
  124. 0xfed1,0x086d,0x3425,0xcc0a,0x4027, XPD
  125. 0x0841,0x8cb6,0x5a46,0xc9e3,0x4030, XPD
  126. 0x3d2c,0xed55,0x20e1,0x9105,0x4039, XPD
  127. 0xfdce,0xa4ca,0x2ed8,0x88b8,0x4041, XPD
  128. 0x00ac,0xfb2b,0x6f62,0x804b,0x4048, XPD
  129. };
  130. #endif
  131. #if MIEEE
  132. static long j0n[24] = {
  133. 0x3fff0000,0xa5ff23d6,0x4208f759,
  134. 0xc00a0000,0xca733b28,0xe62ba9a8,
  135. 0x40140000,0xd5034829,0xb608fe10,
  136. 0xc01d0000,0xf792d119,0x7b60008c,
  137. 0x40260000,0xa99636ca,0x69b7943a,
  138. 0xc02e0000,0x87537add,0x63311b0b,
  139. 0x40340000,0xe64371ba,0xad264018,
  140. 0xc03a0000,0x9f47fb95,0xc486b96c,
  141. };
  142. static long j0d[24] = {
  143. /*0x3fff0000,0x80000000,0x00000000,*/
  144. 0x400a0000,0x8e9f5b9f,0xc832bdfe,
  145. 0x40140000,0xb1a2cb5c,0x923fe1a0,
  146. 0x401e0000,0x9b790762,0x93fe66d2,
  147. 0x40270000,0xcc0a3425,0x086dfed1,
  148. 0x40300000,0xc9e35a46,0x8cb60841,
  149. 0x40390000,0x910520e1,0xed553d2c,
  150. 0x40410000,0x88b82ed8,0xa4cafdce,
  151. 0x40480000,0x804b6f62,0xfb2b00ac,
  152. };
  153. #endif
  154. /*
  155. sqrt(j0^2(1/x^2) + y0^2(1/x^2)) = z P(z**2)/Q(z**2)
  156. z(x) = 1/sqrt(x)
  157. Relative error
  158. n=7, d=7
  159. Peak error = 1.80e-20
  160. Relative error spread = 5.1e-2
  161. */
  162. #if UNK
  163. static long double modulusn[8] = {
  164. 3.947542376069224461532E-1L,
  165. 6.864682945702134624126E0L,
  166. 1.021369773577974343844E1L,
  167. 7.626141421290849630523E0L,
  168. 2.842537511425216145635E0L,
  169. 7.162842530423205720962E-1L,
  170. 9.036664453160200052296E-2L,
  171. 8.461833426898867839659E-3L,
  172. };
  173. static long double modulusd[7] = {
  174. /* 1.000000000000000000000E0L,*/
  175. 9.117176038171821115904E0L,
  176. 1.301235226061478261481E1L,
  177. 9.613002539386213788182E0L,
  178. 3.569671060989910901903E0L,
  179. 8.983920141407590632423E-1L,
  180. 1.132577931332212304986E-1L,
  181. 1.060533546154121770442E-2L,
  182. };
  183. #endif
  184. #if IBMPC
  185. static short modulusn[] = {
  186. 0x8559,0xf552,0x3a38,0xca1d,0x3ffd, XPD
  187. 0x38a3,0xa663,0x7b91,0xdbab,0x4001, XPD
  188. 0xb343,0x2673,0x4e51,0xa36b,0x4002, XPD
  189. 0x5e4b,0xe3af,0x59bb,0xf409,0x4001, XPD
  190. 0xb1cd,0x4e5e,0x2274,0xb5ec,0x4000, XPD
  191. 0xcfe9,0x74e0,0x67a1,0xb75e,0x3ffe, XPD
  192. 0x6b78,0x4cc6,0x25b7,0xb912,0x3ffb, XPD
  193. 0xcb2b,0x4b73,0x8075,0x8aa3,0x3ff8, XPD
  194. };
  195. static short modulusd[] = {
  196. /*0x0000,0x0000,0x0000,0x8000,0x3fff, XPD*/
  197. 0x4498,0x3d2a,0xf3fb,0x91df,0x4002, XPD
  198. 0x5e3d,0xb5f4,0x9848,0xd032,0x4002, XPD
  199. 0xb837,0x3075,0xdbc0,0x99ce,0x4002, XPD
  200. 0x775a,0x1b79,0x7d9c,0xe475,0x4000, XPD
  201. 0x7e3f,0xb8dd,0x04df,0xe5fd,0x3ffe, XPD
  202. 0xed5a,0x31cd,0xb3ac,0xe7f3,0x3ffb, XPD
  203. 0x8a83,0x1b80,0x003e,0xadc2,0x3ff8, XPD
  204. };
  205. #endif
  206. #if MIEEE
  207. static long modulusn[24] = {
  208. 0x3ffd0000,0xca1d3a38,0xf5528559,
  209. 0x40010000,0xdbab7b91,0xa66338a3,
  210. 0x40020000,0xa36b4e51,0x2673b343,
  211. 0x40010000,0xf40959bb,0xe3af5e4b,
  212. 0x40000000,0xb5ec2274,0x4e5eb1cd,
  213. 0x3ffe0000,0xb75e67a1,0x74e0cfe9,
  214. 0x3ffb0000,0xb91225b7,0x4cc66b78,
  215. 0x3ff80000,0x8aa38075,0x4b73cb2b,
  216. };
  217. static long modulusd[21] = {
  218. /*0x3fff0000,0x80000000,0x00000000,*/
  219. 0x40020000,0x91dff3fb,0x3d2a4498,
  220. 0x40020000,0xd0329848,0xb5f45e3d,
  221. 0x40020000,0x99cedbc0,0x3075b837,
  222. 0x40000000,0xe4757d9c,0x1b79775a,
  223. 0x3ffe0000,0xe5fd04df,0xb8dd7e3f,
  224. 0x3ffb0000,0xe7f3b3ac,0x31cded5a,
  225. 0x3ff80000,0xadc2003e,0x1b808a83,
  226. };
  227. #endif
  228. /*
  229. atan(y0(x)/j0(x)) = x - pi/4 + x P(x**2)/Q(x**2)
  230. Absolute error
  231. n=5, d=6
  232. Peak error = 2.80e-21
  233. Relative error spread = 5.5e-1
  234. */
  235. #if UNK
  236. static long double phasen[6] = {
  237. -7.356766355393571519038E-1L,
  238. -5.001635199922493694706E-1L,
  239. -7.737323518141516881715E-2L,
  240. -3.998893155826990642730E-3L,
  241. -7.496317036829964150970E-5L,
  242. -4.290885090773112963542E-7L,
  243. };
  244. static long double phased[6] = {
  245. /* 1.000000000000000000000E0L,*/
  246. 7.377856408614376072745E0L,
  247. 4.285043297797736118069E0L,
  248. 6.348446472935245102890E-1L,
  249. 3.229866782185025048457E-2L,
  250. 6.014932317342190404134E-4L,
  251. 3.432708072618490390095E-6L,
  252. };
  253. #endif
  254. #if IBMPC
  255. static short phasen[] = {
  256. 0x5106,0x12a6,0x4dd2,0xbc55,0xbffe, XPD
  257. 0x1e30,0x04da,0xb769,0x800a,0xbffe, XPD
  258. 0x8d8a,0x84e7,0xdbd5,0x9e75,0xbffb, XPD
  259. 0xe514,0x8866,0x25a9,0x8309,0xbff7, XPD
  260. 0xdc17,0x325e,0x8baf,0x9d35,0xbff1, XPD
  261. 0x4c2f,0x2dd8,0x79c3,0xe65d,0xbfe9, XPD
  262. };
  263. static short phased[] = {
  264. /*0x0000,0x0000,0x0000,0x8000,0x3fff, XPD*/
  265. 0xf3e9,0xb2a5,0x6652,0xec17,0x4001, XPD
  266. 0x4b69,0x3f87,0x131f,0x891f,0x4001, XPD
  267. 0x6f25,0x2a95,0x2dc6,0xa285,0x3ffe, XPD
  268. 0x37bf,0xfcc8,0x9b9f,0x844b,0x3ffa, XPD
  269. 0xac5c,0x4806,0x8709,0x9dad,0x3ff4, XPD
  270. 0x4c8c,0x2dd8,0x79c3,0xe65d,0x3fec, XPD
  271. };
  272. #endif
  273. #if MIEEE
  274. static long phasen[18] = {
  275. 0xbffe0000,0xbc554dd2,0x12a65106,
  276. 0xbffe0000,0x800ab769,0x04da1e30,
  277. 0xbffb0000,0x9e75dbd5,0x84e78d8a,
  278. 0xbff70000,0x830925a9,0x8866e514,
  279. 0xbff10000,0x9d358baf,0x325edc17,
  280. 0xbfe90000,0xe65d79c3,0x2dd84c2f,
  281. };
  282. static long phased[18] = {
  283. /*0x3fff0000,0x80000000,0x00000000,*/
  284. 0x40010000,0xec176652,0xb2a5f3e9,
  285. 0x40010000,0x891f131f,0x3f874b69,
  286. 0x3ffe0000,0xa2852dc6,0x2a956f25,
  287. 0x3ffa0000,0x844b9b9f,0xfcc837bf,
  288. 0x3ff40000,0x9dad8709,0x4806ac5c,
  289. 0x3fec0000,0xe65d79c3,0x2dd84c8c,
  290. };
  291. #endif
  292. #define JZ1 5.783185962946784521176L
  293. #define JZ2 30.47126234366208639908L
  294. #define JZ3 7.488700679069518344489e1L
  295. #define PIO4L 0.78539816339744830961566L
  296. #ifdef ANSIPROT
  297. extern long double sqrtl ( long double );
  298. extern long double fabsl ( long double );
  299. extern long double polevll ( long double, void *, int );
  300. extern long double p1evll ( long double, void *, int );
  301. extern long double cosl ( long double );
  302. extern long double sinl ( long double );
  303. extern long double logl ( long double );
  304. long double j0l ( long double );
  305. #else
  306. long double sqrtl(), fabsl(), polevll(), p1evll(), cosl(), sinl(), logl();
  307. long double j0l();
  308. #endif
  309. long double j0l(x)
  310. long double x;
  311. {
  312. long double xx, y, z, modulus, phase;
  313. xx = x * x;
  314. if( xx < 81.0L )
  315. {
  316. y = (xx - JZ1) * (xx - JZ2) * (xx -JZ3);
  317. y *= polevll( xx, j0n, 7 ) / p1evll( xx, j0d, 8 );
  318. return y;
  319. }
  320. y = fabsl(x);
  321. xx = 1.0/xx;
  322. phase = polevll( xx, phasen, 5 ) / p1evll( xx, phased, 6 );
  323. z = 1.0/y;
  324. modulus = polevll( z, modulusn, 7 ) / p1evll( z, modulusd, 7 );
  325. y = modulus * cosl( y - PIO4L + z*phase) / sqrtl(y);
  326. return y;
  327. }
  328. /*
  329. y0(x) = 2/pi * log(x) * j0(x) + P(z**2)/Q(z**2)
  330. 0 <= x <= 5
  331. Absolute error
  332. n=7, d=7
  333. Peak error = 8.55e-22
  334. Relative error spread = 2.7e-1
  335. */
  336. #if UNK
  337. static long double y0n[8] = {
  338. 1.556909814120445353691E4L,
  339. -1.464324149797947303151E7L,
  340. 5.427926320587133391307E9L,
  341. -9.808510181632626683952E11L,
  342. 8.747842804834934784972E13L,
  343. -3.461898868011666236539E15L,
  344. 4.421767595991969611983E16L,
  345. -1.847183690384811186958E16L,
  346. };
  347. static long double y0d[7] = {
  348. /* 1.000000000000000000000E0L,*/
  349. 1.040792201755841697889E3L,
  350. 6.256391154086099882302E5L,
  351. 2.686702051957904669677E8L,
  352. 8.630939306572281881328E10L,
  353. 2.027480766502742538763E13L,
  354. 3.167750475899536301562E15L,
  355. 2.502813268068711844040E17L,
  356. };
  357. #endif
  358. #if IBMPC
  359. static short y0n[] = {
  360. 0x126c,0x20be,0x647f,0xf344,0x400c, XPD
  361. 0x2ec0,0x7b95,0x297f,0xdf70,0xc016, XPD
  362. 0x2fdd,0x4b27,0xca98,0xa1c3,0x401f, XPD
  363. 0x3e3c,0xb343,0x46c9,0xe45f,0xc026, XPD
  364. 0xb219,0x37ba,0x5142,0x9f1f,0x402d, XPD
  365. 0x23c9,0x6b29,0x4244,0xc4c9,0xc032, XPD
  366. 0x501f,0x6264,0xbdf4,0x9d17,0x4036, XPD
  367. 0x5fbd,0x0171,0x135a,0x8340,0xc035, XPD
  368. };
  369. static short y0d[] = {
  370. /*0x0000,0x0000,0x0000,0x8000,0x3fff, XPD*/
  371. 0x9057,0x7f25,0x59b7,0x8219,0x4009, XPD
  372. 0xd938,0xb6b2,0x71d8,0x98be,0x4012, XPD
  373. 0x97a4,0x90fa,0xa7e9,0x801c,0x401b, XPD
  374. 0x553b,0x4dc8,0x8695,0xa0c3,0x4023, XPD
  375. 0x6732,0x8c1b,0xc5ab,0x9384,0x402b, XPD
  376. 0x04d3,0xa629,0xd61d,0xb410,0x4032, XPD
  377. 0x241a,0x8f2b,0x629a,0xde4b,0x4038, XPD
  378. };
  379. #endif
  380. #if MIEEE
  381. static long y0n[24] = {
  382. 0x400c0000,0xf344647f,0x20be126c,
  383. 0xc0160000,0xdf70297f,0x7b952ec0,
  384. 0x401f0000,0xa1c3ca98,0x4b272fdd,
  385. 0xc0260000,0xe45f46c9,0xb3433e3c,
  386. 0x402d0000,0x9f1f5142,0x37bab219,
  387. 0xc0320000,0xc4c94244,0x6b2923c9,
  388. 0x40360000,0x9d17bdf4,0x6264501f,
  389. 0xc0350000,0x8340135a,0x01715fbd,
  390. };
  391. static long y0d[21] = {
  392. /*0x3fff0000,0x80000000,0x00000000,*/
  393. 0x40090000,0x821959b7,0x7f259057,
  394. 0x40120000,0x98be71d8,0xb6b2d938,
  395. 0x401b0000,0x801ca7e9,0x90fa97a4,
  396. 0x40230000,0xa0c38695,0x4dc8553b,
  397. 0x402b0000,0x9384c5ab,0x8c1b6732,
  398. 0x40320000,0xb410d61d,0xa62904d3,
  399. 0x40380000,0xde4b629a,0x8f2b241a,
  400. };
  401. #endif
  402. /*
  403. y0(x) = (x-Y0Z1)(x-Y0Z2)(x-Y0Z3)(x-Y0Z4)P(x)/Q(x)
  404. 4.5 <= x <= 9
  405. Absolute error
  406. n=9, d=9
  407. Peak error = 2.35e-20
  408. Relative error spread = 7.8e-13
  409. */
  410. #if UNK
  411. static long double y059n[10] = {
  412. 2.368715538373384869796E-2L,
  413. -1.472923738545276751402E0L,
  414. 2.525993724177105060507E1L,
  415. 7.727403527387097461580E1L,
  416. -4.578271827238477598563E3L,
  417. 7.051411242092171161986E3L,
  418. 1.951120419910720443331E5L,
  419. 6.515211089266670755622E5L,
  420. -1.164760792144532266855E5L,
  421. -5.566567444353735925323E5L,
  422. };
  423. static long double y059d[9] = {
  424. /* 1.000000000000000000000E0L,*/
  425. -6.235501989189125881723E1L,
  426. 2.224790285641017194158E3L,
  427. -5.103881883748705381186E4L,
  428. 8.772616606054526158657E5L,
  429. -1.096162986826467060921E7L,
  430. 1.083335477747278958468E8L,
  431. -7.045635226159434678833E8L,
  432. 3.518324187204647941098E9L,
  433. 1.173085288957116938494E9L,
  434. };
  435. #endif
  436. #if IBMPC
  437. static short y059n[] = {
  438. 0x992f,0xab45,0x90b6,0xc20b,0x3ff9, XPD
  439. 0x1207,0x46ea,0xc3db,0xbc88,0xbfff, XPD
  440. 0x5504,0x035a,0x59fa,0xca14,0x4003, XPD
  441. 0xd5a3,0xf673,0x4e59,0x9a8c,0x4005, XPD
  442. 0x62e0,0xc25b,0x2cb3,0x8f12,0xc00b, XPD
  443. 0xe8fa,0x4b44,0x4a39,0xdc5b,0x400b, XPD
  444. 0x49e2,0xfb52,0x02af,0xbe8a,0x4010, XPD
  445. 0x8c07,0x29e3,0x11be,0x9f10,0x4012, XPD
  446. 0xfd54,0xb2fe,0x0a23,0xe37e,0xc00f, XPD
  447. 0xf90c,0x3510,0x0be9,0x87e7,0xc012, XPD
  448. };
  449. static short y059d[] = {
  450. /*0x0000,0x0000,0x0000,0x8000,0x3fff, XPD*/
  451. 0xdebf,0xa468,0x8a55,0xf96b,0xc004, XPD
  452. 0xad09,0x8e6a,0xa502,0x8b0c,0x400a, XPD
  453. 0xa28c,0x5563,0xd19f,0xc75e,0xc00e, XPD
  454. 0xe8b6,0xd705,0xda91,0xd62c,0x4012, XPD
  455. 0xec8a,0x4697,0xddde,0xa742,0xc016, XPD
  456. 0x27ff,0xca92,0x3d78,0xcea1,0x4019, XPD
  457. 0xe26b,0x76b9,0x250a,0xa7fb,0xc01c, XPD
  458. 0xceb6,0x3463,0x5ddb,0xd1b5,0x401e, XPD
  459. 0x3b3b,0xea0b,0xb8d1,0x8bd7,0x401d, XPD
  460. };
  461. #endif
  462. #if MIEEE
  463. static long y059n[30] = {
  464. 0x3ff90000,0xc20b90b6,0xab45992f,
  465. 0xbfff0000,0xbc88c3db,0x46ea1207,
  466. 0x40030000,0xca1459fa,0x035a5504,
  467. 0x40050000,0x9a8c4e59,0xf673d5a3,
  468. 0xc00b0000,0x8f122cb3,0xc25b62e0,
  469. 0x400b0000,0xdc5b4a39,0x4b44e8fa,
  470. 0x40100000,0xbe8a02af,0xfb5249e2,
  471. 0x40120000,0x9f1011be,0x29e38c07,
  472. 0xc00f0000,0xe37e0a23,0xb2fefd54,
  473. 0xc0120000,0x87e70be9,0x3510f90c,
  474. };
  475. static long y059d[27] = {
  476. /*0x3fff0000,0x80000000,0x00000000,*/
  477. 0xc0040000,0xf96b8a55,0xa468debf,
  478. 0x400a0000,0x8b0ca502,0x8e6aad09,
  479. 0xc00e0000,0xc75ed19f,0x5563a28c,
  480. 0x40120000,0xd62cda91,0xd705e8b6,
  481. 0xc0160000,0xa742ddde,0x4697ec8a,
  482. 0x40190000,0xcea13d78,0xca9227ff,
  483. 0xc01c0000,0xa7fb250a,0x76b9e26b,
  484. 0x401e0000,0xd1b55ddb,0x3463ceb6,
  485. 0x401d0000,0x8bd7b8d1,0xea0b3b3b,
  486. };
  487. #endif
  488. #define TWOOPI 6.36619772367581343075535E-1L
  489. #define Y0Z1 3.957678419314857868376e0L
  490. #define Y0Z2 7.086051060301772697624e0L
  491. #define Y0Z3 1.022234504349641701900e1L
  492. #define Y0Z4 1.336109747387276347827e1L
  493. /* #define MAXNUML 1.189731495357231765021e4932L */
  494. extern long double MAXNUML;
  495. long double y0l(x)
  496. long double x;
  497. {
  498. long double xx, y, z, modulus, phase;
  499. if( x < 0.0 )
  500. {
  501. return (-MAXNUML);
  502. }
  503. xx = x * x;
  504. if( xx < 81.0L )
  505. {
  506. if( xx < 20.25L )
  507. {
  508. y = TWOOPI * logl(x) * j0l(x);
  509. y += polevll( xx, y0n, 7 ) / p1evll( xx, y0d, 7 );
  510. }
  511. else
  512. {
  513. y = (x - Y0Z1)*(x - Y0Z2)*(x - Y0Z3)*(x - Y0Z4);
  514. y *= polevll( x, y059n, 9 ) / p1evll( x, y059d, 9 );
  515. }
  516. return y;
  517. }
  518. y = fabsl(x);
  519. xx = 1.0/xx;
  520. phase = polevll( xx, phasen, 5 ) / p1evll( xx, phased, 6 );
  521. z = 1.0/y;
  522. modulus = polevll( z, modulusn, 7 ) / p1evll( z, modulusd, 7 );
  523. y = modulus * sinl( y - PIO4L + z*phase) / sqrtl(y);
  524. return y;
  525. }