You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
besselk_power_series_cutoff(nu, x::Float64) = x <2.0|| nu >1.6x -1.0
432
435
besselk_power_series_cutoff(nu, x::Float32) = x <10.0f0|| nu >1.65f0*x -8.0f0
433
436
437
+
438
+
"""
439
+
besselk_asymptoticexp(v, x, order)
440
+
441
+
Computes the asymptotic expansion of K_ν w.r.t. argument. Accurate for large x, and faster than uniform asymptotic expansion for small to small-ish orders. The default order of the expansion is 10.
442
+
"""
443
+
functionbesselk_asymptoticexp(v, x::T) where T
444
+
_besselk_asymptoticexp(v, float(x), 10)
445
+
end
446
+
besselk_asexp_cutoff(nu, x) = (nu <20.0) && (x >25.0)
447
+
448
+
# Compute the function for (_v, _v+1), where _v = v-floor(v), and then do
449
+
# forward recursion. If the argument is really large, this should be faster than
450
+
# the uniform asymptotic expansion and plenty accurate.
451
+
function_besselk_asymptoticexp(v, x::T, order) where T
452
+
_v = v -floor(v)
453
+
(kv, kvp1) =_besselk_as_pair(_v, x, order)
454
+
v == _v &&return kv
455
+
_v +=one(v)
456
+
twodx =T(2)*inv(x)
457
+
while _v < v
458
+
(kv, kvp1) = (kvp1, muladd(kvp1, twodx*_v, kv))
459
+
_v +=one(_v)
460
+
end
461
+
kvp1
462
+
end
463
+
464
+
# For now, no exponential improvement. It requires the exponential integral
465
+
# function, which would either need to be lifted from SpecialFunctions.jl or
466
+
# re-implemented. And with an order of, like, 10, this seems to be pretty
467
+
# accurate and still faster than the uniform asymptotic expansion.
0 commit comments