We have learned basic things about differentiaton. Taking the derivative of a function is basically just going through all its “elements,” deriving it with a rule (for example, the power rule), and putting them all back together. Let’s do a little bit of refreshing. What’s the derivative of the following function?

f(x) = 2x^2 - x - 6

Let’s work on that for a little bit.

\begin{align*} f{\prime}(x) &= {2(2)(x^1)} - 1 \\ &= {4x - 1} \\ \end{align*}

A breeze.

A Case Study

Let the function {\text{amount}}(t) = 0.01t^2 + 0.5t + 100 which calculates the amount of water in the unit of “gallons” in a water tank at a time in the unit of “minutes.”

We need to:
1. Calculate the amount of water at minute 0, 9, 10, 11, and 20.
2. Calculate how fast the amount of water has been added at minute 10.


Question 1: Amount of water at certain minutes of flowing

First of all, let’s make this math function an R function.

amount <- makeFun(((0.01) * t ^ 2) + ((0.5) * t) + 100 ~ t)

We can plot this function from t = -5 to t = 25.

And now, we can see what each of t values correspond with. We can a draw vertical lines at t = 0, 9, 10, 11, and 20 and put dots where those lines intersects with the graph, so we can see how the amount of water changes over time.

What are those values where it intersects? They are the answers. These are the values when we put t into {\text{amount}(t)} where t = 0, 9, 10, 11, and 20.

answers_1 <- data.frame(
  "t" = c(0, 9, 10, 11, 20),
  "amount" = c(amount(0),amount(9), amount(10), amount(11), amount(20))
)


Question 2: How fast the water was flowing at a certain minute

For this one, we need to find the slope of the tangent line of a function. The function to find the slope of the tangent line of a function is, well, the derivative of that function.

We can get the derivative of an R function with the D() function.

deriv_amount <- D(amount(x) ~ x)

The question is: how fast was the amount of water changed at minute 10?
We just need to plug in 10 into the new function.

deriv_amount(10)
## [1] 0.7

0.7 gallons per minute.
And how to prove this? We can look back at the answers of the first question.

\text{amount}(0) = 100
\text{amount}(9) = 105.31
\text{amount}(10) = 106
\text{amount}(11) = 106.71
\text{amount}(20) = 114

The derivative of a function results in a value of how fast something is changing. It is a way to accurately calculate the slope of the tangent line. Our answer, 0.7 is the instantaneous rate of change at t = 10.

Another way to calculate the slope of the tangent line is to calculate the slope of the secant line. m_{tan} \simeq m_{sec} That is, we take the difference of \text{amount}(11) and \text{amount}(9), and divide that with the difference of 11 and 9. We choose these two numbers because they are before and after 10 in the data. So, that would be:

\begin{align*} m_{sec} &= \frac{\text{amount}(11) - \text{amount}(9)}{11 - 9} \\ &= \frac{106.71 - 105.31}{11 - 9} \\ &= \frac{1.4}{2} \\ &= 0.7 \\ \end{align*}

This slope can be visualized like so:

Reference:

Kaplan, Daniel. 2022. MOSAIC Calculus. GitHub Pages. https://dtkaplan.github.io/MC2/


contra