8 #include <lifev/navier_stokes/function/bessel/bessel.hpp> 11 double gamma (
double x);
13 int bessik01a (
double x,
double& i0,
double& i1,
double& k0,
double& k1,
14 double& i0p,
double& i1p,
double& k0p,
double& k1p)
16 double r, x2, ca, cb, ct, ww, w0, xr, xr2;
81 for (k = 1; k <= 50; k++)
83 r *= 0.25 * x2 / (k * k);
85 if (std::fabs (r / i0) <
eps)
92 for (k = 1; k <= 50; k++)
94 r *= 0.25 * x2 / (k * (k + 1) );
96 if (std::fabs (r / i1) <
eps)
117 ca = std::exp (x) / std::sqrt (2.0 *
M_PI * x);
120 for (k = 0; k < kz; k++)
122 i0 += a[k] * std::pow (xr, k + 1);
126 for (k = 0; k < kz; k++)
128 i1 += b[k] * std::pow (xr, k + 1);
134 ct = - (std::log (0.5 * x) +
el);
139 for (k = 1; k <= 50; k++)
142 r *= 0.25 * x2 / (k * k);
144 if (std::fabs ( (k0 - ww) / k0) <
eps)
157 for (k = 0; k < 8; k++)
159 k0 += a1[k] * std::pow (xr2, k + 1);
163 k1 = (1.0 / x - i1 * k0) / i0;
171 int bessik01b (
double x,
double& i0,
double& i1,
double& k0,
double& k1,
172 double& i0p,
double& i1p,
double& k0p,
double& k1p)
174 double t, t2, dtmp, dtmp1;
196 i0 = ( ( ( ( (0.0045813 * t2 + 0.0360768) * t2 + 0.2659732) * t2 +
197 1.2067492) * t2 + 3.0899424) * t2 + 3.5156229) * t2 + 1.0;
198 i1 = x * ( ( ( ( (0.00032411 * t2 + 0.00301532) * t2 + 0.02658733 * t2 +
199 0.15084934) * t2 + 0.51498869) * t2 + 0.87890594) * t2 + 0.5);
204 dtmp1 = std::exp (x) / std::sqrt (x);
205 dtmp = ( ( ( ( ( ( (0.00392377 * t - 0.01647633) * t + 0.026355537) * t - 0.02057706) * t +
206 0.00916281) * t - 0.00157565) * t + 0.00225319) * t + 0.01328592) * t + 0.39894228;
208 dtmp = ( ( ( ( ( ( (-0.00420059 * t + 0.01787654) * t - 0.02895312) * t + 0.02282967) * t -
209 0.01031555) * t + 0.00163801) * t - 0.00362018) * t - 0.03988024) * t + 0.39894228;
216 dtmp = ( ( ( ( (0.0000074 * t2 + 0.0001075) * t2 + 0.00262698) * t2 + 0.0348859) * t2 +
217 0.23069756) * t2 + 0.4227842) * t2 - 0.57721566;
218 k0 = dtmp - i0 * std::log (t);
219 dtmp = ( ( ( ( (-0.00004686 * t2 - 0.00110404) * t2 - 0.01919402) * t2 -
220 0.18156897) * t2 - 0.67278578) * t2 + 0.15443144) * t2 + 1.0;
221 k1 = dtmp / x + i1 * std::log (t);
226 dtmp1 = std::exp (-x) / std::sqrt (x);
227 dtmp = ( ( ( ( (0.00053208 * t - 0.0025154) * t + 0.00587872) * t - 0.01062446) * t +
228 0.02189568) * t - 0.07832358) * t + 1.25331414;
230 dtmp = ( ( ( ( (-0.00068245 * t + 0.00325614) * t - 0.00780353) * t + 0.01504268) * t -
231 0.0365562) * t + 0.23498619) * t + 1.25331414;
240 int bessikna (
int n,
double x,
int& nm,
double* in,
double* kn,
241 double* inp,
double* knp)
243 double bi0, bi1, bk0, bk1, g, g0, g1, f, f0, f1, h, h0, h1, s0;
246 if ( (x < 0.0) || (n < 0) )
252 for (k = 0; k <= n; k++)
273 if ( (x > 40.0) && (n < (
int) (0.25 * x) ) )
277 for (k = 2; k <= n; k++)
279 h = -2.0 * (k - 1.0) * h1 / x + h0;
298 for (k = m; k >= 0; k--)
300 f = 2.0 * (k + 1.0) * f1 / x + f0;
309 for (k = 0; k <= m; k++)
316 for (k = 2; k <= nm; k++)
318 g = 2.0 * (k - 1.0) * g1 / x + g0;
323 for (k = 2; k <= nm; k++)
325 inp[k] = in[k - 1] - k * in[k] / x;
326 knp[k] = -kn[k - 1] - k * kn[k] / x;
330 int bessiknb (
int n,
double x,
int& nm,
double* in,
double* kn,
331 double* inp,
double* knp)
333 double s0, bs, f (0), f0, f1, sk0, a0, bkl, vt, r, g, g0, g1;
336 if ( (x < 0.0) || (n < 0) )
342 for (k = 0; k <= n; k++)
371 for (k = m; k >= 0; k--)
373 f = 2.0 * (k + 1.0) * f1 / x + f0;
378 if ( (k != 0) && (k == 2 * (
int) (k / 2) ) )
386 s0 = std::exp (x) / (bs - f);
387 for (k = 0; k <= nm; k++)
393 kn[0] = - (std::log (0.5 * x) +
el) * in[0] + s0 * sk0;
394 kn[1] = (1.0 / x - in[1] * kn[0]) / in[0];
398 a0 = std::sqrt (M_PI_2 / x) * std::exp (-x);
415 for (l = 0; l < 2; l++)
420 for (k = 1; k <= kz; k++)
422 r *= 0.125 * (vt - std::pow (2.0 * k - 1.0, 2) ) / (k * x);
430 for (k = 2; k <= nm; k++)
432 g = 2.0 * (k - 1.0) * g1 / x + g0;
439 for (k = 1; k <= nm; k++)
441 inp[k] = in[k - 1] - k * in[k] / x;
442 knp[k] = -kn[k - 1] - k * kn[k] / x;
454 int bessikv (
double v,
double x,
double& vm,
double* iv,
double* kv,
455 double* ivp,
double* kvp)
457 double x2, v0, piv, vt, a1, v0p, gap (0), r, bi0, ca, sum;
458 double f (0), f1, f2, ct, cs, wa, gan, ww, w0, v0n;
459 double r1, r2, bk0, bk1, bk2, a2, cb;
462 if ( (v < 0.0) || (x < 0.0) )
475 for (k = 0; k <= n; k++)
500 a1 = std::pow (0.5 * x, v0) / gap;
518 for (k = 1; k <= 30; k++)
520 r *= 0.25 * x2 / (k * (k + v0) );
522 if (std::fabs (r / bi0) <
eps)
531 ca = std::exp (x) / std::sqrt (2.0 *
M_PI * x);
534 for (k = 1; k <= kz; k++)
536 r *= -0.125 * (vt - std::pow (2.0 * k - 1.0, 2.0) ) / (k * x);
552 for (k = m; k >= 0; k--)
554 f = 2.0 * (v0 + k + 1.0) * f1 / x + f2;
563 for (k = 0; k <= n; k++)
567 ivp[0] = v0 * iv[0] / x + iv[1];
568 for (k = 1; k <= n; k++)
570 ivp[k] = - (k + v0) * iv[k] / x + iv[k - 1];
577 ct = -std::log (0.5 * x) -
el;
581 for (k = 1; k <= 50; k++)
584 r *= 0.25 * x2 / (k * k);
587 if (std::fabs ( (wa - ww) / wa) <
eps)
599 a2 = 1.0 / (gan * std::pow (0.5 * x, v0) );
600 a1 = std::pow (0.5 * x, v0) / gap;
604 for (k = 1; k <= 120; k++)
606 r1 *= 0.25 * x2 / (k * (k - v0) );
607 r2 *= 0.25 * x2 / (k * (k + v0) );
608 sum += a2 * r1 - a1 * r2;
609 wa = std::fabs (sum);
610 if (std::fabs ( (wa - ww) / wa) <
eps)
616 bk0 = M_PI_2 * sum / std::sin (piv);
621 cb = std::exp (-x) * std::sqrt (M_PI_2 / x);
624 for (k = 1; k <= kz; k++)
626 r *= 0.125 * (vt - std::pow (2.0 * k - 1.0, 2.0) ) / (k * x);
631 bk1 = (1.0 / x - iv[1] * bk0) / iv[0];
634 for (k = 2; k <= n; k++)
636 bk2 = 2.0 * (v0 + k - 1.0) * bk1 / x + bk0;
641 kvp[0] = v0 * kv[0] / x - kv[1];
642 for (k = 1; k <= n; k++)
644 kvp[k] = - (k + v0) * kv[k] / x - kv[k - 1];
int msta1(double x, int mp)
int bessik01b(double x, double &i0, double &i1, double &k0, double &k1, double &i0p, double &i1p, double &k0p, double &k1p)
int msta2(double x, int n, int mp)
int bessikna(int n, double x, int &nm, double *in, double *kn, double *inp, double *knp)
int bessiknb(int n, double x, int &nm, double *in, double *kn, double *inp, double *knp)
int bessik01a(double x, double &i0, double &i1, double &k0, double &k1, double &i0p, double &i1p, double &k0p, double &k1p)
int bessikv(double v, double x, double &vm, double *iv, double *kv, double *ivp, double *kvp)