Skip to main content

bessel_jn_pair_impl

Function bessel_jn_pair_impl 

Source
pub fn bessel_jn_pair_impl<P, E, V, const A1: usize, const A2: usize, const AH: usize, const B1: usize, const B2: usize, const BH: usize, const N: i32>(
    x: V,
    t0: &BesselJ<E, A1, A2, AH>,
    t1: &BesselJ<E, B1, B2, BH>,
) -> (V, V)
Expand description

(J_{N-1}, J_N) for N >= 2.

§Two arms, and why J gets a crossover that I did not

$J_\nu$ is the minimal solution, so upward recurrence is unstable in general, and yet measured against mpmath it is exact whenever N < x: worst 3.08e-16 envelope-relative over orders 2..50 and x to 300.

That is the reverse of what happened for $I_\nu$, where forward recurrence failed even far into the region the textbook rule blesses, and the reason is worth writing down because the two look like the same recurrence. I accumulates cancellation: I_{k+1} = I_{k-1} - (2k/x)I_k subtracts two nearly equal numbers for k << x, losing bits every step regardless of which solution dominates. J oscillates, so its terms are not systematically close and there is nothing to cancel. What is left is dominant-solution admixture, and Y_n/J_n is O(1) precisely while N < x.

So the split is on N < x, and both arms are bounded by N alone: forward costs N - 1 steps, and the downward arm is only reached where x <= N, which caps its x-scaled trip count at 0.35N. No O(x) tail, and therefore no asymptotic arm needed.

§The normalization, and the trap in it

The downward arm produces ratios r_k = J_k/J_{k-1} and recovers J_N = J_0 \prod r_k. That normalization is fine for $I$, whose order-0 value is positive everywhere, and wrong for $J$, whose J_0 vanishes at 2.405, 5.520, … Boost normalizes by J_0 regardless. Here the seed is whichever of J_0, J_1 is larger in magnitude. They have no common zero, so one of them is always well away from zero. J_1 seeding divides the product by r_1, which is exactly J_0/J_1 and cancels the bad factor rather than carrying it.

Last built: 2026-09-08 21:35:55 UTC