This project implements a general root-finding algorithm using the bisection method.
The goal was to translate mathematical intuition from calculus into a working computational algorithm.
While studying Chapter 4 of Guttag’s book, I initially struggled to fully internalize the bisection approach.
Instead of memorizing the method, I decided to rebuild it from first principles.
The key realization was that efficient root-finding depends on correctly identifying boundaries that contain a root.
Reducing the search space early makes the algorithm both correct and fast.
From James Stewart’s Calculus, I used the idea that:
If a real root exists, the function must cross the x-axis at least once.
This implies that a root exists in an interval where: f(x) * f(x + Δx) < 0
Using this idea, I scanned for sign changes to automatically determine valid boundaries for the bisection process.
The implementation is structured into three main components:
- Iteratively searches for an interval where the function changes sign
- Uses a
whileloop with incremental steps - Returns the lower and upper bounds that contain a root
- Applies the bisection method within the identified boundaries
- Repeatedly halves the interval until convergence
- Combines boundary detection and bisection search
- Returns:
- the root estimate
- the number of iterations required
A separate test function, test_find_root(), was implemented to validate correctness.
- Tests 27 different combinations of parameters
- Ensures robustness across multiple scenarios
- Verifies convergence behavior and iteration counts
- How calculus concepts translate into computational algorithms
- Why boundary selection is critical for numerical methods
- How abstraction helps structure problem-solving
- How to build algorithms incrementally instead of copying formulas
Concepts and inspiration were drawn from:
- MIT 6.100L
- Guttag, Introduction to Computation and Programming
- Think Python
- James Stewart, Calculus
This project reflects my learning process and focuses on understanding over optimization.
Future improvements could include:
- adaptive step sizing for boundary detection
- support for other root-finding methods