14 #include <lifev/navier_stokes/function/bessel/bessel.hpp> 17 double gamma (
double x);
37 int bessjy01a (
double x,
double& j0,
double& j1,
double& y0,
double& y1,
38 double& j0p,
double& j1p,
double& y0p,
double& y1p)
40 double x2, r, ec, w0, w1, r0, r1, cs0, cs1;
41 double cu, p0, q0, p1, q1, t1, t2;
55 -3.833534661393944e12,
57 -7.286857349377656e16,
71 -3.649010818849833e11,
73 -5.827244631566907e15,
88 -3.833857520742790e10,
90 -5.060568503314727e14,
100 -6.038440767050702e2,
102 -8.902978767070678e5,
104 -4.043620325107754e9,
105 3.827011346598605e11,
106 -4.406481417852278e13,
107 6.065091351222699e15,
108 -9.833883876590679e17,
133 for (k = 1; k <= 30; k++)
135 r *= -0.25 * x2 / (k * k);
137 if (std::fabs (r) < std::fabs (j0) * 1e-15)
144 for (k = 1; k <= 30; k++)
146 r *= -0.25 * x2 / (k * (k + 1) );
148 if (std::fabs (r) < std::fabs (j1) * 1e-15)
154 ec = std::log (0.5 * x) +
el;
158 for (k = 1; k <= 30; k++)
161 r0 *= -0.25 * x2 / (k * k);
164 if (std::fabs (r) < std::fabs (cs0) * 1e-15)
169 y0 = M_2_PI * (ec * j0 - cs0);
173 for (k = 1; k <= 30; k++)
176 r1 *= -0.25 * x2 / (k * (k + 1) );
177 r = r1 * (2.0 * w1 + 1.0 / (k + 1) );
179 if (std::fabs (r) < std::fabs (cs1) * 1e-15)
184 y1 = M_2_PI * (ec * j1 - 1.0 / x - 0.25 * x * cs1);
203 for (k = 0; k < kz; k++)
205 p0 += a[k] * std::pow (x, -2 * k - 2);
206 q0 += b[k] * std::pow (x, -2 * k - 3);
208 cu = std::sqrt (M_2_PI / x);
209 j0 = cu * (p0 * std::cos (t1) - q0 * std::sin (t1) );
210 y0 = cu * (p0 * std::sin (t1) + q0 * std::cos (t1) );
211 t2 = x - 0.75 *
M_PI;
214 for (k = 0; k < kz; k++)
216 p1 += a1[k] * std::pow (x, -2 * k - 2);
217 q1 += b1[k] * std::pow (x, -2 * k - 3);
219 j1 = cu * (p1 * std::cos (t2) - q1 * std::sin (t2) );
220 y1 = cu * (p1 * std::sin (t2) + q1 * std::cos (t2) );
247 int bessjy01b (
double x,
double& j0,
double& j1,
double& y0,
double& y1,
248 double& j0p,
double& j1p,
double& y0p,
double& y1p)
250 double t, t2, dtmp, a0, p0, q0, p1, q1, ta0, ta1;
271 j0 = ( ( ( ( ( (-0.5014415e-3 * t2 + 0.76771853e-2) * t2 - 0.0709253492) * t2 +
272 0.4443584263) * t2 - 1.7777560599) * t2 + 3.9999973021) * t2
273 - 3.9999998721) * t2 + 1.0;
274 j1 = t * ( ( ( ( ( ( (-0.1289769e-3 * t2 + 0.22069155e-2) * t2 - 0.0236616773) * t2 +
275 0.1777582922) * t2 - 0.8888839649) * t2 + 2.6666660544) * t2 -
276 3.999999971) * t2 + 1.9999999998);
277 dtmp = ( ( ( ( ( ( (-0.567433e-4 * t2 + 0.859977e-3) * t2 - 0.94855882e-2) * t2 +
278 0.0772975809) * t2 - 0.4261737419) * t2 + 1.4216421221) * t2 -
279 2.3498519931) * t2 + 1.0766115157) * t2 + 0.3674669052;
280 y0 = M_2_PI * std::log (0.5 * x) * j0 + dtmp;
281 dtmp = ( ( ( ( ( ( (0.6535773e-3 * t2 - 0.0108175626) * t2 + 0.107657607) * t2 -
282 0.7268945577) * t2 + 3.1261399273) * t2 - 7.3980241381) * t2 +
283 6.8529236342) * t2 + 0.3932562018) * t2 - 0.6366197726;
284 y1 = M_2_PI * std::log (0.5 * x) * j1 + dtmp / x;
290 a0 = std::sqrt (M_2_PI / x);
291 p0 = ( ( ( (-0.9285e-5 * t2 + 0.43506e-4) * t2 - 0.122226e-3) * t2 +
292 0.434725e-3) * t2 - 0.4394275e-2) * t2 + 0.999999997;
293 q0 = t * ( ( ( ( (0.8099e-5 * t2 - 0.35614e-4) * t2 + 0.85844e-4) * t2 -
294 0.218024e-3) * t2 + 0.1144106e-2) * t2 - 0.031249995);
296 j0 = a0 * (p0 * std::cos (ta0) - q0 * std::sin (ta0) );
297 y0 = a0 * (p0 * std::sin (ta0) + q0 * std::cos (ta0) );
298 p1 = ( ( ( (0.10632e-4 * t2 - 0.50363e-4) * t2 + 0.145575e-3) * t2
299 - 0.559487e-3) * t2 + 0.7323931e-2) * t2 + 1.000000004;
300 q1 = t * ( ( ( ( (-0.9173e-5 * t2 + 0.40658e-4) * t2 - 0.99941e-4) * t2
301 + 0.266891e-3) * t2 - 0.1601836e-2) * t2 + 0.093749994);
302 ta1 = x - 0.75 *
M_PI;
303 j1 = a0 * (p1 * std::cos (ta1) - q1 * std::sin (ta1) );
304 y1 = a0 * (p1 * std::sin (ta1) + q1 * std::cos (ta1) );
314 double a0, f0, f1, f;
318 n0 = (
int) (1.1 * a0) + 1;
319 f0 = 0.5 * std::log10 (6.28 * n0) - n0 * std::log10 (1.36 * a0 / n0) - mp;
321 f1 = 0.5 * std::log10 (6.28 * n1) - n1 * std::log10 (1.36 * a0 / n1) - mp;
322 for (i = 0; i < 20; i++)
324 nn = (
int) (n1 - (n1 - n0) / (1.0 - f0 / f1) );
325 f = 0.5 * std::log10 (6.28 * nn) - nn * std::log10 (1.36 * a0 / nn) - mp;
326 if (std::abs (nn - n1) < 1)
339 double a0, ejn, hmp, f0, f1, f, obj;
344 ejn = 0.5 * std::log10 (6.28 * n) - n * std::log10 (1.36 * a0 / n);
348 n0 = (
int) (1.1 * a0);
359 f0 = 0.5 * std::log10 (6.28 * n0) - n0 * std::log10 (1.36 * a0 / n0) - obj;
361 f1 = 0.5 * std::log10 (6.28 * n1) - n1 * std::log10 (1.36 * a0 / n1) - obj;
362 for (i = 0; i < 20; i++)
364 nn = (
int) (n1 - (n1 - n0) / (1.0 - f0 / f1) );
365 f = 0.5 * std::log10 (6.28 * nn) - nn * std::log10 (1.36 * a0 / nn) - obj;
366 if (std::abs (nn - n1) < 1)
395 int bessjyna (
int n,
double x,
int& nm,
double* jn,
double* yn,
396 double* jnp,
double* ynp)
398 double bj0, bj1, f (0), f0, f1, f2, cs;
402 if ( (x < 0.0) || (n < 0) )
408 for (i = 0; i <= n; i++)
426 if (n < (
int) 0.9 * x)
428 for (k = 2; k <= n; k++)
430 jn[k] = 2.0 * (k - 1.0) * bj1 / x - bj0;
448 for (k = m; k >= 0; k--)
450 f = 2.0 * (k + 1.0) / x * f1 - f2;
458 if (std::fabs (bj0) > std::fabs (bj1) )
466 for (k = 0; k <= nm; k++)
471 for (k = 2; k <= nm; k++)
473 jnp[k] = jn[k - 1] - k * jn[k] / x;
477 for (k = 2; k <= nm; k++)
479 f = 2.0 * (k - 1.0) * f1 / x - f0;
484 for (k = 2; k <= nm; k++)
486 ynp[k] = yn[k - 1] - k * yn[k] / x;
494 int bessjynb (
int n,
double x,
int& nm,
double* jn,
double* yn,
495 double* jnp,
double* ynp)
497 double t1, t2, f (0), f1, f2, bj0, bj1, bjk, by0, by1, cu, s0, su, sv;
498 double ec, bs, byk, p0, p1, q0, q1;
501 -0.7031250000000000e-1,
508 0.7324218750000000e-1,
530 if ( (x < 0.0) || (n < 0) )
536 for (i = 0; i <= n; i++)
547 if (x <= 300.0 || n > (
int) (0.9 * x) )
567 for (k = m; k >= 0; k--)
569 f = 2.0 * (k + 1.0) / x * f1 - f2;
574 if ( (k == 2 * (
int) (k / 2) ) && (k != 0) )
578 su += (-1) * ( (k & 2) - 1) * f / (
double) k;
583 sv += (-1) * ( (k & 2) - 1) * (
double) k * f / (k * k - 1.0);
589 for (k = 0; k <= nm; k++)
593 ec = std::log (0.5 * x) + 0.5772156649015329;
594 by0 = M_2_PI * (ec * jn[0] - 4.0 * su / s0);
596 by1 = M_2_PI * ( (ec - 1.0) * jn[1] - jn[0] / x - 4.0 * sv / s0);
604 for (k = 0; k < 4; k++)
606 p0 += a[k] * std::pow (x, -2 * k - 2);
607 q0 += b[k] * std::pow (x, -2 * k - 3);
609 cu = std::sqrt (M_2_PI / x);
610 bj0 = cu * (p0 * std::cos (t1) - q0 * std::sin (t1) );
611 by0 = cu * (p0 * std::sin (t1) + q0 * std::cos (t1) );
614 t2 = x - 0.75 *
M_PI;
617 for (k = 0; k < 4; k++)
619 p1 += a1[k] * std::pow (x, -2 * k - 2);
620 q1 += b1[k] * std::pow (x, -2 * k - 3);
622 bj1 = cu * (p1 * std::cos (t2) - q1 * std::sin (t2) );
623 by1 = cu * (p1 * std::sin (t2) + q1 * std::cos (t2) );
626 for (k = 2; k <= nm; k++)
628 bjk = 2.0 * (k - 1.0) * bj1 / x - bj0;
635 for (k = 1; k <= nm; k++)
637 jnp[k] = jn[k - 1] - k * jn[k] / x;
639 for (k = 2; k <= nm; k++)
641 byk = 2.0 * (k - 1.0) * by1 / x - by0;
647 for (k = 1; k <= nm; k++)
649 ynp[k] = yn[k - 1] - k * yn[k] / x;
661 int bessjyv (
double v,
double x,
double& vm,
double* jv,
double* yv,
662 double* djv,
double* dyv)
664 double v0, vl, vg, vv, a, a0, r, x2, bjv0 (0), bjv1, bjvl, f (0), f0, f1, f2;
665 double r0, r1, ck, cs, cs0, cs1, sk, qx, px, byv0 (0), byv1 (0), rp, xk, rq;
666 double b, ec, w0, w1, bju0 (0), bju1, pv0, pv1, byvk;
667 int j, k, l, m, n, kz;
672 if ( (x < 0.0) || (v < 0.0) )
678 for (k = 0; k <= n; k++)
699 for (l = 0; l < 2; l++)
704 for (k = 1; k <= 40; k++)
706 r *= -0.25 * x2 / (k * (k + vl) );
708 if (std::fabs (r) < std::fabs (bjvl) * 1e-15)
714 a = std::pow (0.5 * x, vl) /
gamma (vg
);
739 for (j = 0; j < 2; j++)
741 vv = 4.0 * (j + v0) * (j + v0);
744 for (k = 1; k <= kz; k++)
746 rp *= (-0.78125e-2) * (vv - std::pow (4.0 * k - 3.0, 2.0) ) *
747 (vv - std::pow (4.0 * k - 1.0, 2.0) ) / (k * (2.0 * k - 1.0) * x2);
752 for (k = 1; k <= kz; k++)
754 rq *= (-0.78125e-2) * (vv - std::pow (4.0 * k - 1.0, 2.0) ) *
755 (vv - std::pow (4.0 * k + 1.0, 2.0) ) / (k * (2.0 * k + 1.0) * x2);
758 qx *= 0.125 * (vv - 1.0) / x;
759 xk = x - (0.5 * (j + v0) + 0.25) *
M_PI;
760 a0 = std::sqrt (M_2_PI / x);
766 bjv0 = a0 * (px * ck - qx * sk);
767 byv0 = a0 * (px * sk + qx * ck);
771 bjv1 = a0 * (px * ck - qx * sk);
772 byv1 = a0 * (px * sk + qx * ck);
778 djv[0] = v0 * jv[0] / x - jv[1];
779 djv[1] = - (1.0 + v0) * jv[1] / x + jv[0];
780 if ( (n >= 2) && (n <= (
int) (0.9 * x) ) )
784 for (k = 2; k <= n; k++)
786 f = 2.0 * (k + v0 - 1.0) * f1 / x - f0;
805 for (k = m; k >= 0; k--)
807 f = 2.0 * (v0 + k + 1.0) / x * f1 - f2;
815 if (std::fabs (bjv0) > std::fabs (bjv1) )
823 for (k = 0; k <= n; k++)
828 for (k = 2; k <= n; k++)
830 djv[k] = - (k + v0) * jv[k] / x + jv[k - 1];
836 for (l = 0; l < 2; l++)
841 for (k = 1; k <= 40; k++)
843 r *= -0.25 * x2 / (k * (k - vl) );
845 if (std::fabs (r) < std::fabs (bjvl) * 1e-15)
851 b = std::pow (2.0 / x, vl) /
gamma (vg
);
862 pv1 =
M_PI * (1.0 + v0);
863 byv0 = (bjv0 * std::cos (pv0) - bju0) / std::sin (pv0);
864 byv1 = (bjv1 * std::cos (pv1) - bju1) / std::sin (pv1);
868 ec = std::log (0.5 * x) +
el;
872 for (k = 1; k <= 30; k++)
875 r0 *= -0.25 * x2 / (k * k);
878 byv0 = M_2_PI * (ec * bjv0 - cs0);
882 for (k = 1; k <= 30; k++)
885 r1 *= -0.25 * x2 / (k * (k + 1) );
886 cs1 += r1 * (2.0 * w1 + 1.0 / (k + 1.0) );
888 byv1 = M_2_PI * (ec * bjv1 - 1.0 / x - 0.25 * x * cs1);
893 for (k = 2; k <= n; k++)
895 byvk = 2.0 * (v0 + k - 1.0) * byv1 / x - byv0;
900 dyv[0] = v0 * yv[0] / x - yv[1];
901 for (k = 1; k <= n; k++)
903 dyv[k] = - (k + v0) * yv[k] / x + yv[k - 1];
int msta1(double x, int mp)
int msta2(double x, int n, int mp)
int bessjynb(int n, double x, int &nm, double *jn, double *yn, double *jnp, double *ynp)
int bessjyv(double v, double x, double &vm, double *jv, double *yv, double *jvp, double *yvp)
int bessjy01b(double x, double &j0, double &j1, double &y0, double &y1, double &j0p, double &j1p, double &y0p, double &y1p)
int bessjyna(int n, double x, int &nm, double *jn, double *yn, double *jnp, double *ynp)
int bessjy01a(double x, double &j0, double &j1, double &y0, double &y1, double &j0p, double &j1p, double &y0p, double &y1p)