using MTH229 import PlotlyJS plotly()
Rather than use the online submission of answers, as we do with the projects, this will be submitted through email to prepare for the test.
For each question you should use Julia to answer the question, then you should take a picture with your phone or take a screenshot and email it to me jverzani@gmail.com
with a title like Jane Doe, question #1
. At the top of each cell, type your name so that I know it comes from your screen.
That is, you "picture" would look like this:
Q1: Find the one zero of $f(x) = x^5-x-1$ using Julia:
# John Verzani f(x) = x^5 - x - 1 fzero(f, 1)
1.1673039782614187
Okay, let's begin. This is an extra credit project on lines. It is worth upto 50 additional points on your projects. (That is it could bump your project average up 5 points if done well.)
Q1: The secant line between two points $(a,f(a))$ and $(b,f(b))$ can be added to a graph using a command like:
f(x) = x^5 - x - 1 a,b = 1, 2 plot(f, 0.5, 2.5) plot!(secant(f, a, b))
What is the slope of the secant line just drawn?
## your name here
Q2: Find the point where the secant line above intersects the $x$ axis.
## your name here
Q3: The secant method is like Newton's method, only it uses secant lines, not tangent lines. This has the advantage of not having to compute the derivative and the disadvantage of being theoretically a bit slower.
Run these two commands (the first runs the secant method, the second Newtons method)
fzero(f, (1,2), order=1, verbose=true)
1.1673039782614187
newton(f, 1, verbose=true)
1.1673039782614187
Do the two methods return the same answer for the zero? Do they take the same number of iterations? Do they take the same number of function evaluations?
## your name here
Q4: The tangent line to the graph of f
at c
can be added by the tangent(f,c)
function. For example, he we add 2 tangent lines:
f(x) =x^5 - x - 1 plot(f, 1,2.2) plot!(tangent(f, 2)) plot!(tangent(f,1))
We want to find the $x$ value of the intersection point of the two tangent lines. Let:
a, b = 1, 2 h(x) = tangent(f,b)(x) - tangent(f,a)(x)
h (generic function with 1 method)
Then h
is zero at the intersection point. Find x:
## your name here
Q5: Make the same graph as before only using $f(x) = x^2 - x - 1$. Again with a=1
and b=2
find the intersection point of the two tangent lines. As well, one of these two examples has the intersection point exactly midway between $a$ and $b$, which one?
## your name here
(As an aside, You can see parabolas will always have this be true from this computation:)
@vars a b c x α β p(x) = a*x^2 + b*x + c dp(x) = 2*a*x + b t1 = p(α) + dp(α)*(x-α) t2 = p(β) + dp(β)*(x-β) solve(t1-t2, x)
Q6. The area between two curves described by $f(x)$ and $g(x)$ over $[a,b]$ is the integral $\int_a^b f(x)-g(x) dx$.
Let $f(x) = x^5 - x - 1$, $a=1$ and $b=.15$. Let $c$ be the point of intersection of the two tangent lines. The following graph uses an approximation of c
:
f(x) =x^5 - x - 1 plot(f, .95,1.6) plot!(tangent(f, 1)) plot!(tangent(f, 1.5)) c = 1.30 # only an approximation! plot!([c,c],[0,f(c)])
For the actual value of c
(that is find it as above), what is the area under f
above the tangent line at a
between a
and c
? Compare with the area under f
above the tangent line at b
between c
and b
. (You may find the functions defined helpful:)
## your name here f(x) = x^5 - x - 1 a,b = 1, 1.5 h(x) = tangent(f, b)(x) - tangent(f,a)(x) ha(x) = f(x) - tangent(f,a)(x) hb(x) = f(x) - tangent(f,b)(x)
hb (generic function with 1 method)
Q7. Repeat the same computation as above, only now use $f(x) = x^2 - x - 1$. Do you get the same area on each side of $c$?
## your name here
Q8. Linearization in calculus means (essentially) replacing a section of a curve around some point $(c,f(c))$ with the tangent line at c for purposes of computing values of the function near $c$.
Let $f(x) = 1/(1-x)$ and $c=0$. Use linearization to compute $f(0.1)$ and compare to the exact value. Which is right?
a) $f(x) \approx x$;
b) $f(x) \approx 1+x$;
c) $f(x) \approx 1-x$; or
d) $f(x) \approx 1-1/x$
## your name here