02| Bisection Method

Introduction

The values of \(x\) that satisfy \(f(x) = 0\) are called the roots of \(f(x)\). Finding the roots of equations is important in science and engineering, but some equations, such as \(\cos x - x = 0\) (called transcendental equations), cannot be solved analytically. In such cases, numerical methods are needed. One such method is the Bisection method.

To understand how the Bisection method works, notice that the function has opposite signs on either side of the root. The Bisection method uses this fact to ‘box in’ the root. Here’s how it works:

  1. Pick two values of \(x\) (let’s call them \(x_\text{left}\) and \(x_\text{right}\)) that we know lie on opposite sides of the root.
  2. Determine the midpoint \(x_\text{mid}\) of \(x_\text{left}\) and \(x_\text{right}\), and evaluate the function at this point.
  3. If the sign of \(f(x_\text{mid})\) is the same as the sign \(f(x_\text{left})\), then replace \(x_\text{left}\) with \(x_\text{mid}\). Else, replace \(x_\text{right}\) with the midpoint.
  4. Now you have narrowed the range of the root to \((x_\text{left}, x_\text{mid})\) or \((x_\text{mid}, x_\text{right})\). Continue steps 2-4 until you have achieved the desired accuracy for the root.

The Bisection method is a simple but effective root-finding algorithm that can be implemented using only basic Python programming.

Tasks

  1. Plot for an estimate

    Get an estimate for the root of \(\cos x - x =0\) by plotting the functions \(\cos x\) and \(x\).

  2. Use bisection

    Use the bisection method to determine the root of \(\cos x - x =0\) to 10 decimal places.

    (Answer = 0.739_085_133_2)

Back to top