# Bisection Method | Numerical Methods Lesson 4

The bisection method is a numerical method used to find the root of a given function. It is a simple and robust method that can be used for finding the roots of both linear and nonlinear functions.

The basic idea behind the bisection method is to repeatedly divide an interval containing a root of the function into two equal subintervals and then determine which subinterval contains the root. This process is repeated until the desired level of accuracy is achieved.

The bisection method assumes that the function is continuous and changes sign over the interval being considered. The method works by evaluating the function at the midpoint of the interval, and then determining which subinterval contains the root based on the sign of the function at the midpoint.

The algorithm for the bisection method is as follows:

1. Choose an interval [a,b] containing a root of the function f(x).
2. Evaluate the function at the midpoint c=(a+b)/2.
3. If f(c) is zero, then c is the root and the algorithm terminates.
4. If f(c) has the same sign as f(a), then the root is in the interval [c,b]. Set a=c and go to step 2.
5. If f(c) has the same sign as f(b), then the root is in the interval [a,c]. Set b=c and go to step 2.

The bisection method is guaranteed to converge to a root of the function if the initial interval contains a root and the function is continuous and changes sign over the interval. However, the method can be slow compared to other numerical methods and may require many iterations to achieve a desired level of accuracy.

## Simplified

This is a simplified explanation of the algorithm.

1. Choose two points a and b such that the function f(x) changes sign between them, which means f(a) and f(b) have opposite signs.
2. Calculate the midpoint c = (a+b)/2.
3. Evaluate the function at the midpoint f(c).
4. If f(c) is zero, then c is the root and the algorithm terminates.
5. If f(c) has the same sign as f(a), then the root is in the interval [c,b]. Set a=c and go to step 2.
6. If f(c) has the same sign as f(b), then the root is in the interval [a,c]. Set b=c and go to step 2.
7. Repeat steps 2 to 6 until the desired level of accuracy is achieved.

The bisection method repeatedly divides the interval into two equal subintervals and determines which subinterval contains the root by checking the sign of the function at the midpoint of the interval. This process is repeated until the desired level of accuracy is achieved.

## Example 1

Let’s say we want to find the root of the function f(x) = x^3 – 2x – 5.

First, we need to choose an interval [a,b] that contains a root of the function. Let’s choose the interval [2,3] since f(2) = -1 and f(3) = 10, which means that the function changes sign over the interval.

Next, we calculate the midpoint of the interval c = (a+b)/2 = (2+3)/2 = 2.5.

We evaluate the function at the midpoint f(c) = 2.5^3 – 2(2.5) – 5 = -0.875.

Since f(c) is negative, we know that the root is in the interval [c,b] = [2.5,3]. So, we set a=c=2.5 and go back to step 2.

We repeat the process by calculating the midpoint of the new interval c = (a+b)/2 = (2.5+3)/2 = 2.75.

We evaluate the function at the midpoint f(c) = 2.75^3 – 2(2.75) – 5 = 0.404.

Since f(c) is positive, we know that the root is in the interval [a,c] = [2.5,2.75]. So, we set b=c=2.75 and go back to step 2.

We repeat the process by calculating the midpoint of the new interval c = (a+b)/2 = (2.5+2.75)/2 = 2.625.

We evaluate the function at the midpoint f(c) = 2.625^3 – 2(2.625) – 5 = -0.243.

Since f(c) is negative, we know that the root is in the interval [c,b] = [2.625,2.75]. So, we set a=c=2.625 and go back to step 2.

We continue this process until we reach the desired level of accuracy or until we reach a maximum number of iterations. For example, we may choose to stop the algorithm when the absolute difference between b and a is less than a certain tolerance value (e.g. 0.0001). Once we have found the root to the desired level of accuracy, we can stop the algorithm and return the value of c as the approximate root of the function.

## Example 2

Let’s say we want to find the root of the function f(x) = sin(x) – x/2.

First, we need to choose an interval [a,b] that contains a root of the function. Let’s choose the interval [0, 1] since f(0) = 0 and f(1) = 0.0651, which means that the function changes sign over the interval.

Next, we can use the bisection method algorithm to find the approximate root of the function:

1. Choose the interval [a,b] = [0,1].
2. Calculate the midpoint c = (a+b)/2 = 0.5.
3. Evaluate the function at the midpoint f(c) = sin(0.5) – 0.5/2 = 0.0663.
4. Since f(c) is positive, we know that the root is in the interval [a,c] = [0,0.5]. Set b=c=0.5 and go back to step 2.
5. Calculate the midpoint c = (a+b)/2 = 0.25.
6. Evaluate the function at the midpoint f(c) = sin(0.25) – 0.25/2 = -0.0587.
7. Since f(c) is negative, we know that the root is in the interval [c,b] = [0.25,0.5]. Set a=c=0.25 and go back to step 2.
8. Repeat steps 2 to 7 until the desired level of accuracy is achieved.

The bisection method algorithm will continue to divide the interval in half and evaluate the function at the midpoint until the desired level of accuracy is achieved or a maximum number of iterations is reached. Once we have found the root to the desired level of accuracy, we can stop the algorithm and return the value of c as the approximate root of the function.

## Excercises

Exercise 1: Use the bisection method to find the root of the function f(x) = x^2 – 3 in the interval [1, 2] with a tolerance of 0.0001. Write the solution to three decimal places.

Exercise 2: Use the bisection method to find the root of the function f(x) = cos(x) – x^3 in the interval [0, 1] with a tolerance of 0.0001. Write the solution to three decimal places.

## Reviewer

To avoid written quizzes reviewer, click setting on the upper right corner options/settings and check only “multiple choice”.

## 2 thoughts on “Bisection Method | Numerical Methods Lesson 4”

1. June Vergel Querol says:

What seems to be the difficult part Mr. Duriguez?