Exercise 14.3

Exercise 14.3#

Question 1#

The roots of the function \(f(x) = e^x - 1\) can be found mathematically (without the use of numercial methods).

  1. Plot \(f(x)\) on an interval containing the root.

  2. Without using a root finding method from a package, write a function for the bisection method that takes

    • \(f\) (and \(f'\) where relevant)

    • the initial guess

    • the tolerance/precision

    as arguments.

    Verify your function by using it to find the root. Test a few values for the initial guess, what if you pick the value of the root?

Hint:

  • Functions are like any other Python object and can be set as the value of a variable or argument.

Question 2#

The function \(f(x) = e^x - 3 x - 4\) has two roots inside of the interval \([-2, 3]\).

  1. Plot \(f(x)\) over the given interval and take note of roughly where these roots lie.

  2. Find each of these roots using the function you defined in Question 1. Plot a curve for \(f(x)\) and dots where you have found the roots.