pub fn bessel_kn_recur<E, V, const N: i32>(x: V, k0: V, k1: V) -> (V, V)where
E: FloatElement,
V: FloatVector<Element = E>,Expand description
$K_N(x)$ for N >= 2 from $K_0$ and $K_1$, by upward recurrence.
K_{n+1}(x) = K_{n-1}(x) + \frac{2n}{x} K_n(x)Takes the two seeds rather than the coefficient tables that produce them. The recurrence has nothing to do with any table, and threading four of them through so it could call the order-0 and order-1 kernels itself cost fourteen const-generic array lengths on a function whose arithmetic needs none. The one place that already names the tables concretely, the per-element dispatch, builds the seeds instead.
Scaled and unscaled both work with no flag: $e^{x}$ is a common factor of every term and
passes straight through, so whichever form the seeds are in is the form that comes out.
§Why upward, when I needs downward
$K_\nu$ is the dominant solution of the modified Bessel equation and $I_\nu$ the
minimal one, so the stability argument inverts exactly. Recurring $K$ upward amplifies
what is already growing, which is harmless. Recurring the minimal solution upward
destroys it, which is what forces $I$ onto a downward continued fraction with an
$O(x)$ trip count. Here the cost is N - 1 steps: no continued fraction, no dependence
on x, and no precision tier to measure. That is why this is the one kernel in the file
with no P: Policy parameter at all. Every operation in it is exact-by-construction
arithmetic, so there is no approximation to pick a tier for.
§Overflow
$K_N$ grows quickly in the order: $K_{50}(1)$ is about $2.6\times10^{78}$ and
$K_{60}(1)$ leaves f64. The recurrence sums terms of like sign, so it saturates to
$+\infty$ rather than returning a wrong finite value, and the scaled form buys nothing
here: unlike $I$, this overflow is in N, not in x.