Skip to main content

Four Multi-phase hybrid bracketing algorithms for numerical root finding

Project description

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
mpbf Bisection + False Position ~6.7 2
mpbfms Bisection + False Position + Modified Secant ~2.8 3-4
mptf Trisection + False Position ~5.3 3
mptfms Trisection + False Position + Modified Secant ~2.4 4-5

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.BF (mpbf)

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

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

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.TF (mptf)

Multi-phase Trisection-False Position method:

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

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 δ

📚 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={Springer}
}

Running Benchmarks

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

📄 License

MIT License - see LICENSE for details.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hybridroots-1.0.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hybridroots-1.0.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file hybridroots-1.0.0.tar.gz.

File metadata

  • Download URL: hybridroots-1.0.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for hybridroots-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6e5e1a09254f8480ac3cd8d2fdde0b362bc96fd449dac35eb5202c9bd7426f7b
MD5 6301582bf18c2b4838136bcb5b8e545b
BLAKE2b-256 d488495653074668411b2b68a9b6d4a5ed268fe812e50c42050e95a01da7df1a

See more details on using hashes here.

File details

Details for the file hybridroots-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: hybridroots-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for hybridroots-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b0c0903df7549bbfbdea7ae9eef24ededaf4b35e69368e007f128807522aa21
MD5 07d519cc51015173f99dbf6f25e327fa
BLAKE2b-256 b76cbea265413408c00e04bb78afb7e340d95118dfa9f5679af9e57f2985f1ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page