top of page
Search
  • Writer's pictureMichael G

Mastering the Bisection Method with MATLAB

Hi there! 👋 it's Michael and in the forthcoming article, we will explore the Bisection Method, a numerical technique employed to determine the root of a function f . We'll delve into the mechanics of this method, elucidating its implementation using MATLAB.

Throughout our exploration, we'll examine key aspects of the bisection method, including how it verifies the sign of the function at interval endpoints, handles special cases where the function value is near zero at an endpoint, and applies the basic bisection algorithm to iteratively narrow down the interval until the desired accuracy is achieved.

Moreover, we'll delve into the practical application of the bisection method, demonstrating how it returns results and providing insights into its computational efficiency and accuracy.


Problem statement:


  • Compute its roots with an accuracy of the fifth decimal place using the bisection method.


We use the bisection method to calculate the root of the function f with an accuracy of the fifth decimal place in the interval [0, 3]. For the implementation of the bisection method on the function f, the following MATLAB code was used:



Explanation:

Checking the Sign of the Function:


  • The check if f(a)*f(b) > 0 ,verifies if the signs of the function at the endpoints of the interval are the same. If yes, then the bisection method cannot be used because there is no change in sign within the interval, and it prints an error message.

Special Cases:


  • If the value of the function at one of the endpoints of the interval is already very close to zero (less than or equal to the tolerance), then this endpoint is considered a root, and the function returns this value.

Basic Bisection Algorithm:


  • Then, the method uses the basic bisection algorithm: it divides the interval in half (c), checks the sign of the function at c, and continues to split the interval according to the sign.

  • The algorithm repeats until the desired accuracy is achieved (the difference between the endpoints of the interval is less than the tolerance).


Results:


Bisection Result: root_bisection = 0.85714

Number of Iterations: n = 30



Until the next one, cheers! 🍺


Comments


bottom of page