# Bisection Method

Bisection method is a numerical method to find the root of a polynomial. In bisection method we iteratively reach to the solution by narrowing down after guessing two values which enclose the actual solution.

Bisection method is the same thing as guess the number game you might have played in your school, where the player guesses the number and then receives a hint about whether the actual number is greater or lesser the guess. The player keeps track of the hints and tries to reach the actual number in minimum number of guesses. Here is as sample game (the solution is 4)

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
---|

**Gameplay1: Random Guesses**

- Guess: 8 (hint: the actual number is lower)
- Guess: 2 (hint: the actual number is higher)
- Guess: 7 (hint: the actual number is lower)
- Guess: 5 (hint: the actual number is lower)
- Guess: 4 (correct)

**Gameplay2: Cutting into Halves**

- Guess: 5 (hint: the actual number is lower)
- Guess: 2 (hint: the actual number is higher)
- Guess: 4 (correct)

In the above two gameplays it’s clear that it is better to cut the bounded region in half than to take blind guesses. Bisection method uses the same technique to solve an equation and approaches to the solution by dividing the possible solution region to half and then deciding which side will contain the solution. Hint: The side where the function meets x-axis is the side to go. The values for which the function gives values with opposite signs encloses the point where the function meets x-axis.

# Steps

- Guess the initial upper and lower bounds first. (which must enclose the actual solution)
- Check if the initial upper and lower bounds are correct. If the function gives values with opposite signs for both values, then the bounds are correct.
- Iteratively:
- Calculate the midpoint of the upper and lower bounds
- Calculate the value of the function for all the three values: lowerBound, upperBound and the midpoint
- Decide which side to go. (The side which contains the solution/where the function changes sign)

Replace either lower or upper bound with the midpoint to cut the region into half. In other words, choose either lowerBound, midpoint or midpoint, upperBound as the new lowerBound and upperBound - Repeat until the value of midpoint reaches the desired decimal places or the difference between lower and upper bound is less than the tolerable error.

- Midpoint is your desired solution.

# Example

f(x) = x^{2} - 3

Let a: lower bound , b:upper bound and m: midpoint for brevity.

**Initial Bounds:** a = 1 & b=2

a | b | f(a) | f(b) | m = (a+b)/2 | f(m) | Choosing the Side | Error = b-a |
---|---|---|---|---|---|---|---|

1.0 | 2.0 | -2.0 | 1.0 | 1.5 | -0.75 | a = m | 0.5 |

1.5 | 2.0 | -0.75 | 1.0 | 1.75 | 0.062 | b = m | 0.25 |

1.5 | 1.75 | -0.75 | 0.0625 | 1.625 | -0.359 | a = m | 0.125 |

1.625 | 1.75 | -0.3594 | 0.0625 | 1.6875 | -0.1523 | a = m | 0.0625 |

1.6875 | 1.75 | -0.1523 | 0.0625 | 1.7188 | -0.0457 | a = m | 0.0313 |

1.7188 | 1.75 | -0.0457 | 0.0625 | 1.7344 | 0.0081 | b = m | 0.0156 |

1.71988 | 1.7344 | -0.0457 | 0.0081 | 1.7266 | -0.0189 | a = m | 0.0078 |

Now the error is tolerable hence our **desired solution is 1.7266**

This example was a simple but in real life it takes a huge number of iterations to reach the desired root hence we use computer to help us.

Written by Arifullah Jan and last revised on