Module solve
Expand description
Bracketed scalar root-finders for the passive kernels.
Every iterative solve on the pricing surface — an OAS from a clean price, a
yield from a dirty price, a volatility from an option price — is a passive
f64 problem with one unknown and a monotone objective. The two shapes
here cover them: bisection when only values are available, and a
bracket-safeguarded Newton when the derivative is already in hand from a
forward-mode pass — and, where only values are available but the
objective is smooth, Brent’s method: bisection’s bracket kept at every
step, with a secant or inverse-quadratic step taken whenever one would
land inside the bracket and shrink it fast enough.
All three terminate on a scale-free tolerance rather than a fixed iteration
count: a residual small in the target’s own units, or a step that has
stopped moving the unknown. A fixed count is either wasteful (two hundred
halvings of a bracket that reached f64 resolution at fifty) or, at large
notionals, unreachable (chasing the last representable digit of a
ten-million-notional price). The cap is a backstop, and reaching it is a
reported failure, not a silently returned midpoint.
Structs§
- Solve
Tolerance 🔒 - The convergence criteria, relative to the magnitude of what they measure.
- Solved 🔒
- A converged solve: the root and the iterations it took.
Enums§
- Solve
Failure 🔒 - Why a solve did not produce a root.
Functions§
- bisect_
monotone 🔒 - Bisection for
f(x) = targeton a monotonefover[lo, hi]. - brent_
monotone 🔒 - Brent’s method for
f(x) = targeton a monotonefover[lo, hi]. - newton_
bracketed 🔒 - Newton for
f(x) = targetfromx0, safeguarded by the bracket[lo, hi].