Skip to content

feat(root_finding): add Brent bracketed scalar root finder - #323

Merged
kmolan merged 5 commits into
kmolan:mainfrom
snowyukitty:feat/brent-root-finder
Aug 16, 2026
Merged

kmolan merged 5 commits into
kmolan:mainfrom
snowyukitty:feat/brent-root-finder

Conversation

@snowyukitty

Copy link
Copy Markdown
Contributor

Description

Adds a bracketed scalar root finder using Brent's method (the Dekker-Brent algorithm) in crates/multicalc/src/root_finding/brent.rs.

Implementation Details

  • Combines bracket preservation with secant method and inverse quadratic interpolation (IQI).
  • Implements standard Brent fallback checks to guarantee bisection convergence while achieving superlinear convergence on smooth functions.
  • Integrates seamlessly with existing RootReport and RootTermination structures.
  • Added comprehensive unit tests in crates/multicalc/tests/suite/root_finding.rs comparing against Bisection fixtures (asserting equal root precision with strictly fewer iterations), invalid brackets, non-finite values, and budget exhaustion.

Testing

  • cargo test -p multicalc

Closes #216

@snowyukitty
snowyukitty requested a review from kmolan as a code owner August 16, 2026 04:36

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the first PR! 🎉 You'll get a first review within 48 h. CI runs the 5-target matrix — a budget-gate failure isn't your fault, see ci/README.md.

@kmolan

kmolan commented Aug 16, 2026 •

Copy link
Copy Markdown
Owner

@snowyukitty you're failing pipelines. Run cargo fmt --all and push the formatting changes.

@snowyukitty

Copy link
Copy Markdown
Contributor Author

Done — I ran cargo fmt --all and pushed the formatting-only follow-up in b6987cf. The current check is green. Thanks for the pointer.

@kmolan

kmolan commented Aug 16, 2026

Copy link
Copy Markdown
Owner

Brent is not re-exported from the crate root. lib.rs exports Bisection, Newton, NewtonSystem, etc., which is why use multicalc::Bisection works. Currently use multicalc::Brent does not work.


/// Evaluates inverse quadratic interpolation (IQI) through three points `(a, fa)`, `(b, fb)`, `(c, fc)`.
#[inline]
pub fn inverse_quadratic_interpolation<T: Numeric>(a: T, fa: T, b: T, fb: T, c: T, fc: T) -> T {

@kmolan kmolan Aug 16, 2026 •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this public? I don't know if external users will want to access this. Lets keep it pub(crate) so its internal only and we can still test it.

Also it is missing the #[must_use] attribute

@snowyukitty

Copy link
Copy Markdown
Contributor Author

Done in 35c4521 — Brent is now re-exported from the crate root, the IQI helper is pub(crate) with #[must_use] and in-module coverage, and I added the required Unreleased changelog entry. The full local test, clippy, and docs checks are green.

@kmolan
kmolan merged commit d63fa75 into kmolan:main Aug 16, 2026
16 checks passed
@kmolan

kmolan commented Aug 16, 2026

Copy link
Copy Markdown
Owner

@snowyukitty thanks! Looking forward to more contributions 🚀

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.

Add a Brent bracketed root finder

2 participants