Skip to main content

Module interp

Module interp 

Expand description

Between-pillar interpolation, and which schemes can carry a derivative.

Every scheme here acts on a discount curve’s log discount factor pillars, because that is what the piecewise families store. The anchor (τ = 0, ln DF = 0) is implicit — it is not a free parameter, so it is not in the ordinate vector — and each scheme treats it as the left end of the first segment.

§Schemes and derivatives

A scheme that is linear in its ordinates records exact adjoints for free: the weights are functions of the abscissae alone, which are passive schedule quantities, so the mode’s arithmetic differentiates the ordinates and nothing else. Every scheme in this module is of that kind.

A scheme whose coefficients depend non-linearly on the ordinates — a Hagan-West monotone-convex region boundary that moves as the pillars move, a monotonicity filter that switches on a comparison between them — cannot record correct first-order adjoints without differentiating through that dependence. Such a scheme SHALL declare adjoint_refusal rather than return numbers that can carry the wrong sign: reporting a wrong sensitivity is worse than reporting none. Value queries are unaffected — the refusal governs only risk read-back.

Enums§

Interpolation
How a discount curve reads between its pillars.

Functions§

anchored 🔒
The knot ordinates in the mode: the anchor’s zero, then the pillars’.
band 🔒
The two band coefficients of the continuity system on a segment of length h: the off-diagonal A and the half-diagonal B.
capped 🔒
t with its magnitude capped at bound’s, its sign kept.
cosh_minus 🔒
z·cosh(z) − sinh(z), accurate for small z for the same reason.
extrapolate 🔒
The log discount factor past the last pillar: the last segment’s forward rate, held flat.
hagan_west_forwards 🔒
Hagan-West knot forwards, collared for monotonicity.
hagan_west_integral 🔒
∫₀ˣ G, where G is Hagan-West’s shape function on one segment with G(0) = g0, G(1) = g1 and ∫₀¹ G = 0.
hermite_slopes 🔒
Knot slopes for the Hermite-based monotone schemes.
hyman_filter 🔒
Hyman’s monotonicity filter over knot slopes m, given the secants s and spacings h, the branches chosen on passive values so every mode differentiates the slopes it keeps.
knot 🔒
Knot i of the sequence, without materialising it.
knots 🔒
The knot sequence: the implicit anchor followed by the free pillars.
magnitude 🔒
|x|, the sign read on the passive value.
monotone_value 🔒
A monotone scheme’s value on the located segment, its shape parameters live in the mode.
secants 🔒
Secant slopes over the knot sequence.
second_derivatives 🔒
The second derivatives at every knot, solved from the continuity system.
sinh_minus 🔒
sinh(z) − z, accurate for small z where the subtraction cancels.
sinh_ratio 🔒
sinh(σx) / sinh(σh) for 0 ≤ x ≤ h, written so a large σh cannot overflow: both exponentials are of non-positive argument.
slopes 🔒
The divided differences d_i = (y_{i+1} − y_i)/h_i over the knot sequence.
solve_tridiagonal 🔒
Solves a tridiagonal system A x = d by the Thomas algorithm, with the matrix passive and the right-hand side in the pricing mode.
spline_value 🔒
The spline’s value on the segment hi ends, given the solved second derivatives.
zero_rates 🔒
The knot ordinates in zero-rate space: each pillar’s −y/τ, and the anchor’s taken as the first pillar’s, where 0/0 leaves it undefined.