51 #define CEPHES_DEBUG 0
57 #define MAXGAM 171.624376956302725
61 #define BIG 1.44115188075855872E+17
63 static double jvs(
double n,
double x);
64 static double hankel(
double n,
double x);
65 static double recur(
double *
n,
double x,
double *newn,
int cancel);
66 static double jnx(
double n,
double x);
67 static double jnt(
double n,
double x);
69 double jv(
double n,
double x)
71 double k,
q,
t,
y, an;
80 i = an - 16384.0 *
floor(an / 16384.0);
97 if ((
x < 0.0) && (
y != an)) {
103 if (
x == 0 &&
n < 0 && !nint) {
105 return INFINITY /
gamma(
n + 1);
116 if ((
y <
t) && (an > 21.0))
118 if ((an < k) && (
y > 21.0))
140 if ((
n >= 0.0) && (
n < 20.0)
141 && (
y > 6.0) && (
y < 20.0)) {
161 if (an > (k + 3.0)) {
189 t = (0.0083 *
y + 0.09) *
y + 12.9;
198 printf(
"y = %.16e, recur q = %.16e\n",
y,
q);
224 done:
return (
sign *
y);
231 static double recur(
double *
n,
double x,
double *newn,
int cancel)
233 double pkm2, pkm1, pk, qkm2, qkm1;
236 double k, ans, qk, xk, yk, r,
t, kf;
239 int miniter, maxiter;
270 printf(
"recur: n = %.6e, newn = %.6e, cfrac = ", *
n, *newn);
283 pk = pkm1 * yk + pkm2 * xk;
284 qk = qkm1 * yk + qkm2 * xk;
291 if (qk != 0 && ctr > miniter)
297 t =
fabs((ans - r) / r);
304 if (++ctr > maxiter) {
326 printf(
"%.6e\n", ans);
331 if (
fabs(ans) < 0.125) {
352 pkm2 = (pkm1 * r - pk *
x) /
x;
372 while (k > (kf + 0.5));
379 if ((kf >= 0.0) && (
fabs(pk) >
fabs(pkm1))) {
386 printf(
"newn %.6e rans %.6e\n", k, pkm2);
397 static double jvs(
double n,
double x)
399 double t, u,
y,
z, k;
409 u *=
z / (k * (
n + k));
416 printf(
"power series=%.5e ",
y);
418 t = frexp(0.5 *
x, &ex);
426 printf(
"pow(.5*x, %.4e)/gamma(n+1)=%.5e\n",
n,
t);
435 printf(
"log pow=%.5e, lgam(%.4e)=%.5e\n",
z,
n + 1.0, k);
445 printf(
"log y=%.5e\n",
log(
y));
467 double p,
q,
j,
m, pp, qq;
488 u *= (
m - k * k) / (
j *
z);
492 u *= (
m - k * k) / (
j *
z);
502 if ((flag != 0) && (
t >
conv)) {
504 printf(
"Hankel: convergence to %.4E\n",
conv);
511 u =
x - (0.5 *
n + 0.25) *
M_PI;
514 printf(
"hank: %.6e\n",
t);
526 1.041666666666666666666667E-1,
527 8.355034722222222222222222E-2,
528 1.282265745563271604938272E-1,
529 2.918490264641404642489712E-1,
530 8.816272674437576524187671E-1,
531 3.321408281862767544702647E+0,
532 1.499576298686255465867237E+1,
533 7.892301301158651813848139E+1,
534 4.744515388682643231611949E+2,
535 3.207490090890661934704328E+3
538 static double mu[] = {
540 -1.458333333333333333333333E-1,
541 -9.874131944444444444444444E-2,
542 -1.433120539158950617283951E-1,
543 -3.172272026784135480967078E-1,
544 -9.424291479571202491373028E-1,
545 -3.511203040826354261542798E+0,
546 -1.572726362036804512982712E+1,
547 -8.228143909718594444224656E+1,
548 -4.923553705236705240352022E+2,
549 -3.316218568547972508762102E+3
552 static double P1[] = {
553 -2.083333333333333333333333E-1,
554 1.250000000000000000000000E-1
557 static double P2[] = {
558 3.342013888888888888888889E-1,
559 -4.010416666666666666666667E-1,
560 7.031250000000000000000000E-2
563 static double P3[] = {
564 -1.025812596450617283950617E+0,
565 1.846462673611111111111111E+0,
566 -8.912109375000000000000000E-1,
567 7.324218750000000000000000E-2
570 static double P4[] = {
571 4.669584423426247427983539E+0,
572 -1.120700261622299382716049E+1,
573 8.789123535156250000000000E+0,
574 -2.364086914062500000000000E+0,
575 1.121520996093750000000000E-1
578 static double P5[] = {
579 -2.8212072558200244877E1,
580 8.4636217674600734632E1,
581 -9.1818241543240017361E1,
582 4.2534998745388454861E1,
583 -7.3687943594796316964E0,
584 2.27108001708984375E-1
587 static double P6[] = {
588 2.1257013003921712286E2,
589 -7.6525246814118164230E2,
590 1.0599904525279998779E3,
591 -6.9957962737613254123E2,
592 2.1819051174421159048E2,
593 -2.6491430486951555525E1,
594 5.7250142097473144531E-1
597 static double P7[] = {
598 -1.9194576623184069963E3,
599 8.0617221817373093845E3,
600 -1.3586550006434137439E4,
601 1.1655393336864533248E4,
602 -5.3056469786134031084E3,
603 1.2009029132163524628E3,
604 -1.0809091978839465550E2,
605 1.7277275025844573975E0
609 static double jnx(
double n,
double x)
611 double zeta, sqz, zz, zp,
np;
612 double cbn, n23,
t,
z, sz;
613 double pp, qq, z32i, zzi;
614 double ak, bk, akl, bkl;
615 int sign, doa, dob, nflg, k,
s, tk, tkp1,
m;
617 static double ai, aip, bi, bip;
632 t = 1.5 * (
log((1.0 + sz) /
z) - sz);
638 t = 1.5 * (sz -
acos(1.0 /
z));
642 z32i =
fabs(1.0 /
t);
650 printf(
"zeta %.5E, Airy(%.5E)\n",
zeta,
t);
652 airy(
t, &ai, &aip, &bi, &bip);
659 u[3] =
polevl(zzi,
P3, 3) / (sz * zz);
662 u[5] =
polevl(zzi,
P5, 5) / (pp * sz);
665 u[7] =
polevl(zzi,
P7, 7) / (pp * sz);
668 for (k = 0; k <= 7; k++)
669 printf(
"u[%d] = %.5E\n", k, u[k]);
681 for (k = 0; k <= 3; k++) {
687 for (
s = 0;
s <= tk;
s++) {
693 ak +=
sign *
mu[
s] * zp * u[tk -
s];
698 if (((
m + 1) & 3) > 1)
719 bk +=
lambda[tkp1] * zp * u[0];
730 printf(
"a[%d] %.5E, b[%d] %.5E\n", k, ak, k, bk);
741 t *= ai * pp /
cbrt(
n) + aip * qq / (n23 *
n);
751 -9.0000000000000000000e-2,
752 8.5714285714285714286e-2
756 1.3671428571428571429e-1,
757 -5.4920634920634920635e-2,
758 -4.4444444444444444444e-3
762 1.3500000000000000000e-3,
763 -1.6036054421768707483e-1,
764 4.2590187590187590188e-2,
765 2.7330447330447330447e-3
769 -2.4285714285714285714e-1,
770 1.4285714285714285714e-2
774 -9.0000000000000000000e-3,
775 1.9396825396825396825e-1,
776 -1.1746031746031746032e-2
780 1.9607142857142857143e-2,
781 -1.5983694083694083694e-1,
782 6.3838383838383838384e-3
786 static double jnt(
double n,
double x)
789 double cbn, n23, cbtwo;
790 double ai, aip, bi, bip;
791 double nk, fk, gk, pp, qq;
801 airy(zz, &ai, &aip, &bi, &bip);
816 for (k = 0; k <= 4; k++)
817 printf(
"F[%d] = %.5E\n", k,
F[k]);
818 for (k = 0; k <= 3; k++)
819 printf(
"G[%d] = %.5E\n", k,
G[k]);
826 for (k = 0; k <= 4; k++) {
834 printf(
"fk[%d] %.5E, gk[%d] %.5E\n", k, fk, k, gk);
839 fk = cbtwo * ai * pp / cbn +
cbrt(4.0) * aip * qq /
n;