This repository provides efficient implementations of the Modified Anderson-Björck (ModAB) bracketing root-finding algorithm [1] for solving nonlinear equations of the form f(x) = 0.
Available in C, C#, C++ (ROOT.CERN framework), Python, Julia, Zig, Rust, Java, TypeScript, and Excel/VBA.
- Guaranteed convergence - Bracketing approach ensures the root is always found.
- Great performance - Fewer function evaluations than Brent, Ridders, and other popular methods. Being simple and lightweight, it has very little computational overhead per iteration.
- Worst-case optimality - Retains the worst-case optimality of Bisection for the hard cases.
- Cross-platform - Python package that works on Windows, Linux, and macOS.
- Multiple languages - Use in your preferred environment.
- Extensive testing and benchmarking - The algorithm is benchmark against a broad set of test functions of many different types.
The ModAB algorithm combines the reliability of bisection with the speed of the secant method:
- Bisection phase - Starts with bisection to ensure stability
- Linearity detection - Monitors when the function behavior is close enough to linear
- False-position acceleration - Switches to false-position method when conditions are favorable
- Anderson-Björck correction - Applies A&B corrections to prevent stalling
- Rational correction - Bends the secant step to follow the curvature of the function, using a 3-point rational model through the bracket and the last endpoint it dropped
- Closing step - Keeps each new point at least half the tolerance away from the endpoint just evaluated, so a one-sided convergence still closes the bracket
- Adaptive fallback - Returns to bisection if progress slows
This hybrid approach achieves superlinear convergence while maintaining the worst-case optimality of bisection. The current version with steps 5 and 6 is called Rational ModAB (RModAB).
| Method | Mean | Error | StdDev |
|---|---|---|---|
| Bisection | 103.51 us | 0.923 us | 0.721 us |
| FalsePosition | 362.01 us | 1.612 us | 1.346 us |
| Illinois | 150.20 us | 0.452 us | 0.377 us |
| AndersonBjork | 214.96 us | 0.651 us | 0.544 us |
| ITP | 256.18 us | 2.287 us | 2.028 us |
| Ridders | 104.32 us | 0.689 us | 0.645 us |
| Brent | 123.36 us | 1.506 us | 1.409 us |
| ModAB | 58.26 us | 0.482 us | 0.376 us |
| RModAB | 58.18 us | 0.728 us | 0.645 us |
*BenchmarkDotNet v0.15.8, .NET 10.0.12 x64 RyuJIT x86-64-v4
Windows 11 (10.0.26200.9711/25H2/2025Update/HudsonValley2)
Intel Core i7-1065G7 CPU 1.30GHz 8 logical and 4 physical cores + 16 GB RAM
| Func | bs | fp | ill | AB | ITP | Rid | Br | ModAB | RModAB |
|---|---|---|---|---|---|---|---|---|---|
| SumAll | 4835 | 11192 | 4087 | 5267 | 3337 | 3354 | 3141 | 1992 | 1881 |
| Valid | 4428 | 10715 | 3486 | 4666 | 2925 | 2897 | 2699 | 1705 | 1596 |
| Ave | 47.6 | 115.2 | 37.5 | 50.2 | 31.5 | 31.2 | 29.0 | 18.3 | 17.2 |
| Mean | 45.2 | 68.4 | 22.1 | 22.6 | 24.8 | 22.2 | 17.2 | 14.7 | 13.6 |
| StdDev | 8.9 | 88.2 | 49.4 | 69.6 | 19.1 | 33.7 | 39.4 | 14.7 | 14.1 |
| Median | 49.0 | 202.0 | 15.0 | 13.0 | 23.0 | 17.0 | 12.0 | 12.0 | 11.0 |
| Max | 53 | 202 | 202 | 202 | 55 | 202 | 142 | 78 | 56 |
| BestAt | 14 | 5 | 1 | 18 | 5 | 2 | 21 | 22 | 67 |
| WorstAt | 38 | 50 | 5 | 13 | 2 | 3 | 0 | 1 | 1 |
| Succ | 93 | 46 | 88 | 80 | 93 | 91 | 93 | 93 | 93 |
| Invalid | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 |
| False | 0 | 19 | 0 | 0 | 0 | 2 | 0 | 0 | 0 |
| MaxIter | 0 | 28 | 5 | 13 | 0 | 0 | 0 | 0 | 0 |
MIT License - see the LICENSE file for details.
Calcpad - https://calcpad.eu - C#
Root-Fortran - https://github.com/jacobwilliams/roots-fortran - Fortran
ROOT.CERN - https://github.com/root-project/root - C++
SCiML/NonlinearSolve.jl - https://github.com/SciML/NonlinearSolve.jl - Julia
JuliaMath/Roots.jl - https://github.com/JuliaMath/Roots.jl - Julia
MultiFloats.jl - https://github.com/dzhang314/MultiFloats.jl - Julia
mpmath - https://pypi.org/project/mpmath/ - Python (https://github.com/mpmath/mpmath)
PyModAB - https://pypi.org/project/pymodab/ - Python/C
-
Ganchovski, N.; Smith, O.; Rackauckas, C.; Tomov, L.; Traykov, A. Improvements to the Modified Anderson–Björck (modAB) Root-Finding Algorithm. Algorithms 2026, 19, 332. https://doi.org/10.3390/a19050332
-
Ganchovski N. Structural Analysis by Functional Modeling in the Cloud. PhD Thesis 2025, UACEG, Sofia
-
Ganchovski, N.; Traykov, A. (2023). "Modified Anderson-Björck's method for solving non-linear equations in structural mechanics." IOP Conference Series: Materials Science and Engineering, 1276(1), 012010. DOI: 10.1088/1757-899X/1276/1/012010
-
Galvão, Henrique & Silva, Valdelírio. (2024). Classes de Métodos Numéricos não Convencionais para Determinação de Raízes de Funções. DOI: 10.13140/RG.2.2.24088.57606
-
Błonka, Adrian. (2025). Optimization of Network Tied-Arch Bridges with Metaheuristic and Gradient-based Algorithms. https://www.researchgate.net/publication/405267708
-
Yarndley, Jack & Evans, Adam & Zhou, Xingyu & Wijayatunga, Minduli & Armellin, Roberto. (2026). Exoplanetary Tour Design with Solar Sails: TheAntipodes Results in the GTOC13 Problem. DOI: 10.48550/arXiv.2607.10150
Contributions are welcome. You can open an issue or submit a pull request.
