Test 2 Review

Review for test 2 in MTH229

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:

using MTH229
using Plots
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.


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:

a, b = 4, 2
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\)?


Why is the suggested value not 2.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 x
f(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 SymPy but, 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
a, b = 4, 2
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)
L = limit(f(x), x=>0)
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

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/4
f'(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:

@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
ex = 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?