Lab 2: Limits And Derivatives: Part 1
(Click here for the Maple version)
(Click here for part 2)
By Christopher J. Tralie
Problem 1: Root Finding Using The Intermediate Value Theorem (5 pts)
Consider the equation \[ sin(x) + \sqrt{x} = x \] This equation would be difficult to solve using conventional algebraic means, so we will be instead using a numerical technique that relies on continuity. To do this, let's hone in on the interval [2, 3] for x. Since each individual component of this equation is continuous on this interval, each side of the equation is continuous, and the intermediate value theorem holds.
Step 1: Showing Existence of A Solution on [2, 3]
First, re-arrange the above equation into the form f(x) = 0. Then, define a function in Sage that represents f(x), evaluate f(x) at the endpoints of the interval, and use the intermediate value theorem to conclude that there must be a solution.
Question:Explain in your writeup how you are applying the intermediate value theorem to conclude that there is a solution in the interval [2, 3].
Hint: You may need to numerically evaluate f(2) and f(3) to help you with this. Look back at the previous lab to refresh yourself on how to do this.
Step 2: Root Finding by Logarithmic Search
You will now hone in on the root of f(x) (a solution f(x) = 0), which is also a solution of the above equation, by successively halving the interval under consideration. Start with a variable a = 2 and a variable b = 3. Then, perform the following steps several times
- Define a variable c that's halfway in between a and b
- Replace either a or b with the value of c, so that the new f(a) and f(b) continue to have opposite signs.
- Repeat steps 1 and 2 six more times and indicate in your writeup what your intervals are at each step.
Hint: The print()
command will print out results into your cells, and it can take multiple comma separated values. For instance, print(1, 2, 3)
will output 1 2 3
. This command should help you to keep your notebook organized.
Question: What is the seventh c you get when you do this? Plug in that c to \[ \sin(x) + \sqrt{x} = x \] How close is it to satisfying that equation compared to the x = 2 and x = 3 that you started with?
Extra Credit Question (+2) : How long would it take to get within 0.01 of a true solution of the equation? (Hint: There's a reason this is called logarithmic search). Are you within that tolerance?
Problem 2: Derivatives in Sage (5 pts)
You will now familiarize yourself with the derivative
command in Sage. To take a derivative of an algebraic expression with respect to a variable in that expression, type derivative(expression, variable)
. For instance,
derivative(x^2 + 3*x, x)
2*x + 3
.
Question: What is the derivative of \[ e^{\sqrt{4x^2 + 2}} \] with respect to x? Do this problem by hand and attach your work, then use Sage to show that you got the correct answer.
Problem 3: Gaussian Derivatives and Hermite Polynomials: An Application To Neuroscience (5 pts)
Consider the function \[ f(x) = \frac{1}{2}e^{-x^2/2} \] Compute the first two derivatives by hand and attach your work (taking a picture of writing on paper is fine). Then check your answers using the derivative function in Sage. Note that to take the nth derivative of a function f with respect to x in Sage, the command is
fn = derivative(f, x, n)
Question: Use Sage to compute and plot the 10th derivative, the 50th derivative, and the 100th derivative over the interval from -4 to 4. What pattern do you notice happening as you compute more and more derivatives?
For your general edification, you should know that the polynomials in front of the exponential term at each derivative are known as Hermite polynomials. Also, the derivatives are related to Morlet wavelets, which is a model for how the visual cortex in our brains picks up on edges and stripe patterns.