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-diagonalAand the half-diagonalB. - capped 🔒
twith its magnitude capped atbound’s, its sign kept.- cosh_
minus 🔒 z·cosh(z) − sinh(z), accurate for smallzfor 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, whereGis Hagan-West’s shape function on one segment withG(0) = g0,G(1) = g1and∫₀¹ G = 0.- hermite_
slopes 🔒 - Knot slopes for the Hermite-based monotone schemes.
- hyman_
filter 🔒 - Hyman’s monotonicity filter over knot slopes
m, given the secantssand spacingsh, the branches chosen on passive values so every mode differentiates the slopes it keeps. - knot 🔒
- Knot
iof 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 smallzwhere the subtraction cancels.- sinh_
ratio 🔒 sinh(σx) / sinh(σh)for0 ≤ x ≤ h, written so a largeσhcannot overflow: both exponentials are of non-positive argument.- slopes 🔒
- The divided differences
d_i = (y_{i+1} − y_i)/h_iover the knot sequence. - solve_
tridiagonal 🔒 - Solves a tridiagonal system
A x = dby 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
hiends, 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, where0/0leaves it undefined.