Skip to contentSkip to lesson map

The Derivative as a Function I

Status
Updates coming
Reading
MMAC Ch 4.2, pp 365-368
Lesson map

Objectives

  1. Describe that in general, the derivative of a function is also a function.
  2. Given a function, use R to approximate and plot its derivative.
  3. Given the plot of a function, approximate its derivative graphically by hand.

1. Derivative Function

Objective. Describe that in general, the derivative of a function is also a function.

Figure

The top graph shows f(x)=x3−5xf(x) = x^3 - 5x with its tangent line at five inputs, each slope estimated as in the Lesson 25 Notes, section 2. The bottom graph shows the slope of each tangent line as a height at the same input. The tangent line at x=2x = 2 has slope 7, plotted as the point (2,7)(2, 7). The tangent line at x=0x = 0 has slope −5-5, plotted as the point (0,−5)(0, -5). Every input of f(x)=x3−5xf(x) = x^3 - 5x gives one slope, and plotting the slope at every input gives the green curve, the graph of the derivative function.

Definition 1 (Derivative function).

Let f(x)f(x) be a function. The derivative function f′(x)f'(x) outputs the instantaneous rate of change of f(x)f(x) for each input xx where that rate exists.

The number f′(2)f'(2) is not a derivative function. It is one output of f′(x)f'(x), the instantaneous rate of change at the single input x=2x = 2, and the definition requires an output for each input xx where that rate exists.

ExpressionKind of objectMeaning
f′(2)f'(2)a numberthe slope of the graph of f(x)f(x) at x=2x = 2
f′(x)f'(x)a functionassigns to each input xx the slope of the graph of f(x)f(x) at xx, where the slope exists
ddxf(x)\frac{d}{dx}f(x)a functionthe same function as f′(x)f'(x), read “dd dxdx of ff of xx”

Example 1

For the function

f(x)=x3−5x, f(x) = x^3 - 5x,

the average rate of change on [x,x+0.001][x, x + 0.001] approximates f′(x)f'(x) and takes these values at five inputs:

xx−2-2−1-1001122
rate on [x,x+0.001][x, x + 0.001]6.9946.994−2.003-2.003−5.000-5.000−1.997-1.9977.0067.006

Is the derivative of f(x)f(x) a function?

ShowHide solution

By the definition of the derivative function, f′(x)f'(x) outputs the instantaneous rate of change of f(x)f(x) for each input xx where that rate exists. The derivative of f(x)f(x) is a function, because each input xx has exactly one instantaneous rate of change. The table gives estimates of f′(x)f'(x) at five inputs, and the rate changes with the input: f′(0)f'(0) is near −5-5 while f′(2)f'(2) is near 77. Each column of the table is a point (x,rate)(x, \text{rate}) near the green curve in the figure above, such as (2,7.006)(2, 7.006) near (2,7)(2, 7).

Example 2

The height HH in meters of a ball thrown straight up, tt seconds after release, is

H(t)=19.6t−4.9t2. H(t) = 19.6t - 4.9t^{2}.

The average rate of change on [t,t+0.001][t, t + 0.001] approximates H′(t)H'(t) and takes these values:

tt0011223344
rate on [t,t+0.001][t, t + 0.001]19.59519.5959.7959.795−0.005-0.005−9.805-9.805−19.605-19.605

Describe H′(t)H'(t) as a function: give its input and its output with units, and say what the table shows about the ball.

ShowHide solution

The derivative function H′(t)H'(t) takes as input a time tt in seconds and outputs the instantaneous rate of change of the height at that time, in meters per second. The derivative H′(t)H'(t) is a function of tt, because each time has exactly one instantaneous rate of change. The estimates decrease from about 19.595 meters per second at release to about −19.605-19.605 meters per second at t=4t = 4. The height increases at a decreasing rate until t=2t = 2. At t=2t = 2 the estimate is −0.005-0.005 meters per second, a change in height of about 5 millimeters per second, against about 9.8 meters per second at t=1t = 1 and at t=3t = 3. Therefore H′(2)≈0H'(2) \approx 0, and the ball is at or very near the top of its flight at t=2t = 2. After t=2t = 2 the rate is negative and the height decreases.

Lesson map

2. Approximating the Derivative in R

Objective. Given a function, use R to approximate and plot its derivative.

