Test 2 Review

Review for test 2 in MTH229

Test 2 will be on April 4th and cover projects 5, 6, and 7.

As with the first test, you can use the computer and the internet, but you can not use your phone or any other connected device during the test. It is too easy to communicate with others.

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
plotly()

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))
c = 0
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:

a, b = 4, 2
f(x) = ((a^x - x*log(a)) / (b^x - x*log(b)))^(1/x^2)
lim(f, 0)
6Γ—2 Matrix{Float64}:
 0.1     2.13034
 0.01    2.06377
 0.001   2.05663
 0.0001  2.05591
 1.0e-5  2.05584
 1.0e-6  2.05599

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
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

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

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.

Select an item

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 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?