Before you turn this problem in, make sure everything runs as expected. First, restart the kernel (in the menubar, select Kernel\(\rightarrow\)Restart) and then run all cells (in the menubar, select Cell\(\rightarrow\)Run All).

Make sure you fill in any place that says YOUR CODE HERE or “YOUR ANSWER HERE”, as well as your name and collaborators below:

NAME = ""
COLLABORATORS = ""

Suppose you want to solve a difficult nonlinear algebraic equation that cannot readily be solved with algebra. For example, consider \(f(x) = x e^{-x}\), and you seek to find the value of \(x\) that makes this function equal to 0.1. One way to do this is to use a nonlinear algebra solver. In this problem, we will consider a way to solve it by integrating a differential equation.

The idea is to derive the derivative of the function, \(f'(x)\), and then solve the initial value problem with an event function that finds the solution you want.

First, plot the function#

You should plot the function to see if there is a solution. Consider an x-range from 0 to 5. Comment on whether there are any solutions, and if so how many and approximately where they are.

Derive f’(x)#

This should be done by hand, and the result described in the next cell. Write a function for the derivative.

Solve the ode#

Now that you have an \(f'(x)\) Solve the initial value problem with \(f(0)\) over the x-range that you plotted the original function on. Use an event function to identify points where \(f(x)=0.1\).

Prepare a plot of the solution that has the following features:

  1. Plot the original function provided in this problem.

  2. Plot the solution you got from integrating \(f'(x)\).

  3. Plot where your solution points you found are.

Use root to solve it also, and compare your results.#


When you are done, download a PDF and turn it in on Canvas. Make sure to save your notebook, then run this cell and click on the download link.

%run ~/s25-06623/s25.py
%pdf