pub fn bessel_ik_half<P, E, V, const SCALED: bool>(
nu: V,
x: V,
far_threshold: E,
) -> (V, V)Expand description
$(I_\nu(x), K_\nu(x))$ at half-integer $\nu$, both signs of $\nu$, for $x > 0$.
With SCALED, returns $(e^{-x}I_\nu(x),\; e^{x}K_\nu(x))$, the same convention the
integer-order entry points use, and the one this kernel works in internally regardless,
because the seeds are otherwise unrepresentable: $\sinh x$ overflows at $x = 710$ while
$e^{-x}\sinh x$ is $1/2$ forever. The unscaled form is the scaled one times an
exponential, and pays that exponential’s $x\,\varepsilon/2$ relative error, which is the
documented reason to prefer the scaled twin on accuracy grounds, not only on range.
§Seeds
I_{1/2} = \sqrt{\tfrac{2}{\pi x}}\sinh x,\quad
I_{-1/2} = \sqrt{\tfrac{2}{\pi x}}\cosh x,\quad
K_{1/2} = K_{-1/2} = \sqrt{\tfrac{\pi}{2x}}\,e^{-x}Scaled, $e^{-x}\sinh x = -\mathrm{expm1}(-2x)/2$ and $e^{-x}\cosh x = (1 + e^{-2x})/2$,
so one exp_m1 supplies both and neither loses a bit to cancellation at small $x$,
which the algebraically equal $(1 - e^{-2x})/2$ would.
§Directions
$K$ is the dominant solution and walks upward, $n$ steps, no trip count and no $x$
dependence. $I$ is the minimal one and cannot: its upward recurrence subtracts nearly
equal terms for $k \ll x$ and loses bits every step whatever the order. So $I$ takes the
downward ratio recurrence $r_h = 1/(2h/x + r_{h+1})$, seeded at zero above the wanted
order, exactly as the integer-order $I$ kernel does and with the same two tier constants.
Unlike $J$ there is no zero to trip over: $I_{-1/2} = \sqrt{2/\pi x}\cosh x$ is positive
everywhere, so the normalization needs no choice between two seeds.
§Negative order
$K$ is even in $\nu$ at every order and needs nothing. $I$ is not, at non-integer
order, and the reflection brings $K$ in:
I_{-(m+1/2)}(x) = I_{m+1/2}(x) + \tfrac{2}{\pi}(-1)^m K_{m+1/2}(x)This is a genuine subtraction when $m$ is odd, and $I_{-(m+1/2)}$ really does have
zeros: $I_{-3/2}$ vanishes near $x = 1.1997$, where $\tanh x = 1/x$. The contract is
absolute against the larger term, not relative, for the same reason it is for $J$ at its
zeros. Boost’s bessel_ik carries the same formula with the same exposure.
far_threshold is where the unscaled form halves its exponential, see
unscale_i. It comes from the BesselI table so every $I$
arm in the crate turns that corner at the same x.