File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 462
462
# function, which would either need to be lifted from SpecialFunctions.jl or
463
463
# re-implemented. And with an order of, like, 10, this seems to be pretty
464
464
# accurate and still faster than the uniform asymptotic expansion.
465
- function _besselk_as_pair (v, x:: T , order) where {T}
465
+ function _besselk_as_pair (v, x:: T , order) where T
466
+ fv = 4 * v* v
467
+ fvp1 = 4 * (v+ one (v))^ 2
468
+ z = 8 * x
469
+ knu, knpu1 = one (T), one (T)
470
+ ak_nu = fv - 1
471
+ ak_nup1 = fvp1 - 1
472
+
473
+ for i in 1 : order
474
+ term_v = ak_nu / z
475
+ term_vp1 = ak_nup1 / z
476
+ knu += term_v
477
+ knpu1 += term_vp1
478
+
479
+ a = muladd (2 , i, one (T))^ 2
480
+ z *= 8 * x* (i + one (T))
481
+
482
+ ak_nu *= fv - a
483
+ ak_nup1 *= fvp1 - a
484
+ end
485
+ coef = SQRT_PID2 (T)* exp (- x)/ sqrt (x)
486
+ return coef* knu, coef* knpu1
487
+ end
466
488
fv = 4 * v* v
467
489
fvp1 = 4 * (v+ one (v))^ 2
468
490
_z = x
You can’t perform that action at this time.
0 commit comments