using MTH229
using Plots
plotly()
Test 2 Review
Review for test 2 in MTH229
Test 2 will be on November 7th and cover projects 5, 6, and 7.
Here are some sample questions. Any similarity to actual questions is not intended and should not be inferred.
Limits
As in class, we use the following packages:
Question
Consider the function
\[ f(x) = \frac{x}{3 - \sqrt{x + 9}} \]
We wish to graphically identify the limit at \(0\), \(L=\lim_{x \rightarrow 0}f(x)\).
f(x) = x / (3 - sqrt(x + 9))
= 0
c plot(f, c - 1, c + 1)
What is the value of \(L\)? Use NaN
if the limit does not exist.
How can you tell?
Question
Let
\[ f(x) = \left(\frac{a^x - x\cdot \log(a)}{b^x - x\cdot \log(b)}\right)^{1/x^2} \]
For some \(a\) and \(b\) we have a graph of \(f\):
Based on the graphic, what is \(\lim_{x \rightarrow 0}f(x)\)?
Question
Let
\[ f(x) = \left(\frac{a^x - x\cdot \log(a)}{b^x - x\cdot \log(b)}\right)^{1/x^2} \]
For some \(a\) and \(b\) we have the following output from the lim
function of MTH229
:
= 4, 2
a, b f(x) = ((a^x - x*log(a)) / (b^x - x*log(b)))^(1/x^2)
lim(f, 0)
0.100000 2.1303447756660145 0.010000 2.0637724257542938 0.001000 2.0566280256141964 0.000100 2.0559095866739243 0.000010 2.0558379221389402 0.000001 2.05598856865836 ⋮ ⋮ c L? ⋮ ⋮ -0.000001 2.05598856865836 -0.000010 2.0558242275529772 -0.000100 2.0557498622591086 -0.001000 2.055030529226614 -0.010000 2.0477993964825556 -0.100000 1.9725283171698242
What is the suggested value of the limit as \(x \rightarrow 0\)?
Question
We can do limits with SymPy
too. However, like numeric and graphical limits, there can be subtle technical issues with symbolic limits, as illustrated below:
Does the following limit found by SymPy
agree with the one you just found?
@syms x
= 4, 2
a, b f(x) = ((a^x - x*log(a)) / (b^x - x*log(b)))^(1/x^2)
limit(f(x), x=>0)
\(\infty\)
Does this code find the proper limit?
@syms x a b
f(x) = ((a^x - x*log(a)) / (b^x - x*log(b)))^(1/x^2)
= limit(f(x), x=>0)
L L(a =>4, b=>2)
\(e^{- \frac{\log{\left(2 \right)}^{2}}{2} + \frac{\log{\left(4 \right)}^{2}}{2}}\)
Question
Let
\[ L = \lim_{x \rightarrow 4} \frac{\sqrt{x}-2}{x-4} \]
Using lim
, find the suggested value of \(L\) numerically.
Using limit
what is the exact value of \(L\)?
Question
Let
\[ f(x) = \frac{x+1}{|x+1|} \]
Using SymPy
compute:
\[ L = \lim_{x \rightarrow -1+} f(x) \]
Using SymPy
compute:
\[ L = \lim_{x \rightarrow -1-} f(x) \]
Does the limit at \(-1\) exist?
Derivatives
Question
What does the following code compute?
f(x) = cos(x)
= pi/4, 1e-6
c, h f(c + h) - f(c)) / h (
-0.7071071347342084
How accurate do you expect the answer to be?
Question
True or false: the forward difference quotient is simply the slope of the secant line between \(x=c\) and \(x=c+h\). When \(h\) is small, this secant line and tangent line have slopes which are approximately the same, but are not expected to be exactly equal.
Question
When the MTH229
package is loaded, the notation f'
can be used to find the automatic derivative of the function f
. This automatic derivative numerically computes fully accurate derivatives up to slight numeric differences.
For example, the function \(f(x) = x\cdot e^{-2x^2}\) has a derivative at \(1\) of \(-3/e^2\). If f(x) = x*exp(-2x^2)
how accurate is f'(1)
(in absolute value)?
The difference between f'(1)
and \(f'(1)\) (automatic versus exact) is:
For the same function, plot the derivative over \([0,3]\). At what \(x\) value is the derivative smallest? (Answer from the graph).
Question
Let \(f(x) = \sin(\sin^2(x))\). Graph \(f\) and its derivative over the interval \([0, \pi]\). The graph of the derivative intersects the graph of \(f\) between the endpoints at what \(x\) value? Numerically find your answer.
Question
Symbolic derivatives are easy to take: just make x
symbolic and the call diff
. For example:
@syms x
diff(x * sin(x), x)
\(x \cos{\left(x \right)} + \sin{\left(x \right)}\)
The only problem is the resulting derivative can grow in complexity. How many summands after simplification does the derivative of have?
@syms x
= x * sin(x) * (1 - cos(x))
ex diff(ex, x)
(That is, how many terms are added together in the answer after SymPy simplifies?)
Newton’s method
Question
This figure shows a visualization of Newton’s method starting at \(x_1 = 2\). What is the value of \(x_4\) (after 3 iterations). Read this from the graph.
(Note, the above uses \(x_1\) for the starting point; \(x_0\) is also a common choice to name the starting point.)
The value \(x_1=2\) is a bad starting point. Does the algorithm still converge?
Question
Use Newton’s method to find a zero of \(\sin(\sin(x)) - 1/2\) starting at \(x_1=1\).
Question
Use Newton’s method to find where \(f(x) = \cos(x)\) intersects \(g(x) = x/10\) starting at \(\pi/2\):
Do you get the same answer if you started at \(-\pi/2\)?
Question
The graph of \(f(x) = \sin(\sin(x)) - \cos(x)\) shows a critical point near \(2.5\). Use Newton’s method to find a numerically precise value.
Question
How many iterations does Newton’s method take to converge to an approximate zero of \(f(x) = \sin(\sin(x)) - \cos(x)\) starting at \(x_1 = 1\)?
Question
Let \(f(x) = x^{1/3}\), or f(x) = cbrt(x)
in Julia
. Letting \(x_1=1\) search for a zero using fzero
and with newton
. Which is correct?