djairy.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. /* djairy.f -- translated by f2c (version 20100827).
  2. This file no longer depends on f2c.
  3. */
  4. #include "slatec-internal.hpp"
  5. int djairy_(double *x, double *rx, double *c__, double *ai, double *dai)
  6. {
  7. /* Initialized data */
  8. static integer n1 = 14;
  9. static double const con2 = 5.03154716196777;
  10. static double const con3 = .380004589867293;
  11. static double const con4 = .833333333333333;
  12. static double const con5 = .866025403784439;
  13. static double const ak1[14] = { .220423090987793,-.1252902427877,
  14. .0103881163359194,8.22844152006343e-4,-2.34614345891226e-4,
  15. 1.63824280172116e-5,3.06902589573189e-7,-1.29621999359332e-7,
  16. 8.22908158823668e-9,1.53963968623298e-11,-3.39165465615682e-11,
  17. 2.03253257423626e-12,-1.10679546097884e-14,-5.1616949778508e-15 };
  18. static double const ak2[23] = { .274366150869598,.00539790969736903,
  19. -.0015733922062119,4.2742752824875e-4,-1.12124917399925e-4,
  20. 2.88763171318904e-5,-7.36804225370554e-6,1.87290209741024e-6,
  21. -4.75892793962291e-7,1.21130416955909e-7,-3.09245374270614e-8,
  22. 7.92454705282654e-9,-2.03902447167914e-9,5.26863056595742e-10,
  23. -1.36704767639569e-10,3.56141039013708e-11,-9.3138829654843e-12,
  24. 2.44464450473635e-12,-6.43840261990955e-13,1.70106030559349e-13,
  25. -4.50760104503281e-14,1.19774799164811e-14,-3.19077040865066e-15 }
  26. ;
  27. static double const ak3[14] = { .280271447340791,-.00178127042844379,
  28. 4.03422579628999e-5,-1.63249965269003e-6,9.21181482476768e-8,
  29. -6.52294330229155e-9,5.47138404576546e-10,-5.2440825180026e-11,
  30. 5.60477904117209e-12,-6.56375244639313e-13,8.31285761966247e-14,
  31. -1.12705134691063e-14,1.62267976598129e-15,-2.46480324312426e-16 }
  32. ;
  33. static double const ajp[19] = { .0778952966437581,-.184356363456801,
  34. .0301412605216174,.0305342724277608,-.00495424702513079,
  35. -.00172749552563952,2.4313763783919e-4,5.04564777517082e-5,
  36. -6.16316582695208e-6,-9.03986745510768e-7,9.70243778355884e-8,
  37. 1.09639453305205e-8,-1.04716330588766e-9,-9.60359441344646e-11,
  38. 8.25358789454134e-12,6.36123439018768e-13,-4.96629614116015e-14,
  39. -3.29810288929615e-15,2.35798252031104e-16 };
  40. static double const ajn[19] = { .0380497887617242,-.245319541845546,
  41. .165820623702696,.0749330045818789,-.0263476288106641,
  42. -.00592535597304981,.00144744409589804,2.18311831322215e-4,
  43. -4.10662077680304e-5,-4.66874994171766e-6,7.1521880727716e-7,
  44. 6.52964770854633e-8,-8.44284027565946e-9,-6.44186158976978e-10,
  45. 7.20802286505285e-11,4.72465431717846e-12,-4.66022632547045e-13,
  46. -2.67762710389189e-14,2.36161316570019e-15 };
  47. static double const a[15] = { .490275424742791,.00157647277946204,
  48. -9.66195963140306e-5,1.35916080268815e-7,2.98157342654859e-7,
  49. -1.86824767559979e-8,-1.03685737667141e-9,3.28660818434328e-10,
  50. -2.5709141063278e-11,-2.32357655300677e-12,9.57523279048255e-13,
  51. -1.20340828049719e-13,-2.90907716770715e-15,4.55656454580149e-15,
  52. -9.99003874810259e-16 };
  53. static integer n2 = 23;
  54. static double const b[15] = { .278593552803079,-.00352915691882584,
  55. -2.31149677384994e-5,4.7131784226356e-6,-1.12415907931333e-7,
  56. -2.00100301184339e-8,2.60948075302193e-9,-3.55098136101216e-11,
  57. -3.50849978423875e-11,5.83007187954202e-12,-2.04644828753326e-13,
  58. -1.10529179476742e-13,2.87724778038775e-14,-2.88205111009939e-15,
  59. -3.32656311696166e-16 };
  60. static integer n1d = 14;
  61. static integer n2d = 24;
  62. static integer n3d = 19;
  63. static integer n4d = 15;
  64. static integer m1d = 12;
  65. static integer m2d = 22;
  66. static integer m3d = 17;
  67. static integer m4d = 13;
  68. static double const dak1[14] = { .204567842307887,-.0661322739905664,
  69. -.00849845800989287,.00312183491556289,-2.70016489829432e-4,
  70. -6.35636298679387e-6,3.02397712409509e-6,-2.18311195330088e-7,
  71. -5.36194289332826e-10,1.1309803562231e-9,-7.43023834629073e-11,
  72. 4.28804170826891e-13,2.23810925754539e-13,-1.39140135641182e-14 };
  73. static integer n3 = 19;
  74. static double const dak2[24] = { .29333234388323,-.00806196784743112,
  75. .0024254017233314,-6.82297548850235e-4,1.85786427751181e-4,
  76. -4.97457447684059e-5,1.32090681239497e-5,-3.49528240444943e-6,
  77. 9.24362451078835e-7,-2.44732671521867e-7,6.4930783764891e-8,
  78. -1.72717621501538e-8,4.60725763604656e-9,-1.2324905529155e-9,
  79. 3.30620409488102e-10,-8.89252099772401e-11,2.39773319878298e-11,
  80. -6.4801392115345e-12,1.75510132023731e-12,-4.76303829833637e-13,
  81. 1.2949824110081e-13,-3.5267962221043e-14,9.62005151585923e-15,
  82. -2.62786914342292e-15 };
  83. static double const dak3[14] = { .284675828811349,.0025307307261908,
  84. -4.83481130337976e-5,1.84907283946343e-6,-1.01418491178576e-7,
  85. 7.05925634457153e-9,-5.85325291400382e-10,5.56357688831339e-11,
  86. -5.908890947795e-12,6.88574353784436e-13,-8.68588256452194e-14,
  87. 1.17374762617213e-14,-1.68523146510923e-15,2.55374773097056e-16 };
  88. static double const dajp[19] = { .0653219131311457,-.120262933688823,
  89. .00978010236263823,.0167948429230505,-.00197146140182132,
  90. -8.45560295098867e-4,9.42889620701976e-5,2.25827860945475e-5,
  91. -2.29067870915987e-6,-3.76343991136919e-7,3.45663933559565e-8,
  92. 4.29611332003007e-9,-3.58673691214989e-10,-3.57245881361895e-11,
  93. 2.72696091066336e-12,2.26120653095771e-13,-1.58763205238303e-14,
  94. -1.12604374485125e-15,7.31327529515367e-17 };
  95. static double const dajn[19] = { .0108594539632967,.0853313194857091,
  96. -.315277068113058,-.0878420725294257,.0553251906976048,
  97. .00941674060503241,-.00332187026018996,-4.11157343156826e-4,
  98. 1.01297326891346e-4,9.87633682208396e-6,-1.87312969812393e-6,
  99. -1.50798500131468e-7,2.32687669525394e-8,1.59599917419225e-9,
  100. -2.07665922668385e-10,-1.24103350500302e-11,1.39631765331043e-12,
  101. 7.3940097115574e-14,-7.328874756275e-15 };
  102. static double const da[15] = { .491627321104601,.00311164930427489,
  103. 8.23140762854081e-5,-4.61769776172142e-6,-6.13158880534626e-8,
  104. 2.8729580465652e-8,-1.81959715372117e-9,-1.44752826642035e-10,
  105. 4.53724043420422e-11,-3.99655065847223e-12,-3.24089119830323e-13,
  106. 1.62098952568741e-13,-2.40765247974057e-14,1.69384811284491e-16,
  107. 8.17900786477396e-16 };
  108. static double const db[15] = { -.277571356944231,.0044421283341992,
  109. -8.42328522190089e-5,-2.5804031841871e-6,3.42389720217621e-7,
  110. -6.24286894709776e-9,-2.36377836844577e-9,3.16991042656673e-10,
  111. -4.40995691658191e-12,-5.18674221093575e-12,9.64874015137022e-13,
  112. -4.9019057660871e-14,-1.77253430678112e-14,5.55950610442662e-15,
  113. -7.1179333757953e-16 };
  114. static integer n4 = 15;
  115. static integer m1 = 12;
  116. static integer m2 = 21;
  117. static integer m3 = 17;
  118. static integer m4 = 13;
  119. static double const fpi12 = 1.30899693899575;
  120. /* System generated locals */
  121. integer i__1;
  122. /* Local variables */
  123. integer i__, j;
  124. double t, e1, e2, f1, f2, ec, cv, tt, ccv, scv, rtrx, temp1, temp2;
  125. /* ***BEGIN PROLOGUE DJAIRY */
  126. /* ***SUBSIDIARY */
  127. /* ***PURPOSE Subsidiary to DBESJ and DBESY */
  128. /* ***LIBRARY SLATEC */
  129. /* ***TYPE DOUBLE PRECISION (JAIRY-S, DJAIRY-D) */
  130. /* ***AUTHOR Amos, D. E., (SNLA) */
  131. /* Daniel, S. L., (SNLA) */
  132. /* Weston, M. K., (SNLA) */
  133. /* ***DESCRIPTION */
  134. /* DJAIRY computes the Airy function AI(X) */
  135. /* and its derivative DAI(X) for DASYJY */
  136. /* INPUT */
  137. /* X - Argument, computed by DASYJY, X unrestricted */
  138. /* RX - RX=SQRT(ABS(X)), computed by DASYJY */
  139. /* C - C=2.*(ABS(X)**1.5)/3., computed by DASYJY */
  140. /* OUTPUT */
  141. /* AI - Value of function AI(X) */
  142. /* DAI - Value of the derivative DAI(X) */
  143. /* ***SEE ALSO DBESJ, DBESY */
  144. /* ***ROUTINES CALLED (NONE) */
  145. /* ***REVISION HISTORY (YYMMDD) */
  146. /* 750101 DATE WRITTEN */
  147. /* 890531 Changed all specific intrinsics to generic. (WRB) */
  148. /* 891009 Removed unreferenced variable. (WRB) */
  149. /* 891214 Prologue converted to Version 4.0 format. (BAB) */
  150. /* 900328 Added TYPE section. (WRB) */
  151. /* 910408 Updated the AUTHOR section. (WRB) */
  152. /* ***END PROLOGUE DJAIRY */
  153. /* ***FIRST EXECUTABLE STATEMENT DJAIRY */
  154. if (*x < 0.) {
  155. goto L90;
  156. }
  157. if (*c__ > 5.) {
  158. goto L60;
  159. }
  160. if (*x > 1.2) {
  161. goto L30;
  162. }
  163. t = (*x + *x - 1.2) * con4;
  164. tt = t + t;
  165. j = n1;
  166. f1 = ak1[j - 1];
  167. f2 = 0.;
  168. i__1 = m1;
  169. for (i__ = 1; i__ <= i__1; ++i__) {
  170. --j;
  171. temp1 = f1;
  172. f1 = tt * f1 - f2 + ak1[j - 1];
  173. f2 = temp1;
  174. /* L10: */
  175. }
  176. *ai = t * f1 - f2 + ak1[0];
  177. j = n1d;
  178. f1 = dak1[j - 1];
  179. f2 = 0.;
  180. i__1 = m1d;
  181. for (i__ = 1; i__ <= i__1; ++i__) {
  182. --j;
  183. temp1 = f1;
  184. f1 = tt * f1 - f2 + dak1[j - 1];
  185. f2 = temp1;
  186. /* L20: */
  187. }
  188. *dai = -(t * f1 - f2 + dak1[0]);
  189. return 0;
  190. L30:
  191. t = (*x + *x - con2) * con3;
  192. tt = t + t;
  193. j = n2;
  194. f1 = ak2[j - 1];
  195. f2 = 0.;
  196. i__1 = m2;
  197. for (i__ = 1; i__ <= i__1; ++i__) {
  198. --j;
  199. temp1 = f1;
  200. f1 = tt * f1 - f2 + ak2[j - 1];
  201. f2 = temp1;
  202. /* L40: */
  203. }
  204. rtrx = sqrt(*rx);
  205. ec = exp(-(*c__));
  206. *ai = ec * (t * f1 - f2 + ak2[0]) / rtrx;
  207. j = n2d;
  208. f1 = dak2[j - 1];
  209. f2 = 0.;
  210. i__1 = m2d;
  211. for (i__ = 1; i__ <= i__1; ++i__) {
  212. --j;
  213. temp1 = f1;
  214. f1 = tt * f1 - f2 + dak2[j - 1];
  215. f2 = temp1;
  216. /* L50: */
  217. }
  218. *dai = -ec * (t * f1 - f2 + dak2[0]) * rtrx;
  219. return 0;
  220. L60:
  221. t = 10. / *c__ - 1.;
  222. tt = t + t;
  223. j = n1;
  224. f1 = ak3[j - 1];
  225. f2 = 0.;
  226. i__1 = m1;
  227. for (i__ = 1; i__ <= i__1; ++i__) {
  228. --j;
  229. temp1 = f1;
  230. f1 = tt * f1 - f2 + ak3[j - 1];
  231. f2 = temp1;
  232. /* L70: */
  233. }
  234. rtrx = sqrt(*rx);
  235. ec = exp(-(*c__));
  236. *ai = ec * (t * f1 - f2 + ak3[0]) / rtrx;
  237. j = n1d;
  238. f1 = dak3[j - 1];
  239. f2 = 0.;
  240. i__1 = m1d;
  241. for (i__ = 1; i__ <= i__1; ++i__) {
  242. --j;
  243. temp1 = f1;
  244. f1 = tt * f1 - f2 + dak3[j - 1];
  245. f2 = temp1;
  246. /* L80: */
  247. }
  248. *dai = -rtrx * ec * (t * f1 - f2 + dak3[0]);
  249. return 0;
  250. L90:
  251. if (*c__ > 5.) {
  252. goto L120;
  253. }
  254. t = *c__ * .4 - 1.;
  255. tt = t + t;
  256. j = n3;
  257. f1 = ajp[j - 1];
  258. e1 = ajn[j - 1];
  259. f2 = 0.;
  260. e2 = 0.;
  261. i__1 = m3;
  262. for (i__ = 1; i__ <= i__1; ++i__) {
  263. --j;
  264. temp1 = f1;
  265. temp2 = e1;
  266. f1 = tt * f1 - f2 + ajp[j - 1];
  267. e1 = tt * e1 - e2 + ajn[j - 1];
  268. f2 = temp1;
  269. e2 = temp2;
  270. /* L100: */
  271. }
  272. *ai = t * e1 - e2 + ajn[0] - *x * (t * f1 - f2 + ajp[0]);
  273. j = n3d;
  274. f1 = dajp[j - 1];
  275. e1 = dajn[j - 1];
  276. f2 = 0.;
  277. e2 = 0.;
  278. i__1 = m3d;
  279. for (i__ = 1; i__ <= i__1; ++i__) {
  280. --j;
  281. temp1 = f1;
  282. temp2 = e1;
  283. f1 = tt * f1 - f2 + dajp[j - 1];
  284. e1 = tt * e1 - e2 + dajn[j - 1];
  285. f2 = temp1;
  286. e2 = temp2;
  287. /* L110: */
  288. }
  289. *dai = *x * *x * (t * f1 - f2 + dajp[0]) + (t * e1 - e2 + dajn[0]);
  290. return 0;
  291. L120:
  292. t = 10. / *c__ - 1.;
  293. tt = t + t;
  294. j = n4;
  295. f1 = a[j - 1];
  296. e1 = b[j - 1];
  297. f2 = 0.;
  298. e2 = 0.;
  299. i__1 = m4;
  300. for (i__ = 1; i__ <= i__1; ++i__) {
  301. --j;
  302. temp1 = f1;
  303. temp2 = e1;
  304. f1 = tt * f1 - f2 + a[j - 1];
  305. e1 = tt * e1 - e2 + b[j - 1];
  306. f2 = temp1;
  307. e2 = temp2;
  308. /* L130: */
  309. }
  310. temp1 = t * f1 - f2 + a[0];
  311. temp2 = t * e1 - e2 + b[0];
  312. rtrx = sqrt(*rx);
  313. cv = *c__ - fpi12;
  314. ccv = cos(cv);
  315. scv = sin(cv);
  316. *ai = (temp1 * ccv - temp2 * scv) / rtrx;
  317. j = n4d;
  318. f1 = da[j - 1];
  319. e1 = db[j - 1];
  320. f2 = 0.;
  321. e2 = 0.;
  322. i__1 = m4d;
  323. for (i__ = 1; i__ <= i__1; ++i__) {
  324. --j;
  325. temp1 = f1;
  326. temp2 = e1;
  327. f1 = tt * f1 - f2 + da[j - 1];
  328. e1 = tt * e1 - e2 + db[j - 1];
  329. f2 = temp1;
  330. e2 = temp2;
  331. /* L140: */
  332. }
  333. temp1 = t * f1 - f2 + da[0];
  334. temp2 = t * e1 - e2 + db[0];
  335. e1 = ccv * con5 + scv * .5;
  336. e2 = scv * con5 - ccv * .5;
  337. *dai = (temp1 * e1 - temp2 * e2) * rtrx;
  338. return 0;
  339. } /* djairy_ */