shichi.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. /* shichi.c
  2. *
  3. * Hyperbolic sine and cosine integrals
  4. *
  5. *
  6. *
  7. * SYNOPSIS:
  8. *
  9. * double x, Chi, Shi, shichi();
  10. *
  11. * shichi( x, &Chi, &Shi );
  12. *
  13. *
  14. * DESCRIPTION:
  15. *
  16. * Approximates the integrals
  17. *
  18. * x
  19. * -
  20. * | | cosh t - 1
  21. * Chi(x) = eul + ln x + | ----------- dt,
  22. * | | t
  23. * -
  24. * 0
  25. *
  26. * x
  27. * -
  28. * | | sinh t
  29. * Shi(x) = | ------ dt
  30. * | | t
  31. * -
  32. * 0
  33. *
  34. * where eul = 0.57721566490153286061 is Euler's constant.
  35. * The integrals are evaluated by power series for x < 8
  36. * and by Chebyshev expansions for x between 8 and 88.
  37. * For large x, both functions approach exp(x)/2x.
  38. * Arguments greater than 88 in magnitude return MAXNUM.
  39. *
  40. *
  41. * ACCURACY:
  42. *
  43. * Test interval 0 to 88.
  44. * Relative error:
  45. * arithmetic function # trials peak rms
  46. * DEC Shi 3000 9.1e-17
  47. * IEEE Shi 30000 6.9e-16 1.6e-16
  48. * Absolute error, except relative when |Chi| > 1:
  49. * DEC Chi 2500 9.3e-17
  50. * IEEE Chi 30000 8.4e-16 1.4e-16
  51. */
  52. /*
  53. Cephes Math Library Release 2.8: June, 2000
  54. Copyright 1984, 1987, 2000 by Stephen L. Moshier
  55. */
  56. #include <math.h>
  57. #ifdef UNK
  58. /* x exp(-x) shi(x), inverted interval 8 to 18 */
  59. static double S1[] = {
  60. 1.83889230173399459482E-17,
  61. -9.55485532279655569575E-17,
  62. 2.04326105980879882648E-16,
  63. 1.09896949074905343022E-15,
  64. -1.31313534344092599234E-14,
  65. 5.93976226264314278932E-14,
  66. -3.47197010497749154755E-14,
  67. -1.40059764613117131000E-12,
  68. 9.49044626224223543299E-12,
  69. -1.61596181145435454033E-11,
  70. -1.77899784436430310321E-10,
  71. 1.35455469767246947469E-9,
  72. -1.03257121792819495123E-9,
  73. -3.56699611114982536845E-8,
  74. 1.44818877384267342057E-7,
  75. 7.82018215184051295296E-7,
  76. -5.39919118403805073710E-6,
  77. -3.12458202168959833422E-5,
  78. 8.90136741950727517826E-5,
  79. 2.02558474743846862168E-3,
  80. 2.96064440855633256972E-2,
  81. 1.11847751047257036625E0
  82. };
  83. /* x exp(-x) shi(x), inverted interval 18 to 88 */
  84. static double S2[] = {
  85. -1.05311574154850938805E-17,
  86. 2.62446095596355225821E-17,
  87. 8.82090135625368160657E-17,
  88. -3.38459811878103047136E-16,
  89. -8.30608026366935789136E-16,
  90. 3.93397875437050071776E-15,
  91. 1.01765565969729044505E-14,
  92. -4.21128170307640802703E-14,
  93. -1.60818204519802480035E-13,
  94. 3.34714954175994481761E-13,
  95. 2.72600352129153073807E-12,
  96. 1.66894954752839083608E-12,
  97. -3.49278141024730899554E-11,
  98. -1.58580661666482709598E-10,
  99. -1.79289437183355633342E-10,
  100. 1.76281629144264523277E-9,
  101. 1.69050228879421288846E-8,
  102. 1.25391771228487041649E-7,
  103. 1.16229947068677338732E-6,
  104. 1.61038260117376323993E-5,
  105. 3.49810375601053973070E-4,
  106. 1.28478065259647610779E-2,
  107. 1.03665722588798326712E0
  108. };
  109. #endif
  110. #ifdef DEC
  111. static unsigned short S1[] = {
  112. 0022251,0115635,0165120,0006574,
  113. 0122734,0050751,0020305,0101356,
  114. 0023153,0111154,0011103,0177462,
  115. 0023636,0060321,0060253,0124246,
  116. 0124554,0106655,0152525,0166400,
  117. 0025205,0140145,0171006,0106556,
  118. 0125034,0056427,0004205,0176022,
  119. 0126305,0016731,0025011,0134453,
  120. 0027046,0172453,0112604,0116235,
  121. 0127216,0022071,0116600,0137667,
  122. 0130103,0115126,0071104,0052535,
  123. 0030672,0025450,0010071,0141414,
  124. 0130615,0165136,0132137,0177737,
  125. 0132031,0031611,0074436,0175407,
  126. 0032433,0077602,0104345,0060076,
  127. 0033121,0165741,0167177,0172433,
  128. 0133665,0025262,0174621,0022612,
  129. 0134403,0006761,0124566,0145405,
  130. 0034672,0126332,0034737,0116744,
  131. 0036004,0137654,0037332,0131766,
  132. 0036762,0104466,0121445,0124326,
  133. 0040217,0025105,0062145,0042640
  134. };
  135. static unsigned short S2[] = {
  136. 0122102,0041774,0016051,0055137,
  137. 0022362,0010125,0007651,0015773,
  138. 0022713,0062551,0040227,0071645,
  139. 0123303,0015732,0025731,0146570,
  140. 0123557,0064016,0002067,0067711,
  141. 0024215,0136214,0132374,0124234,
  142. 0024467,0051425,0071066,0064210,
  143. 0125075,0124305,0135123,0024170,
  144. 0125465,0010261,0005560,0034232,
  145. 0025674,0066602,0030724,0174557,
  146. 0026477,0151520,0051510,0067250,
  147. 0026352,0161076,0113154,0116271,
  148. 0127431,0116470,0177465,0127274,
  149. 0130056,0056174,0170315,0013321,
  150. 0130105,0020575,0075327,0036710,
  151. 0030762,0043625,0113046,0125035,
  152. 0031621,0033211,0154354,0022077,
  153. 0032406,0121555,0074270,0041141,
  154. 0033234,0000116,0041611,0173743,
  155. 0034207,0013263,0174715,0115563,
  156. 0035267,0063300,0175753,0117266,
  157. 0036522,0077633,0033255,0136200,
  158. 0040204,0130457,0014454,0166254
  159. };
  160. #endif
  161. #ifdef IBMPC
  162. static unsigned short S1[] = {
  163. 0x01b0,0xbd4a,0x3373,0x3c75,
  164. 0xb05e,0x2418,0x8a3d,0xbc9b,
  165. 0x7fe6,0x8248,0x724d,0x3cad,
  166. 0x7515,0x2c15,0xcc1a,0x3cd3,
  167. 0xbda0,0xbaaa,0x91b5,0xbd0d,
  168. 0xd1ae,0xbe40,0xb80c,0x3d30,
  169. 0xbf82,0xe110,0x8ba2,0xbd23,
  170. 0x3725,0x2541,0xa3bb,0xbd78,
  171. 0x9394,0x72b0,0xdea5,0x3da4,
  172. 0x17f7,0x33b0,0xc487,0xbdb1,
  173. 0x8aac,0xce48,0x734a,0xbde8,
  174. 0x3862,0x0207,0x4565,0x3e17,
  175. 0xfffc,0xd68b,0xbd4b,0xbe11,
  176. 0xdf61,0x2f23,0x2671,0xbe63,
  177. 0xac08,0x511c,0x6ff0,0x3e83,
  178. 0xfea3,0x3dcf,0x3d7c,0x3eaa,
  179. 0x24b1,0x5f32,0xa556,0xbed6,
  180. 0xd961,0x352e,0x61be,0xbf00,
  181. 0xf3bd,0x473b,0x559b,0x3f17,
  182. 0x567f,0x87db,0x97f5,0x3f60,
  183. 0xb51b,0xd464,0x5126,0x3f9e,
  184. 0xa8b4,0xac8c,0xe548,0x3ff1
  185. };
  186. static unsigned short S2[] = {
  187. 0x2b4c,0x8385,0x487f,0xbc68,
  188. 0x237f,0xa1f5,0x420a,0x3c7e,
  189. 0xee75,0x2812,0x6cad,0x3c99,
  190. 0x39af,0x457b,0x637b,0xbcb8,
  191. 0xedf9,0xc086,0xed01,0xbccd,
  192. 0x9513,0x969f,0xb791,0x3cf1,
  193. 0xcd11,0xae46,0xea62,0x3d06,
  194. 0x650f,0xb74a,0xb518,0xbd27,
  195. 0x0713,0x216e,0xa216,0xbd46,
  196. 0x9f2e,0x463a,0x8db0,0x3d57,
  197. 0x0dd5,0x0a69,0xfa6a,0x3d87,
  198. 0x9397,0xd2cd,0x5c47,0x3d7d,
  199. 0xb5d8,0x1fe6,0x33a7,0xbdc3,
  200. 0xa2da,0x9e19,0xcb8f,0xbde5,
  201. 0xe7b9,0xaf5a,0xa42f,0xbde8,
  202. 0xd544,0xb2c4,0x48f2,0x3e1e,
  203. 0x8488,0x3b1d,0x26d1,0x3e52,
  204. 0x084c,0xaf17,0xd46d,0x3e80,
  205. 0x3efc,0xc871,0x8009,0x3eb3,
  206. 0xb36e,0x7f39,0xe2d6,0x3ef0,
  207. 0x73d7,0x1f7d,0xecd8,0x3f36,
  208. 0xb790,0x66d5,0x4ff3,0x3f8a,
  209. 0x9d96,0xe325,0x9625,0x3ff0
  210. };
  211. #endif
  212. #ifdef MIEEE
  213. static unsigned short S1[] = {
  214. 0x3c75,0x3373,0xbd4a,0x01b0,
  215. 0xbc9b,0x8a3d,0x2418,0xb05e,
  216. 0x3cad,0x724d,0x8248,0x7fe6,
  217. 0x3cd3,0xcc1a,0x2c15,0x7515,
  218. 0xbd0d,0x91b5,0xbaaa,0xbda0,
  219. 0x3d30,0xb80c,0xbe40,0xd1ae,
  220. 0xbd23,0x8ba2,0xe110,0xbf82,
  221. 0xbd78,0xa3bb,0x2541,0x3725,
  222. 0x3da4,0xdea5,0x72b0,0x9394,
  223. 0xbdb1,0xc487,0x33b0,0x17f7,
  224. 0xbde8,0x734a,0xce48,0x8aac,
  225. 0x3e17,0x4565,0x0207,0x3862,
  226. 0xbe11,0xbd4b,0xd68b,0xfffc,
  227. 0xbe63,0x2671,0x2f23,0xdf61,
  228. 0x3e83,0x6ff0,0x511c,0xac08,
  229. 0x3eaa,0x3d7c,0x3dcf,0xfea3,
  230. 0xbed6,0xa556,0x5f32,0x24b1,
  231. 0xbf00,0x61be,0x352e,0xd961,
  232. 0x3f17,0x559b,0x473b,0xf3bd,
  233. 0x3f60,0x97f5,0x87db,0x567f,
  234. 0x3f9e,0x5126,0xd464,0xb51b,
  235. 0x3ff1,0xe548,0xac8c,0xa8b4
  236. };
  237. static unsigned short S2[] = {
  238. 0xbc68,0x487f,0x8385,0x2b4c,
  239. 0x3c7e,0x420a,0xa1f5,0x237f,
  240. 0x3c99,0x6cad,0x2812,0xee75,
  241. 0xbcb8,0x637b,0x457b,0x39af,
  242. 0xbccd,0xed01,0xc086,0xedf9,
  243. 0x3cf1,0xb791,0x969f,0x9513,
  244. 0x3d06,0xea62,0xae46,0xcd11,
  245. 0xbd27,0xb518,0xb74a,0x650f,
  246. 0xbd46,0xa216,0x216e,0x0713,
  247. 0x3d57,0x8db0,0x463a,0x9f2e,
  248. 0x3d87,0xfa6a,0x0a69,0x0dd5,
  249. 0x3d7d,0x5c47,0xd2cd,0x9397,
  250. 0xbdc3,0x33a7,0x1fe6,0xb5d8,
  251. 0xbde5,0xcb8f,0x9e19,0xa2da,
  252. 0xbde8,0xa42f,0xaf5a,0xe7b9,
  253. 0x3e1e,0x48f2,0xb2c4,0xd544,
  254. 0x3e52,0x26d1,0x3b1d,0x8488,
  255. 0x3e80,0xd46d,0xaf17,0x084c,
  256. 0x3eb3,0x8009,0xc871,0x3efc,
  257. 0x3ef0,0xe2d6,0x7f39,0xb36e,
  258. 0x3f36,0xecd8,0x1f7d,0x73d7,
  259. 0x3f8a,0x4ff3,0x66d5,0xb790,
  260. 0x3ff0,0x9625,0xe325,0x9d96
  261. };
  262. #endif
  263. #ifdef UNK
  264. /* x exp(-x) chin(x), inverted interval 8 to 18 */
  265. static double C1[] = {
  266. -8.12435385225864036372E-18,
  267. 2.17586413290339214377E-17,
  268. 5.22624394924072204667E-17,
  269. -9.48812110591690559363E-16,
  270. 5.35546311647465209166E-15,
  271. -1.21009970113732918701E-14,
  272. -6.00865178553447437951E-14,
  273. 7.16339649156028587775E-13,
  274. -2.93496072607599856104E-12,
  275. -1.40359438136491256904E-12,
  276. 8.76302288609054966081E-11,
  277. -4.40092476213282340617E-10,
  278. -1.87992075640569295479E-10,
  279. 1.31458150989474594064E-8,
  280. -4.75513930924765465590E-8,
  281. -2.21775018801848880741E-7,
  282. 1.94635531373272490962E-6,
  283. 4.33505889257316408893E-6,
  284. -6.13387001076494349496E-5,
  285. -3.13085477492997465138E-4,
  286. 4.97164789823116062801E-4,
  287. 2.64347496031374526641E-2,
  288. 1.11446150876699213025E0
  289. };
  290. /* x exp(-x) chin(x), inverted interval 18 to 88 */
  291. static double C2[] = {
  292. 8.06913408255155572081E-18,
  293. -2.08074168180148170312E-17,
  294. -5.98111329658272336816E-17,
  295. 2.68533951085945765591E-16,
  296. 4.52313941698904694774E-16,
  297. -3.10734917335299464535E-15,
  298. -4.42823207332531972288E-15,
  299. 3.49639695410806959872E-14,
  300. 6.63406731718911586609E-14,
  301. -3.71902448093119218395E-13,
  302. -1.27135418132338309016E-12,
  303. 2.74851141935315395333E-12,
  304. 2.33781843985453438400E-11,
  305. 2.71436006377612442764E-11,
  306. -2.56600180000355990529E-10,
  307. -1.61021375163803438552E-9,
  308. -4.72543064876271773512E-9,
  309. -3.00095178028681682282E-9,
  310. 7.79387474390914922337E-8,
  311. 1.06942765566401507066E-6,
  312. 1.59503164802313196374E-5,
  313. 3.49592575153777996871E-4,
  314. 1.28475387530065247392E-2,
  315. 1.03665693917934275131E0
  316. };
  317. #endif
  318. #ifdef DEC
  319. static unsigned short C1[] = {
  320. 0122025,0157055,0021702,0021427,
  321. 0022310,0130043,0123265,0022340,
  322. 0022561,0002231,0017746,0013043,
  323. 0123610,0136375,0002352,0024467,
  324. 0024300,0171555,0141300,0000446,
  325. 0124531,0176777,0126210,0035616,
  326. 0125207,0046604,0167760,0077132,
  327. 0026111,0120666,0026606,0064143,
  328. 0126516,0103615,0054127,0005436,
  329. 0126305,0104721,0025415,0004134,
  330. 0027700,0131556,0164725,0157553,
  331. 0130361,0170602,0077274,0055406,
  332. 0130116,0131420,0125472,0017231,
  333. 0031541,0153747,0177312,0056304,
  334. 0132114,0035517,0041545,0043151,
  335. 0132556,0020415,0110044,0172442,
  336. 0033402,0117041,0031152,0010364,
  337. 0033621,0072737,0050647,0013720,
  338. 0134600,0121366,0140010,0063265,
  339. 0135244,0022637,0013756,0044742,
  340. 0035402,0052052,0006523,0043564,
  341. 0036730,0106660,0020277,0162146,
  342. 0040216,0123254,0135147,0005724
  343. };
  344. static unsigned short C2[] = {
  345. 0022024,0154550,0104311,0144257,
  346. 0122277,0165037,0133443,0155601,
  347. 0122611,0165102,0157053,0055252,
  348. 0023232,0146235,0153511,0113222,
  349. 0023402,0057340,0145304,0010471,
  350. 0124137,0164171,0113071,0100002,
  351. 0124237,0105473,0056130,0022022,
  352. 0025035,0073266,0056746,0164433,
  353. 0025225,0061313,0055600,0165407,
  354. 0125721,0056312,0107613,0051215,
  355. 0126262,0166534,0115336,0066653,
  356. 0026501,0064307,0127442,0065573,
  357. 0027315,0121375,0142020,0045356,
  358. 0027356,0140764,0070641,0046570,
  359. 0130215,0010503,0146335,0177737,
  360. 0130735,0047134,0015215,0163665,
  361. 0131242,0056523,0155276,0050053,
  362. 0131116,0034515,0050707,0163512,
  363. 0032247,0057507,0107545,0032007,
  364. 0033217,0104501,0021706,0025047,
  365. 0034205,0146413,0033746,0076562,
  366. 0035267,0044605,0065355,0002772,
  367. 0036522,0077173,0130716,0170304,
  368. 0040204,0130454,0130571,0027270
  369. };
  370. #endif
  371. #ifdef IBMPC
  372. static unsigned short C1[] = {
  373. 0x4463,0xa478,0xbbc5,0xbc62,
  374. 0xa49c,0x74d6,0x1604,0x3c79,
  375. 0xc2c4,0x23fc,0x2093,0x3c8e,
  376. 0x4527,0xa09d,0x179f,0xbcd1,
  377. 0x0025,0xb858,0x1e6d,0x3cf8,
  378. 0x0772,0xf591,0x3fbf,0xbd0b,
  379. 0x0fcb,0x9dfe,0xe9b0,0xbd30,
  380. 0xcd0c,0xc5b0,0x3436,0x3d69,
  381. 0xe164,0xab0a,0xd0f1,0xbd89,
  382. 0xa10c,0x2561,0xb13a,0xbd78,
  383. 0xbbed,0xdd3a,0x166d,0x3dd8,
  384. 0x8b61,0x4fd7,0x3e30,0xbdfe,
  385. 0x43d3,0x1567,0xd662,0xbde9,
  386. 0x4b98,0xffd9,0x3afc,0x3e4c,
  387. 0xa8cd,0xe86c,0x8769,0xbe69,
  388. 0x9ea4,0xb204,0xc421,0xbe8d,
  389. 0x421f,0x264d,0x53c4,0x3ec0,
  390. 0xe2fa,0xea34,0x2ebb,0x3ed2,
  391. 0x0cd7,0xd801,0x145e,0xbf10,
  392. 0xc93c,0xe2fd,0x84b3,0xbf34,
  393. 0x68ef,0x41aa,0x4a85,0x3f40,
  394. 0xfc8d,0x0417,0x11b6,0x3f9b,
  395. 0xe17b,0x974c,0xd4d5,0x3ff1
  396. };
  397. static unsigned short C2[] = {
  398. 0x3916,0x1119,0x9b2d,0x3c62,
  399. 0x7b70,0xf6e4,0xfd43,0xbc77,
  400. 0x6b55,0x5bc5,0x3d48,0xbc91,
  401. 0x32d2,0xbae9,0x5993,0x3cb3,
  402. 0x8227,0x1958,0x4bdc,0x3cc0,
  403. 0x3000,0x32c7,0xfd0f,0xbceb,
  404. 0x0482,0x6b8b,0xf167,0xbcf3,
  405. 0xdd23,0xcbbc,0xaed6,0x3d23,
  406. 0x1d61,0x6b70,0xac59,0x3d32,
  407. 0x6a52,0x51f1,0x2b99,0xbd5a,
  408. 0xcdb5,0x935b,0x5dab,0xbd76,
  409. 0x4d6f,0xf5e4,0x2d18,0x3d88,
  410. 0x095e,0xb882,0xb45f,0x3db9,
  411. 0x29af,0x8e34,0xd83e,0x3dbd,
  412. 0xbffc,0x799b,0xa228,0xbdf1,
  413. 0xbcf7,0x8351,0xa9cb,0xbe1b,
  414. 0xca05,0x7b57,0x4baa,0xbe34,
  415. 0xfce9,0xaa38,0xc729,0xbe29,
  416. 0xa681,0xf1ec,0xebe8,0x3e74,
  417. 0xc545,0x2478,0xf128,0x3eb1,
  418. 0xcfae,0x66fc,0xb9a1,0x3ef0,
  419. 0xa0bf,0xad5d,0xe930,0x3f36,
  420. 0xde19,0x7639,0x4fcf,0x3f8a,
  421. 0x25d7,0x962f,0x9625,0x3ff0
  422. };
  423. #endif
  424. #ifdef MIEEE
  425. static unsigned short C1[] = {
  426. 0xbc62,0xbbc5,0xa478,0x4463,
  427. 0x3c79,0x1604,0x74d6,0xa49c,
  428. 0x3c8e,0x2093,0x23fc,0xc2c4,
  429. 0xbcd1,0x179f,0xa09d,0x4527,
  430. 0x3cf8,0x1e6d,0xb858,0x0025,
  431. 0xbd0b,0x3fbf,0xf591,0x0772,
  432. 0xbd30,0xe9b0,0x9dfe,0x0fcb,
  433. 0x3d69,0x3436,0xc5b0,0xcd0c,
  434. 0xbd89,0xd0f1,0xab0a,0xe164,
  435. 0xbd78,0xb13a,0x2561,0xa10c,
  436. 0x3dd8,0x166d,0xdd3a,0xbbed,
  437. 0xbdfe,0x3e30,0x4fd7,0x8b61,
  438. 0xbde9,0xd662,0x1567,0x43d3,
  439. 0x3e4c,0x3afc,0xffd9,0x4b98,
  440. 0xbe69,0x8769,0xe86c,0xa8cd,
  441. 0xbe8d,0xc421,0xb204,0x9ea4,
  442. 0x3ec0,0x53c4,0x264d,0x421f,
  443. 0x3ed2,0x2ebb,0xea34,0xe2fa,
  444. 0xbf10,0x145e,0xd801,0x0cd7,
  445. 0xbf34,0x84b3,0xe2fd,0xc93c,
  446. 0x3f40,0x4a85,0x41aa,0x68ef,
  447. 0x3f9b,0x11b6,0x0417,0xfc8d,
  448. 0x3ff1,0xd4d5,0x974c,0xe17b
  449. };
  450. static unsigned short C2[] = {
  451. 0x3c62,0x9b2d,0x1119,0x3916,
  452. 0xbc77,0xfd43,0xf6e4,0x7b70,
  453. 0xbc91,0x3d48,0x5bc5,0x6b55,
  454. 0x3cb3,0x5993,0xbae9,0x32d2,
  455. 0x3cc0,0x4bdc,0x1958,0x8227,
  456. 0xbceb,0xfd0f,0x32c7,0x3000,
  457. 0xbcf3,0xf167,0x6b8b,0x0482,
  458. 0x3d23,0xaed6,0xcbbc,0xdd23,
  459. 0x3d32,0xac59,0x6b70,0x1d61,
  460. 0xbd5a,0x2b99,0x51f1,0x6a52,
  461. 0xbd76,0x5dab,0x935b,0xcdb5,
  462. 0x3d88,0x2d18,0xf5e4,0x4d6f,
  463. 0x3db9,0xb45f,0xb882,0x095e,
  464. 0x3dbd,0xd83e,0x8e34,0x29af,
  465. 0xbdf1,0xa228,0x799b,0xbffc,
  466. 0xbe1b,0xa9cb,0x8351,0xbcf7,
  467. 0xbe34,0x4baa,0x7b57,0xca05,
  468. 0xbe29,0xc729,0xaa38,0xfce9,
  469. 0x3e74,0xebe8,0xf1ec,0xa681,
  470. 0x3eb1,0xf128,0x2478,0xc545,
  471. 0x3ef0,0xb9a1,0x66fc,0xcfae,
  472. 0x3f36,0xe930,0xad5d,0xa0bf,
  473. 0x3f8a,0x4fcf,0x7639,0xde19,
  474. 0x3ff0,0x9625,0x962f,0x25d7
  475. };
  476. #endif
  477. /* Sine and cosine integrals */
  478. #ifdef ANSIPROT
  479. extern double log ( double );
  480. extern double exp ( double );
  481. extern double fabs ( double );
  482. extern double chbevl ( double, void *, int );
  483. #else
  484. double log(), exp(), fabs(), chbevl();
  485. #endif
  486. #define EUL 0.57721566490153286061
  487. extern double MACHEP, MAXNUM, PIO2;
  488. int shichi( x, si, ci )
  489. double x;
  490. double *si, *ci;
  491. {
  492. double k, z, c, s, a;
  493. short sign;
  494. if( x < 0.0 )
  495. {
  496. sign = -1;
  497. x = -x;
  498. }
  499. else
  500. sign = 0;
  501. if( x == 0.0 )
  502. {
  503. *si = 0.0;
  504. *ci = -MAXNUM;
  505. return( 0 );
  506. }
  507. if( x >= 8.0 )
  508. goto chb;
  509. z = x * x;
  510. /* Direct power series expansion */
  511. a = 1.0;
  512. s = 1.0;
  513. c = 0.0;
  514. k = 2.0;
  515. do
  516. {
  517. a *= z/k;
  518. c += a/k;
  519. k += 1.0;
  520. a /= k;
  521. s += a/k;
  522. k += 1.0;
  523. }
  524. while( fabs(a/s) > MACHEP );
  525. s *= x;
  526. goto done;
  527. chb:
  528. if( x < 18.0 )
  529. {
  530. a = (576.0/x - 52.0)/10.0;
  531. k = exp(x) / x;
  532. s = k * chbevl( a, S1, 22 );
  533. c = k * chbevl( a, C1, 23 );
  534. goto done;
  535. }
  536. if( x <= 88.0 )
  537. {
  538. a = (6336.0/x - 212.0)/70.0;
  539. k = exp(x) / x;
  540. s = k * chbevl( a, S2, 23 );
  541. c = k * chbevl( a, C2, 24 );
  542. goto done;
  543. }
  544. else
  545. {
  546. if( sign )
  547. *si = -MAXNUM;
  548. else
  549. *si = MAXNUM;
  550. *ci = MAXNUM;
  551. return(0);
  552. }
  553. done:
  554. if( sign )
  555. s = -s;
  556. *si = s;
  557. *ci = EUL + log(x) + c;
  558. return(0);
  559. }