Approximating a derivative in R.

  1. Define the function: f = makeFun(x^3 - 5*x ~ x).
  2. Define the approximate derivative, the average rate of change from xx to x+0.001x + 0.001:
    f_deriv = makeFun((f(x + 0.001) - f(x))/0.001 ~ x).
  3. Evaluate f_deriv(a) to approximate f′(a)f'(a).
  4. Plot f(x)f(x) with plotFun, then add the approximate derivative on top with plotFun(f_deriv(x) ~ x, add = TRUE).

Approximate derivative from f_change. After f_change from section 1 of the Lesson 25 Notes is defined, the line

f_deriv = makeFun(f_change(x, x + 0.001) ~ x)

also defines f_deriv, because f_change(x, x + 0.001) is the average rate of change on [x,x+0.001][x, x + 0.001].

Step size. The step is the width hh of the interval [x,x+h][x, x + h]. For the functions in this course, shrinking a step of 0.001 down to about 0.000001 brings the average rate of change on [x,x+h][x, x + h] closer to f′(x)f'(x), or leaves it equal to f′(x)f'(x) when f(x)f(x) is linear. Far smaller steps can make the estimate worse, because R rounds each output before subtracting.

For f(x)=x3−5xf(x) = x^3 - 5x and a step hh, with f(1)=1−5=−4f(1) = 1 - 5 = -4, the average rate of change on [1,1+h][1, 1 + h] simplifies to

f(1+h)−f(1)h=(1+h)3−5(1+h)−(−4)h=1+3h+3h2+h3−5−5h+4h=−2h+3h2+h3h=−2+3h+h2, \begin{aligned} \frac{f(1 + h) - f(1)}{h} &= \frac{(1 + h)^3 - 5(1 + h) - (-4)}{h} = \frac{1 + 3h + 3h^2 + h^3 - 5 - 5h + 4}{h}\\ &= \frac{-2h + 3h^2 + h^3}{h} = -2 + 3h + h^2, \end{aligned}

which approaches f′(1)=−2f'(1) = -2 as hh approaches 00. The table gives the estimate at three steps:

step0.80.80.30.30.0010.001
estimate of f′(1)f'(1)1.041.04−1.01-1.01−1.996999-1.996999

Answers to three decimals. The estimate with step 0.001 can be wrong in the third decimal or earlier: at x=1x = 1 it rounds to −1.997-1.997, while f′(1)=−2.000f'(1) = -2.000. For an answer to three decimals, shrink the step by a factor of 10 at a time with f_change until the stopping test in the Lesson 25 Notes, section 2, is met. When a problem gives the interval or the step, use that interval or step.

Order of definitions. The function f_deriv uses f. Evaluating f_deriv before f is defined gives an error:

> f_deriv(1)
Error in f(x + 0.001) : could not find function "f"

When f_deriv is defined from f_change, evaluating f_deriv before f_change is defined gives this error:

> f_deriv(1)
Error in f_change(x, x + 0.001) : could not find function "f_change"

Example 3

Approximate f′(1)f'(1) in R for the function

f(x)=x3−5x f(x) = x^3 - 5x

and plot the approximate derivative on top of f(x)f(x) for −3≤x≤3-3 \le x \le 3.

ShowHide solution

Define ff, the average rate of change f_change, and the approximate derivative f_deriv with step 0.001. Evaluate f_deriv(1), then shrink the step on each side of x=1x = 1 with f_change until the stopping test is met. Used R.

f = makeFun(x^3 - 5*x ~ x)
f_change = makeFun((f(b) - f(a))/(b - a) ~ a & b)
f_deriv = makeFun((f(x + 0.001) - f(x))/0.001 ~ x)
f_deriv(1)
[1] -1.996999
f_change(1, 1.001)
[1] -1.996999
f_change(1, 1.0001)
[1] -1.9997
f_change(0.9999, 1)
[1] -2.0003
f_change(1, 1.00001)
[1] -1.99997
f_change(0.99999, 1)
[1] -2.00003

The call f_change(1, 1.001) returns the same −1.996999-1.996999 as f_deriv(1), because both compute the average rate of change on [1,1.001][1, 1.001]. At steps 0.0001 and 0.00001 the rates from both sides all round to −2.000-2.000. The stopping test is met, and to three decimals

f′(1)≈−2.000. f'(1) \approx -2.000.

Plot f(x)f(x) for −3≤x≤3-3 \le x \le 3, then add the approximate derivative f_deriv on top. Used R.

