# Related rates


{{< include ../_common_code.qmd >}}

This section uses these add-on packages:


```{julia}
using CalculusWithJulia
using Plots
plotly()
using Roots
using SymPy
```


---


Related rates problems involve two (or more) unknown quantities that are related through an equation. As the two variables depend on each other, also so do their rates - change with respect to some variable which is often time. Exactly how remains to be discovered. Hence the name "related rates."


#### Examples


The following is a typical "book" problem:


> A *vintage* screen saver displays the outline of a $3$ cm by $2$ cm rectangle and then expands the rectangle in such a way that the $2$ cm side is expanding at the rate of $4$ cm/sec and the proportions of the rectangle never change.  How fast is the area of the rectangle increasing when its dimensions are $12$ cm by $8$ cm? [Source.](http://oregonstate.edu/instruct/mth251/cq/Stage9/Practice/ratesProblems.html)



```{julia}
#| hold: true
#| echo: false
#| cache: true
### {{{growing_rects}}}
## Secant line approaches tangent line...
gr()
function growing_rects_graph(n)
    w = (t) -> 2 + 4t
    h = (t) -> 3/2 * w(t)
    t = n - 1

    w_2 = w(t)/2
    h_2 = h(t)/2

    w_n = w(5)/2
    h_n = h(5)/2

    plt = plot(w_2 * [-1, -1, 1, 1, -1], h_2 * [-1, 1, 1, -1, -1], xlim=(-17,17), ylim=(-17,17),
               legend=false, size=fig_size)
    annotate!(plt, [(-1.5, 1, "Area = $(round(Int, 4*w_2*h_2))")])
    plt


end
caption = L"""

As $t$ increases, the size of the rectangle grows. The ratio of width to height is fixed. If we know the rate of change in time for the width ($dw/dt$) and the height ($dh/dt$) can we tell the rate of change of *area* with respect to time ($dA/dt$)?

"""
n=6

anim = @animate for i=1:n
    growing_rects_graph(i)
end

imgfile = tempname() * ".gif"
gif(anim, imgfile, fps = 1)
plotly()
ImageFile(imgfile, caption)
```

Here we know $A = w \cdot h$ and we know some things about how $w$ and $h$ are related *and* about the rate of how both $w$ and $h$ grow in time $t$. That means that we could express this growth in terms of some functions $w(t)$ and $h(t)$, then we can figure out that the area - as a function of $t$ - will be expressed as:


$$
A(t) = w(t) \cdot h(t).
$$

We would get by the product rule that the *rate of change* of area with respect to time, $A'(t)$ is just:


$$
A'(t) = w'(t) h(t) + w(t) h'(t).
$$

As an aside, it is fairly conventional to suppress the $(t)$ part of the notation $A=wh$ and to use the Leibniz notation for derivatives:


$$
\frac{dA}{dt} = \frac{dw}{dt} h + w \frac{dh}{dt}.
$$

This relationship is true for all $t$, but the problem discusses a certain value of $t$ - when $w(t)=8$ and $h(t) = 12$. At this same value of $t$, we have $w'(t) = 4$ and so $h'(t) = 6$. Substituting these 4 values into the 4 unknowns in the formula for $A'(t)$ gives:


$$
A'(t) = 4 \cdot 12 + 8 \cdot 6 = 96.
$$

Summarizing, from the relationship between $A$, $w$ and $t$, there is a relationship between their rates of growth with respect to $t$, a time variable. Using this and known values, we can compute. In this case,  $A'$ at the specific $t$.


We could also have done this differently. We would recognize the following:


  * The area of a rectangle is just:


```{julia}
A(w,h) = w * h
```

  * The width - expanding at a rate of $4t$ from a starting value of $2$ - must satisfy:


```{julia}
w(t) = 2 + 4*t
```

  * The height is a constant proportion of the width:


```{julia}
h(t) = 3 * w(t) / 2
```

This means again that area depends on $t$ through this formula:


```{julia}
A(t) = A(w(t), h(t))
```

This is why the rates of change are related: as $w$ and $h$ change in time, the functional relationship with $A$ means $A$ also changes in time.


Now to answer the question, when the width is 8, we must have that $t$ is:


```{julia}
tstar = find_zero(x -> w(x) - 8, [0, 4])  # or solve by hand to get 3/2
```

The question is to find the rate the area is increasing at the given time $t$, which is $A'(t)$ or $dA/dt$. We get this by performing the differentiation, then substituting in the value.


Here we do so with the aid of `Julia`, though this problem could readily be done "by hand."


We have expressed $A$ as a function of $t$ by composition, so can differentiate that:


```{julia}
A'(tstar)
```

---


Now what? Why is $96$ of any interest? It is if the value at a specific time is needed. But in general, a better question might be to understand if there is some pattern to the numbers in the figure, these being $6, 54, 150, 294, 486, 726$. Their differences are the *average* rate of change:


```{julia}
xs = [6, 54, 150, 294, 486, 726]
ds = diff(xs)
```

Those seem to be increasing by a fixed amount each time, which we can see by one more application of `diff`:


```{julia}
diff(ds)
```

How can this relationship be summarized? Well, let's go back to what we know, though this time using symbolic math:


```{julia}
@syms t
diff(A(t), t)
```

This should be clear: the rate of change, $dA/dt$, is increasing linearly, hence the second derivative, $d^2A/dt^2$ would be constant, just as we saw for the average rate of change.


So, for this problem, a constant rate of change in width and height leads to a linear rate of change in area, put otherwise, linear growth in both width and height leads to quadratic growth in area.


##### Example


A ladder, with length $l$, is leaning against a wall. We parameterize this problem so that the top of the ladder is at $(0,h)$ and the bottom at $(b, 0)$. Then $l^2 = h^2 + b^2$ is a constant.


If the ladder starts to slip away at the base, but remains in contact with the wall, express the rate of change of $h$ with respect to $t$ in terms of $db/dt$.

```{julia}
#| echo: false
let
    gr()
	l = 12
	b = 6
	h = sqrt(l^2 - b^2)

	plot(;
		axis=([],false),
		legend=false,
		aspect_ratio=:equal)
	P,Q = (0,h),(b,0)
	w = 0.2
	S = Shape([-w,0,0,-w],[0,0,h+1,h+1])
	plot!(S; fillstyle=:/, fillcolor=:gray80, fillalpha=0.5)
	R = Shape([-w,b+2,b+2,-w],[-w,-w,0,0])
	plot!(R, fill=(:gray, 0.25))

	plot!([P,Q]; line=(:black, 2))
	scatter!([P,Q])
	b′ = b + 3/2
	h′ = sqrt(l^2 - b′^2)

	plot!([b,b′],[0,0]; arrow=true, side=:head, line=(:blue, 3))
	plot!([0,0], [h,h′]; arrow=true, side=:head, line=(:blue, 3))

	annotate!([
	(b,-w,text(L"(b(t),0)",:top)),
		(-w, h, text(L"(0,h(t))", :bottom, rotation=90)),
		(b/2, h/2, text(L"L", rotation = -atand(h,b), :bottom))

	])
    current()
end
```

```{julia}
#| echo: false
plotly()
nothing
```



We have from implicitly differentiating in $t$ the equation $l^2 = h^2 + b^2$,  noting that $l$ is a constant, that:


$$
0 = 2h \frac{dh}{dt} + 2b \frac{db}{dt}.
$$

Solving, yields:


$$
\frac{dh}{dt} = -\frac{b}{h} \cdot \frac{db}{dt}.
$$

  * If when $l = 12$ it is known that $db/dt = 2$ when $b=4$, find $dh/dt$.


We just need to find $h$ for this value of $b$, as the other two quantities in the last equation are known.


But $h = \sqrt{l^2 - b^2}$, so the answer is:


```{julia}
length, bottom, dbdt = 12, 4, 2
height = sqrt(length^2 - bottom^2)
-bottom/height * dbdt
```

  * What happens to the rate as $b$ goes to $l$?


As $b$ goes to $l$, $h$ goes to $0$, so $b/h$ blows up. Unless $db/dt$ goes to $0$, the expression will become $-\infty$.


:::{.callout-note}
## Note
Often, this problem is presented with $db/dt$ having a constant rate. In this case, the ladder problem defies physics, as $dh/dt$ eventually is faster than the speed of light as $h \rightarrow 0+$. In practice, were $db/dt$ kept at a constant, the ladder would necessarily come away from the wall.

:::

##### Example



```{julia}
#| hold: true
#| echo: false
#| eval: false
caption = "A man and woman walk towards the light."

imgfile = "figures/long-shadow-noir.png"
ImageFile(:derivatives, imgfile, caption)
```

![A man and woman walk towards the light](./figures/long-shadow-noir.png)

Shadows are a staple of film noir. In the photo, suppose a man and a woman walk towards a street light. As they approach the light the length of their shadow changes.


Suppose, we focus on the $5$ foot tall woman. Her shadow comes from a streetlight $12$ feet high. She is walking at $3$ feet per second towards the light. What is the rate of change of her shadow?


The setup for this problem involves drawing a right triangle with height $12$ and base given by the distance $x$ from the light the woman is *plus* the length $l$ of the shadow. There is a similar triangle formed by the woman's height with length $l$. Equating the ratios of the sided gives:


$$
\frac{5}{l} = \frac{12}{x + l}
$$

As we need to take derivatives, we work with the reciprocal relationship:


$$
\frac{l}{5} = \frac{x + l}{12}
$$

Differentiating in $t$ gives:


$$
\frac{l'}{5} = \frac{x' + l'}{12}
$$

Or


$$
l' \cdot (\frac{1}{5} - \frac{1}{12}) =  \frac{x'}{12}
$$

Solving for $l'$ gives an answer in terms of $x'$ the rate the woman is walking. In this description $x$ is getting shorter, so $x'$ would be $-3$ feet per second and the shadow length would be decreasing at a rate proportional to the walking speed.


##### Example


```{julia}
#| hold: true
#| echo: false
p = plot(; axis=nothing, border=:none, legend=false, aspect_ratio=:equal)
scatter!(p, [0],[50], color=:yellow, markersize=50)
plot!(p, [0, 50], [0,0], linestyle=:dash)
plot!(p, [0,50], [50,0], linestyle=:dot)
plot!(p, [25,25],[25,0], linewidth=5, color=:black)
plot!(p, [25,50], [0,0], linewidth=2, color=:black)
```

The sun is setting at the rate of $1/20$ radian/min, and appears to be dropping perpendicular to the horizon, as depicted in the figure. How fast is the shadow of a $25$ meter wall lengthening at the moment when the shadow is $25$ meters long?


Let the shadow length be labeled $x$, as it appears on the $x$ axis above. Then we have by right-angle trigonometry:


$$
\tan(\theta) = \frac{25}{x}
$$

of $x\tan(\theta) = 25$.


As $t$ evolves, we know $d\theta/dt$ but what is $dx/dt$? Using implicit differentiation yields:


$$
\frac{dx}{dt} \cdot \tan(\theta) + x \cdot (\sec^2(\theta)\cdot \frac{d\theta}{dt}) = 0
$$

Substituting known values and identifying $\theta=\pi/4$ when the shadow length, $x$, is $25$ gives:


$$
\frac{dx}{dt} \cdot \tan(\pi/4) + 25 \cdot(4/2) \cdot \frac{-1}{20} = 0
$$

This can be solved for the unknown: $dx/dt = 50/20$.


##### Example


A batter hits a ball toward third base at $75$ ft/sec and runs toward first base at a rate of $24$ ft/sec. At what rate does the distance between the ball and the batter change when $2$ seconds have passed?


We will answer this symbolically. First we create some symbols for the movement of the ball towards third base, `b(t)`, the runner toward first base, `r(t)`, and the two velocities. We use symbolic functions for the movements, as we will be differentiating them in time:


```{julia}
@syms b() r() v_b v_r
d = sqrt(b(t)^2 + r(t)^2)
```

The distance formula applies to give $d$. As the ball and runner are moving in a perpendicular direction, the formula is easy to apply.


We can differentiate `d` in terms of `t` and in process we also find the derivatives of `b` and `r`:


```{julia}
db, dr = diff(b(t),t), diff(r(t),t) # b(t), r(t) -- symbolic functions
dd = diff(d,t)                      # d -- not d(t) -- an expression
```

The slight difference in the commands is due to `b` and `r` being symbolic functions, whereas `d` is a symbolic expression. Now we begin substituting. First, from the problem `db` is just the velocity in the ball's direction, or `v_b`. Similarly for `v_r`:


```{julia}
ddt = subs(dd, db => v_b, dr => v_r)
```

Now, we can substitute in for `b(t)`, as it is `v_b*t`, etc.:


```{julia}
ddt₁ = subs(ddt, b(t) => v_b * t, r(t) => v_r * t)
```

This finds the rate of change of time for any `t` with symbolic values of the velocities. (And shows how the answer doesn't actually depend on $t$.) The problem's answer comes from a last substitution:


```{julia}
ddt₁(t => 2, v_b => 75, v_r => 24)
```

Were this done by "hand," it would be better to work with distance squared to avoid the expansion of complexity from the square root. That is, using implicit differentiation:


$$
\begin{align*}
d^2 &= b^2 + r^2\\
2d\cdot d' &= 2b\cdot b' + 2r\cdot r'\\
d' &= (b\cdot b' + r \cdot r')/d\\
d' &= (tb'\cdot b' + tr' \cdot r')/d\\
d' &= \left((b')^2 + (r')^2\right) \cdot \frac{t}{d}.
\end{align*}
$$

##### Example


```{julia}
#| hold: true
#| echo: false
#| cache: true
###{{{baseball_been_berry_good}}}
## Secant line approaches tangent line...
gr()
function baseball_been_berry_good_graph(n)

    v0 = 15
    x = (t) -> 50t
    y = (t) -> v0*t - 5 * t^2


    ns = range(.25, stop=3, length=8)

    t = ns[n]
    ts = range(0, stop=t, length=50)
    xs = map(x, ts)
    ys = map(y, ts)

    degrees = atand(y(t)/(100-x(t)))
    degrees = degrees < 0 ? 180 + degrees : degrees

    plt = plot(xs, ys, legend=false, size=fig_size, xlim=(0,150), ylim=(0,15))
    plot!(plt, [x(t), 100], [y(t), 0.0], color=:orange)
    annotate!(plt, [(55, 4,"θ = $(round(Int, degrees)) degrees"),
                    (x(t), y(t), "($(round(Int, x(t))), $(round(Int, y(t))))")])

end
caption = L"""

The flight of the ball as being tracked by a stationary outfielder.  This ball will go over the head of the player. What can the player tell from the quantity $d\theta/dt$?

"""
n = 8


anim = @animate for i=1:n
    baseball_been_berry_good_graph(i)
end


imgfile = tempname() * ".gif"
gif(anim, imgfile, fps = 1)
plotly()
ImageFile(imgfile, caption)
```

A baseball player stands $100$ meters from home base. A batter hits the ball directly at the player so that the distance from home plate is $x(t)$ and the height is $y(t)$.


The player tracks the flight of the ball in terms of the angle $\theta$ made between the ball and the player. This will satisfy:


$$
\tan(\theta) = \frac{y(t)}{100 - x(t)}.
$$

What is the rate of change of $\theta$ with respect to $t$ in terms of that of $x$ and $y$?


We have by the chain rule and quotient rule:


$$
\sec^2(\theta) \theta'(t) = \frac{y'(t) \cdot (100 - x(t)) - y(t) \cdot (-x'(t))}{(100 - x(t))^2}.
$$

If we have $x(t) = 50t$ and $y(t)=v_{0y} t - 5 t^2$ when is the rate of change of the angle happening most quickly?


The formula for $\theta'(t)$ is


$$
\theta'(t) = \cos^2(\theta) \cdot \frac{y'(t) \cdot (100 - x(t)) - y(t) \cdot (-x'(t))}{(100 - x(t))^2}.
$$

This question requires us to differentiate *again* in $t$. Since we have fairly explicit function for $x$ and $y$, we will use `SymPy` to do this.


```{julia}
@syms theta()

v0 = 5
x(t) = 50t
y(t) = v0*t - 5 * t^2
eqn = tan(theta(t)) - y(t) / (100 - x(t))
```

```{julia}
thetap = diff(theta(t),t)
dtheta = solve(diff(eqn, t), thetap)[1]
```

We could proceed directly by evaluating:


```{julia}
d2theta = diff(dtheta, t)(thetap => dtheta)
```

That is not so tractable, however.


It helps to simplify $\cos^2(\theta(t))$ using basic right-triangle trigonometry. Recall, $\theta$ comes from a right triangle with height $y(t)$ and length $(100 - x(t))$. The cosine of this angle will be $100 - x(t)$ divided by the length of the hypotenuse. So we can substitute:


```{julia}
dtheta₁ = dtheta(cos(theta(t))^2 => (100 -x(t))^2/(y(t)^2 + (100-x(t))^2))
```

Plotting reveals some interesting things. For $v_{0y} < 10$ we have graphs that look like:


```{julia}
plot(dtheta₁, 0, v0/5)
```

The ball will drop in front of the player, and the change in $d\theta/dt$ is monotonic.


But let's rerun the code with $v_{0y} > 10$:


```{julia}
#| hold: true
v0 = 15
x(t) = 50t
y(t) = v0*t - 5 * t^2
eqn = tan(theta(t)) - y(t) / (100 - x(t))
thetap = diff(theta(t),t)
dtheta = solve(diff(eqn, t), thetap)[1]
dtheta₁ = subs(dtheta, cos(theta(t))^2, (100 - x(t))^2/(y(t)^2 + (100 - x(t))^2))
plot(dtheta₁, 0, v0/5)
```

In the second case we have a different shape. The graph is not monotonic, and before the peak there is an inflection point.  Without thinking too hard, we can see that the greatest change in the angle is when it is just above the head ($t=2$ has $x(t)=100$).


That these two graphs differ so, means that the player may be able to read if the ball is going to go over his or her head by paying attention to how the ball is being tracked.


##### Example


Hipster pour-over coffee is made with a conical coffee filter. The cone is actually a [frustum](http://en.wikipedia.org/wiki/Frustum) of a cone with small diameter, say $r_0$, chopped off. We will parameterize our cone by a value $h \geq 0$ on the $y$ axis and an angle $\theta$ formed by a side and the $y$ axis. Then the coffee filter is the part of the cone between some $h_0$ (related  $r_0=h_0 \tan(\theta)$) and $h$.


The volume of a cone of height $h$ is $V(h) = \pi/3 h \cdot R^2$. From the geometry, $R = h\tan(\theta)$. The volume of the filter then is:


$$
V = V(h) - V(h_0).
$$

What is $dV/dh$ in terms of $dR/dh$?


Differentiating implicitly gives:


$$
\frac{dV}{dh} = \frac{\pi}{3} ( R(h)^2 + h \cdot 2 R \frac{dR}{dh}).
$$

We see that it depends on $R$ and the change in $R$ with respect to $h$. However, we visualize $h$ - the height - so it is better to re-express. Clearly, $dR/dh = \tan\theta$ and using $R(h) = h \tan(\theta)$ we get:


$$
\frac{dV}{dh} = \pi h^2 \tan^2(\theta).
$$

The rate of change goes down as $h$ gets smaller ($h \geq h_0$) and gets bigger for bigger $\theta$.


How do the quantities vary in time?


For an incompressible fluid, by balancing the volume leaving with how it leaves we will have $dh/dt$ is the ratio of the cross-sectional area at bottom over that at the height of the fluid $(\pi \cdot (h_0\tan(\theta))^2) / (\pi \cdot ((h\tan\theta))^2)$ times the outward velocity of the fluid.


That is $dh/dt = (h_0/h)^2 \cdot v$. Which makes sense - larger openings ($h_0$) mean more fluid lost per unit time so the height change follows, higher levels ($h$) means the change in height is slower, as the cross-sections have more volume.


By [Torricelli's](http://en.wikipedia.org/wiki/Torricelli's_law) law, the out velocity follows the law $v = \sqrt{2g(h-h_0)}$. This gives:


$$
\frac{dh}{dt} = \frac{h_0^2}{h^2} \cdot v = \frac{h_0^2}{h^2} \sqrt{2g(h-h_0)}.
$$

If $h >> h_0$, then $\sqrt{h-h_0} = \sqrt{h}\sqrt{(1 - h_0/h)} \approx \sqrt{h}(1 - (1/2)(h_0/h)) \approx \sqrt{h}$. So the rate of change of height in time is like $1/h^{3/2}$.


Now, by the chain rule, we have then the rate of change of volume with respect to time, $dV/dt$, is:


$$
\begin{align*}
\frac{dV}{dt} &=
\frac{dV}{dh} \cdot \frac{dh}{dt}\\
&= \pi h^2 \tan^2(\theta) \cdot \frac{h_0^2}{h^2} \sqrt{2g(h-h_0)}  \\
&= \pi \sqrt{2g} \cdot (r_0)^2 \cdot \sqrt{h-h_0} \\
&\approx \pi \sqrt{2g} \cdot r_0^2 \cdot \sqrt{h}.
\end{align*}
$$

This rate depends on the square of the size of the opening ($r_0^2$) and the square root of the height ($h$), but not the angle of the cone.


## Questions


###### Question


Supply and demand. Suppose demand for product $XYZ$ is $d(x)$ and supply is $s(x)$. The excess demand is $d(x) - s(x)$. Suppose this is positive. How does this influence price? Guess the "law" of economics that applies:


```{julia}
#| hold: true
#| echo: false
choices = [
"The rate of change of price will be ``0``",
"The rate of change of price will increase",
"The rate of change of price will be positive and will depend on the rate of change of excess demand."
]
answ = 3
radioq(choices, answ, keep_order=true)
```

(Theoretically, when demand exceeds supply, prices increase.)


###### Question


Which makes more sense from an economic viewpoint?


```{julia}
#| hold: true
#| echo: false
choices = [
"If the rate of change of unemployment is negative, the rate of change of wages will be negative.",
"If the rate of change of unemployment is negative, the rate of change of wages will be positive."
]
answ = 2
radioq(choices, answ, keep_order=true)
```

(Colloquially, "the rate of change of unemployment is negative" means the unemployment rate is going down, so there are fewer workers available to fill new jobs.)


###### Question


In chemistry there is a fundamental relationship between pressure ($P$), temperature ($T)$ and volume ($V$) given by $PV=cT$ where $c$ is a constant. Which of the following would be true with respect to time?


```{julia}
#| hold: true
#| echo: false
choices = [
L"The rate of change of pressure is always increasing by $c$",
"If volume is constant, the rate of change of pressure is proportional to the temperature",
"If volume is constant, the rate of change of pressure is proportional to the rate of change of temperature",
"If pressure is held constant, the rate of change of pressure is proportional to the rate of change of temperature"]
answ = 3
radioq(choices, answ, keep_order=true)
```

###### Question


A pebble is thrown into a lake causing ripples to form expanding circles. Suppose one of the circles expands at a rate of $1$ foot per second and the radius of the circle is $10$ feet, what is the rate of change of the area enclosed by the circle?


```{julia}
#| hold: true
#| echo: false
# a = pi*r^2
# da/dt = pi * 2r * drdt
r = 10; drdt = 1
val = pi * 2r * drdt
numericq(val, units=L"feet^2/second")
```

###### Question


A pizza maker tosses some dough in the air. The dough is formed in a circle with radius $10$. As it rotates, its area increases at a rate of $1$ inch$^2$ per second. What is the rate of change of the radius?


```{julia}
#| hold: true
#| echo: false
# a = pi*r^2
# da/dt = pi * 2r * drdt
r = 10; dadt = 1
val =  dadt /( pi * 2r)
numericq(val, units="inches/second")
```

###### Question


An FBI agent with a powerful spyglass is located in a boat anchored 400 meters offshore.  A gangster under surveillance is driving along the shore. Assume the shoreline is straight and that the gangster is 1 km from the point on the shore nearest to the boat.  If the spyglasses must rotate at a rate of $\pi/4$ radians per minute to track the gangster, how fast is the gangster moving? (In kilometers per minute.) [Source.](http://oregonstate.edu/instruct/mth251/cq/Stage9/Practice/ratesProblems.html)


```{julia}
#| hold: true
#| echo: false
## tan(theta) = x/y
## sec^2(theta) dtheta/dt = 1/y dx/dt (y is constant)
## dxdt = y sec^2(theta) dtheta/dt
dthetadt = pi/4
y0 = .4; x0 = 1.0
theta = atan(x0/y0)
val = y0 * sec(theta)^2 * dthetadt
numericq(val, units="kilometers/minute")
```

###### Question


A flood lamp is installed on the ground 200 feet from a vertical wall. A six foot tall man is walking towards the wall at the rate of 4 feet per second. How fast is the tip of his shadow moving down the wall when he is 50 feet from the wall? [Source.](http://oregonstate.edu/instruct/mth251/cq/Stage9/Practice/ratesProblems.html) (As the question is written the answer should be positive.)


```{julia}
#| hold: true
#| echo: false
## y/200 = 6/x
## dydt = 200 * 6 * -1/x^2 dxdt
x0 = 200 - 50
dxdt = 4
val = 200 * 6 * (1/x0^2) * dxdt
numericq(val, units="feet/second")
```

###### Question


Consider the hyperbola $y = 1/x$ and think of it as a slide. A particle slides along the hyperbola so that its x-coordinate is increasing at a rate of $f(x)$ units/sec. If its $y$-coordinate is decreasing at a constant rate of $1$ unit/sec, what is $f(x)$? [Source.](http://oregonstate.edu/instruct/mth251/cq/Stage9/Practice/ratesProblems.html)


```{julia}
#| hold: true
#| echo: false
choices = [
"``f(x) = 1/x``",
"``f(x) = x^0``",
"``f(x) = x``",
"``f(x) = x^2``"
]
answ = 4
radioq(choices, answ, keep_order=true)
```

###### Question


A balloon is in the shape of a sphere, fortunately, as this gives a known formula, $V=4/3 \pi r^3$, for the volume. If the balloon is being filled with a rate of change of volume per unit time is $2$ and the radius is $3$, what is rate of change of radius per unit time?


```{julia}
#| hold: true
#| echo: false
r, dVdt = 3, 2
drdt = dVdt / (4 * pi * r^2)
numericq(drdt, units="units per unit time")
```

###### Question


Consider the curve $f(x) = x^2 - \log(x)$. For a given $x$, the tangent line intersects the $y$ axis. Where?


```{julia}
#| hold: true
#| echo: false
choices = [
"``y = 1 - x^2 - \\log(x)``",
"``y = 1 - x^2``",
"``y = 1 - \\log(x)``",
"``y = x(2x - 1/x)``"
]
answ = 1
radioq(choices, answ)
```

If $dx/dt = -1$, what is $dy/dt$?


```{julia}
#| hold: true
#| echo: false
choices = [
"``dy/dt = 2x + 1/x``",
"``dy/dt = 1 - x^2 - \\log(x)``",
"``dy/dt = -2x - 1/x``",
"``dy/dt = 1``"
]
answ=1
radioq(choices, answ)
```
