As with the first test, you can use the computer and the internet, but you can not use your phone during the test, AI tools, or communicate with others in any way during the test.
As with the first test, some questions will require you to show your Julia commands to receive full credit. If your commands donโt match those taught in class, they may be marked as incorrect.
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:
usingMTH229usingPlots
Precompiling packages...
922.3 ms โ JSON
1510.9 ms โ Roots
590.7 ms โ Conda
435.0 ms โ SimpleExpressions โ SimpleExpressionsRootsExt
546.4 ms โ Roots โ RootsForwardDiffExt
996.4 ms โ CalculusWithJulia
971.3 ms โ CalculusWithJulia โ CalculusWithJuliaSymPyCoreExt
6747.6 ms โ PyCall
1650.0 ms โ SymPy
1327.2 ms โ Roots โ RootsSymPyExt
2467.7 ms โ MTH229
11 dependencies successfully precompiled in 14 seconds. 96 already precompiled.
Precompiling packages...
22943.5 ms โ Plots
1 dependency successfully precompiled in 23 seconds. 175 already precompiled.
Precompiling packages...
1452.2 ms โ CalculusWithJulia โ CalculusWithJuliaPlotsExt
1 dependency successfully precompiled in 2 seconds. 208 already precompiled.
(Unfortunately, plotly() doesnโt work within this HTML page, so our graphics are static.)
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))plot(f, -1, 1)
What is the value of \(L\)? Use NaN if the limit does not exist.
What is the suggested value of the limit as \(x \rightarrow 0\)?
Why is the suggested value not2.05598856865836?
Question
Limits can be done symbolically. The MTH229 package loads the SymPy package which provides the @syms command to make symbolic variables and limit to find the limit of symbolic expressions. What is the output of this set of commands?
@syms xf(x) = (1+ x) ^ (1+ x)limit(f(x), x=>0)
Question
Use the same approach to find this limit:
\[
\lim_{x \rightarrow 0} (1 + x)^{1 + 1/x}
\]
Question
Yes, we can do limits with SymPybut, 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?
\[
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
The graphic shows the graph of \(f(x)\) along with a secant line and a tangent line.
What is the dashed line
What is the dotted line?
Is the tangent line parallel to the secant line?
Question
What does the following code compute?
f(x) =cos(x)c, h =pi/4, 1e-6(f(c + h) -f(c)) / h
-0.7071071347342084
How accurate do you expect the answer to be?
Question
What does the following code compute?
f(x) =cos(x)c =pi/4f'(c)
-0.7071067811865475
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:
The only problem is the resulting derivative can grow in complexity. How many summands after simplification does the derivative of have?
@syms xex =x*sin(x)*(1-cos(x))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.
The value \(x_1=2\) is a bad starting point. Does the algorithm still converge?
Question
Use Newtonโs method to find a when \(f(x) = 1/2\) if \(f(x) = \sin(\sin(x))\). Use \(x_1=1\) as a nearby value.
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 for the critical point (when \(f'(x) = 0\)).
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?