plotFun(f(x) ~ x, xlim = range(-3, 3), ylim = range(-13, 23))
plotFun(f_deriv(x) ~ x, col = "darkgreen", add = TRUE)

The first line plots f(x)f(x), and the second adds the plot of f_deriv in green. The green curve passes through (1,−1.997)(1, -1.997), whose height is the value f_deriv(1) returned, and its height at each input is approximately the slope of the black curve there.

Figure

Example 4

The function Weight models the average weight in grams of a male fetus, with input Week, the gestational age in weeks:

Weight=781.9e0.1216(Week−25). \text{Weight} = 781.9e^{0.1216(\text{Week} - 25)}.

Use R to approximate Weight′(30)\text{Weight}'(30) with step 0.001, and plot the approximate derivative for weeks 20 to 35.

ShowHide solution

Define Weight and the approximate derivative Weight_deriv with step 0.001, the average rate of change from Week to Week+0.001\text{Week} + 0.001. Evaluate it at week 30 and at the ends of the plot, then plot it. Used R.

Weight = makeFun(781.9*exp(0.1216*(Week - 25)) ~ Week)
Weight_deriv = makeFun((Weight(Week + 0.001) - Weight(Week))/0.001 ~ Week)
Weight_deriv(30)
[1] 174.6474
Weight_deriv(c(20, 35))
[1]  51.76785 320.78443
plotFun(Weight_deriv(Week) ~ Week, xlim = range(20, 35))

The line Weight_deriv(30) computes (Weight(30.001)−Weight(30))/0.001\bigl(\text{Weight}(30.001) - \text{Weight}(30)\bigr)/0.001, which approximates Weight′(30)\text{Weight}'(30). At step 0.001 the error of this estimate shows in the second decimal. Report the estimate to one decimal:

Weight′(30)≈174.6 grams per week. \text{Weight}'(30) \approx 174.6 \text{ grams per week}.

In week 30, the average male fetus’s weight is increasing at about 174.6 grams per week. The plot rises from about 51.8 grams per week at week 20 to about 320.8 grams per week at week 35. Because the approximate derivative increases, the weight increases at a greater rate each week.

Figure

Example 5

For the function

f(x)=x3−5x, f(x) = x^3 - 5x,

use R to determine whether f(1.5)f(1.5) is positive or negative, and whether f(x)f(x) is increasing or decreasing at x=1.5x = 1.5.

ShowHide solution

Define ff and evaluate it at x=1.5x = 1.5. Used R.

f = makeFun(x^3 - 5*x ~ x)
f(1.5)
[1] -4.125

The value f(1.5)=−4.125f(1.5) = -4.125 is negative.

The sign of f′(1.5)f'(1.5) determines whether f(x)f(x) is increasing or decreasing. Approximate f′(1.5)f'(1.5) with the approximate derivative, as in Example 3, and check it with the average rates of change on each side of x=1.5x = 1.5 at step 0.0001. Used R.

f_deriv = makeFun((f(x + 0.001) - f(x))/0.001 ~ x)
f_change = makeFun((f(b) - f(a))/(b - a) ~ a & b)
f_deriv(1.5)
[1] 1.754501
f_change(1.5, 1.5001)
[1] 1.75045
f_change(1.4999, 1.5)
[1] 1.74955

The rates from both sides of x=1.5x = 1.5 are positive and close to the estimate 1.754501, far from 0. Therefore f′(1.5)f'(1.5) is positive, and f(x)f(x) is increasing at x=1.5x = 1.5. Because the question asks only for the sign, the work stops without a three-decimal estimate or stopping test.

Lesson map

3. Sketching the Derivative from a Graph

Objective. Given the plot of a function, approximate its derivative graphically by hand.

The value f′(a)f'(a) is the slope of the tangent line to the graph of f(x)f(x) at x=ax = a. The first four graphs show f(x)=x3−5xf(x) = x^3 - 5x with one or two tangent lines. The last graph shows g(x)=∣x∣g(x) = |x|, whose graph has a corner.

Positive derivative

Figure

The graph rises left to right at x=−2x = -2, and f′(−2)≈7f'(-2) \approx 7 is positive.

Negative derivative

Figure

The graph falls left to right at x=0x = 0, and f′(0)≈−5f'(0) \approx -5 is negative.

Zero derivative

Figure

The graph has a valley near x=1.29x = 1.29, where the green approximate derivative of Example 3 crosses 0. The tangent line is horizontal there, and f′(1.29)≈0f'(1.29) \approx 0.

