Exercise 14.2

Exercise 14.2#

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 secant method that takes

    • \(f\)

    • the initial guesses

    • the tolerance/precision

    as arguments.

    Verify your function by using it to find the root. Test a few values for the starting points, 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.