Extra credit opportunity

Extra credit

This extra credit is worth 10 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 your specific values.

using Plots
using MTH229
plotly()
nm = "<<your NAME>>"              # <--- put your name here, leave quotes
a = <<LAST DIGIT OF STUDENT ID>>  # <--- put a number here
a = max(a, 1)

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)
title!("My awesome plot, by $nm")
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(a/2) to a.

Task 2:

  • For any value of c in [0,a] write a function pl(x, c) which finds the line perpendicular to the tangent line at \((c, f(c))\)
pl(x, c) = <<FILL THIS IN>>
  • For c=a/2, again, add a plot of this normal line with the command
plot!(x -> pl(x, a/2))

It should look perpendicular to the tangent line already drawn at \((c,f(c))\). (The aspect_ratio=:equal part of plot ensures this.)

  • This makes a function to plot this normal line for any given c. Just copy and paste it into your notebook. (The linecolor argument mutes the look.)
P(c) = plot!(x -> pl(x, c); linecolor=RGBA(.5,.5,.5, 0.25))
P (generic function with 1 method)
  • These commands will draw many such lines for different values of c. Again, just copy and paste it into your notebook.
cs = range(0, a, length=50)
P.(cs)
current()

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 the “ys” 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 the “xs” with:
plot!(f.(ys), ys)

In your graph, to emphasize the line, use a linewidth value bigger than the default:

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:

ys = range(0, 3a, length=100)
0.0:0.09090909090909091:9.0
<<PLOTTING COMMANDS HERE>>

If you did it right, you can see that the graph suggested by the normal lines is the inverse of this parameterized cosh function. (See Tractrix for another illustration.)