Size of the derivative

Figure

Because the blue tangent line at x=−2.5x = -2.5 is steeper than the red one at x=−2x = -2, f′(−2.5)f'(-2.5) is farther from zero than f′(−2)≈7f'(-2) \approx 7.

Undefined derivative

Figure

The graph of g(x)=∣x∣g(x) = |x| has a corner at x=0x = 0 with no single tangent line, and g′(0)g'(0) is undefined.

Sketching a derivative.

  1. Mark each input where the graph of f(x)f(x) has a horizontal tangent line. The derivative f′(x)f'(x) is zero there.
  2. Draw f′(x)f'(x) above the xx-axis where f(x)f(x) rises and below where f(x)f(x) falls.
  3. Estimate the slope of the graph of f(x)f(x) at a few inputs and plot each slope as a point on the graph of f′(x)f'(x). To estimate a slope, draw the tangent line at the input and divide its rise by its run between two points on it taken from the grid.
  4. Join the points with a smooth curve. Leave a break at each corner.

Example 6

The graph of the function

f(x)=x3−5x f(x) = x^3 - 5x

has a peak near x=−1.29x = -1.29 and a valley near x=1.29x = 1.29. Sketch f′(x)f'(x).

Figure
ShowHide solution

The derivative f′(x)f'(x) is zero at x≈−1.29x \approx -1.29 and x≈1.29x \approx 1.29, because the tangent line is horizontal at the peak and at the valley. The sign of f′(x)f'(x) is positive to the left of the peak and to the right of the valley, because f(x)f(x) rises there. Between the peak and the valley the sign is negative, because f(x)f(x) falls there.

Estimate three slopes, two from the graph and one by symmetry. Draw the tangent line at x=0x = 0 on the grid. It passes through (0,0)(0, 0) and about (1,−5)(1, -5), and its slope is about

−5−01−0=−5. \frac{-5 - 0}{1 - 0} = -5.

Draw the tangent line at x=2x = 2. It passes through (2,−2)(2, -2) and about (3,5)(3, 5), and its slope is about

5−(−2)3−2=7. \frac{5 - (-2)}{3 - 2} = 7.

The slope at x=−2x = -2 is also about 7, because the graph is symmetric about the origin: the part of the graph near x=−2x = -2 is the part near x=2x = 2 rotated half a turn about the origin. The slope falls from about 7 at x=−2x = -2 to about −5-5 at x=0x = 0 and climbs back to about 7 at x=2x = 2, and by the same symmetry the slopes at x=−ax = -a and x=ax = a match. Therefore, the sketch of f′(x)f'(x) is a U-shaped curve, symmetric about the vertical axis, with its lowest point near (0,−5)(0, -5), and the curve crosses the xx-axis at the peak and the valley inputs.

Figure

Example 7

For the graph of h(x)h(x), determine where h′(x)h'(x) is zero, positive, and negative among the inputs

x=−2.5, −2, −1, 0, 1, 2, 2.5. x = -2.5,\ -2,\ -1,\ 0,\ 1,\ 2,\ 2.5.
Figure
ShowHide solution
  • The derivative h′(x)h'(x) is zero at x=−2x = -2, 00, and 22, because the graph has a valley, a peak, and a valley there.
  • The derivative h′(x)h'(x) is positive at x=−1x = -1 and x=2.5x = 2.5, because h(x)h(x) rises there.
  • The derivative h′(x)h'(x) is negative at x=−2.5x = -2.5 and x=1x = 1, because h(x)h(x) falls there.

Example 8

Sketch the derivative of

g(x)=∣x∣. g(x) = |x|.
ShowHide solution

For x<0x < 0, g′(x)g'(x) equals −1-1, because the graph of g(x)g(x) there is a line of slope −1-1. For x>0x > 0, g′(x)g'(x) equals 11, because the graph there is a line of slope 11.

At the corner x=0x = 0, the slope is −1-1 on the left and 11 on the right. Because these two slopes differ, the graph has no single tangent line at x=0x = 0, and g′(0)g'(0) is undefined.

The sketch is a horizontal line at −1-1 for x<0x < 0 and a horizontal line at 11 for x>0x > 0, with a break at x=0x = 0. The open dots at (0,−1)(0, -1) and (0,1)(0, 1) mark that g′(0)g'(0) is undefined.

Figure

Lesson map

Found a mistake, a broken tool or something unclear? Report a problem