Skip to main content

HybridRoots

PyPI version License: MIT Python 3.8+

Multi-Phase Hybrid Bracketing Algorithms for Numerical Root Finding

A Python package implementing four novel root-finding algorithms that combine bisection/trisection, false position, and modified secant methods for efficient, reliable nonlinear equation solving.

Features

  • Four Algorithms: Opt.BF, Opt.BFMS, Opt.TF, Opt.TFMS
  • Pure Python: No external dependencies required
  • SciPy Compatible: Same interface as scipy.optimize.brentq
  • Deterministic: Guaranteed convergence for bracketed roots

Algorithm Summary

Algorithm Method Avg Iterations NFE/iter
mpbfms Bisection + False Position + Modified Secant ~2.8 3-4
mptfms Trisection + False Position + Modified Secant ~2.4 4-5
mpbf Bisection + False Position ~6.7 2
mptf Trisection + False Position ~5.3 3

Installation

pip install hybridroots

For development with testing:

pip install hybridroots[test]

🔧 Usage

from hybridroots import mpbf, mpbfms, mptf, mptfms

# Define your function
def f(x):
    return x**3 - x - 2

# Find root in interval [1, 2]
root, info = mpbfms(f, 1, 2)
print(f"Root: {root}")  # Root: 1.5213797068045676
print(f"Iterations: {info['iterations']}")
print(f"Function calls: {info['function_calls']}")

# All algorithms have the same interface
root1, _ = mpbf(f, 1, 2)    # Opt.BF
root2, _ = mpbfms(f, 1, 2)  # Opt.BFMS
root3, _ = mptf(f, 1, 2)    # Opt.TF
root4, _ = mptfms(f, 1, 2)  # Opt.TFMS

Parameters

Parameter Type Default Description
f callable required Function to find root of
a float required Left endpoint of bracket
b float required Right endpoint of bracket
tol float 1e-14 Absolute tolerance
max_iter int 10000 Maximum iterations

Returns

Value Type Description
root float Approximate root
info dict {'iterations', 'function_calls', 'converged'}

📖 Algorithm Overview

Opt.BFMS (mpbfms)

Multi-phase Bisection-False Position-Modified Secant method:

  1. Bisection step to reduce interval
  2. False position step for refinement
  3. Modified secant with adaptive δ

Opt.TFMS (mptfms)

Multi-phase Trisection-False Position-Modified Secant method:

  1. Trisection for interval reduction
  2. False position refinement
  3. Modified secant with adaptive δ

Opt.BF (mpbf)

Multi-phase Bisection-False Position method. Each iteration:

  1. Bisection step to reduce interval
  2. False position step for refinement

Opt.TF (mptf)

Multi-phase Trisection-False Position method:

  1. Trisection (divides interval into thirds)
  2. False position refinement

📚 Citation

If you use this package in your research, please cite:

@article{ellithy2026hybrid,
  title={Four New Multi-Phase Hybrid Bracketing Algorithms for Numerical Root Finding},
  author={Ellithy, Abdelrahman},
  journal={Journal of the Egyptian Mathematical Society},
  volume={34},
  year={2026},
  publisher={National Information and Documentation Centre (NIDOC), Academy of Scientific Research and Technology, ASRT}
}

Running Benchmarks

pip install hybridroots[benchmark]
python -m hybridroots.benchmarks

📄 License

MIT License - see LICENSE for details.

Links

Metadata

Release files for hybridroots 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hybridroots 1.0.1
File Size Uploaded
hybridroots-1.0.1.tar.gz 15.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hybridroots 1.0.1
File Interpreter ABI Platform
hybridroots-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 31.7 kB

Release files / hybridroots-1.0.1.tar.gz

Download URL hybridroots-1.0.1.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
09d5bbba0a8c3b1bc3004e3f4c55db8bf32a52053ecfc41a544ba86425fb9b93
BLAKE2b-256 checksum
How to use checksums
eac901b33dbdd45bfa816ce5f60556a81bafd98b2b91424327a1c9169053de48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Release files / hybridroots-1.0.1-py3-none-any.whl

Download URL hybridroots-1.0.1-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c47de90605dd1c7adcaa1576e2c64e88044d2fd7cfb15061e25dbbf5b376dcaa
BLAKE2b-256 checksum
How to use checksums
ef87a85c03f58f54c18f676adca392155cf07cf4a2f397a4daff94151807def2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page