using Plots
using MTH229
plotly()
# <<your NAME>>
= <<LAST DIGIT OF STUDENT ID>> a
Extra credit opportunity
Extra credit
This extra credit is worth 5 test points.
You will need to print out your notebook where you did the work to complete this. Your first cell should be the following where your replace the two values marked with <<>>
with yours.
We will consider the following function, where a
has been defined in the first cell:
f(x) = a * log((a + sqrt(a^2 - x^2))/x) - sqrt(a^2 - x^2)
f (generic function with 1 method)
The following will plot this function over the square viewing window of size 3a
by 3a
:
plot(; xlims=(0, 3a), ylims=(0,3a), legend=false, aspect_ratio=:equal)
plot!(f, 0, a)
Just copy and paste the above into your notebook.
Task 1:
For
c=a/2
, draw the tangent line at(c,f(c))
on the graph:Write a function,
d(c)
, to compute the length of the line segment between(0, b)
and(c, f(c))
where the tangent line is of the form \(y=mx + b\).
d(c) = <<FILL THIS IN>>
(Remember, b
is the value of the tangent line when \(x=0\).)
- Compare the value of
d(c)
toa
.
Task 2:
- For any value of
c
in[0,a]
write a functionpl(x, c)
which finds the line perpendicular to the tangent line at \((c, f(c))\)
pl(x, c) = <<FILL THIS IN>>
- This function will plot the line for a given
c
. Just copy and paste it into your notebook.
P(c) = plot!(x -> pl(x, c); linecolor=RGBA(.5,.5,.5, 0.25))
P (generic function with 1 method)
- This command will draw many such lines for different values of
c
. Just copy and paste it into your notebook.
= range(0, a, length=50)
cs P.(cs)
Task 3:
Plotting an inverse function
In the projects, we learned that to add a plot of a function f
using the lower-level interface, we can first create xs
and then plot with
plot!(xs, f.(xs))
We can use this style to plot an inverse function for f
. The \(x\) and \(y\) values are reversed.
- We first create the
ys
and then plot with
plot!(f.(ys), ys)
In your graph, plot to emphasize the line, use:
plot!(f.(ys), ys; linewidth=5)
- Plot the inverse of the function of
g(x) = a * cosh(x/a)
g (generic function with 1 method)
using the range of y
values seen:
= range(0, 3a, length=100) ys
0.0:0.09090909090909091:9.0
<<PLOTTING COMMANDS HERE>>