Skip to content

Add Finance.Solver.Brent, a derivative-free solver - #23

Merged
tubedude merged 2 commits into
mainfrom
solver-brent
Jul 5, 2026
Merged

Add Finance.Solver.Brent, a derivative-free solver#23
tubedude merged 2 commits into
mainfrom
solver-brent

Conversation

@tubedude

@tubedude tubedude commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Finance.Solver.Brent implements Brent's method — bracketing secant,
inverse-quadratic interpolation, and a bisection safeguard. It uses no
derivative, so each iteration costs a single NPV evaluation rather than the two
(NPV + derivative) that safeguarded Newton spends per step.

That makes it faster on long-horizon flows — long amortization schedules,
bond ladders — where each evaluation is itself expensive. On short series Newton
is quicker, so it stays the default; Brent is opt-in per call
(solver: Finance.Solver.Brent) or globally (config :finance, solver: ...).

The shared bracketing and parallel-batch helpers move from
Finance.Solver.Newton into Finance.Shared, so both solvers reuse one
implementation. Brent is parity-tested against the default across a rate × term
sweep (assert_in_delta, 1e-7), reproduces the existing xirr anchors, and
covers divergence, arithmetic overflow, negative-zero collapse, and batch
solve_many.

Ships as 1.6.0.

🤖 Generated with Claude Code

tubedude and others added 2 commits July 5, 2026 13:59
Brent's method (bracketing secant + inverse-quadratic interpolation +
bisection) spends one NPV evaluation per step instead of two, so it is
faster on long-horizon flows. Newton stays the default; select Brent with
`solver: Finance.Solver.Brent`.

Extract the shared bracket and parallel-batch helpers from Newton into
Finance.Shared so both solvers reuse them.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AVibXT2w1dEdVtMHqffFKn
@tubedude
tubedude merged commit 7126474 into main Jul 5, 2026
4 checks passed
@tubedude
tubedude deleted the solver-brent branch July 5, 2026 17:14
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 100.0%. remained the same — solver-brent into main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants