gizmobench

Average Rate of Change Calculator

The average rate of change is the slope of the secant line through two points of a function, and this page keeps it firmly apart from the derivative. Type f(x) and the two endpoints and it returns (f(b) - f(a)) / (b - a) with the substitution on screen: x^2 from 1 to 3 gives f(1) = 1, f(3) = 9 and a slope of 4, while the derivative at those ends is about 2 and about 6, so the average sits 2 above the first rate and 2 below the second. Inside the interval it finds the point where the derivative equals the average, x = 2 for that case, and draws a dashed tangent there parallel to the secant. Endpoints may be expressions, so sin(x) from 0 to pi is accepted and comes back as 0, a number that would read as a flat curve if the page stopped there: it is 0 because both endpoint values are 0, while the curve climbs at one end and falls at the other, and the sentences beside the answer say both. Swapping the bounds to 3 and 1 changes nothing, sqrt(x) from 1 to 9 is 0.25, e^x from 0 to 1 is 1.718281828, 16t^2 from t = 1 to t = 3 is 64, and abs(x) from -1 to 1 is 0 with no tangent offered, because a corner has no single derivative to report. Two plain points are a mode of their own: (1, 1) and (3, 9) give 4, and the page states that two readings say nothing about what happened between them. Trigonometry can be read in degrees instead, where sin from 0 to 90 is 0.01111111111. Figures are shown to ten significant figures and estimates to eight, everything runs in this browser, and nothing you type is sent anywhere.

Average rate of change4f(x) = x^2 · from a = 1 to b = 3 · (9 - 1) / (3 - 1)
Given

Type f(x), then the two endpoints. Endpoints may be expressions too, so pi/2 and 1+1 are both fine.

f(a)
1
f(b)
9
Slope
4
Interval
1 to 3
  1. f(1) = 1^2 = 1
  2. f(3) = 3^2 = 9
  3. (f(3) - f(1)) / (3 - 1) = (9 - 1) / (3 - 1) = 8 / 2 = 4

The secant slope is 4. The derivative, estimated by a central difference, is 2 at a (climbing) and 6 at b (climbing). The average is 2 above the rate at a and 2 below the rate at b, which is the whole difference between a secant and a tangent. Between them the derivative passes through 4: the first point found is x = 2, where the dashed tangent on the plot runs parallel to the secant.

(1, 1)(3, 9)0.763.2411.96-1.96

The solid line is the secant through (1, 1) and (3, 9): its slope, 4, is the average rate of change. The curve is the function itself, sampled across the interval and a little beyond it. The dashed line is the tangent at x = 2, the point found inside the interval where the derivative equals that average.

The quotient is exact arithmetic on the two endpoint values. The derivative figures beside it are numerical estimates from a central difference of about one part in a million, checked against a quarter step and dropped where the two disagree. sin, cos and tan read the variable in radians, so a full turn is 2pi.

Three cases, worked

One secant, the same secant with its bounds swapped, and one that comes out at 0 while the curve climbs and then falls. Every line below is computed by the code that answers the calculator above, so the examples and the tool can never disagree.

  • x² from 1 to 3secant slope
    4
  • Bounds reversed, 3 to 1the same two points
    4, unchanged
  • sin(x) from 0 to πboth endpoints are 0
    0, though it climbs then falls
Accuracy. Exact arithmetic on the two endpoint values, with the substitution written out step by step. This is the slope of the secant line between two points, which is an average across the interval and not the derivative at either end: the sin case above returns 0 for a function that is climbing at one end and falling at the other, and the page says so on screen rather than letting the number stand alone.

Common questions

How do you find the average rate of change of a function?
Evaluate the function at both endpoints, subtract, and divide by the run: (f(b) - f(a)) / (b - a). For f(x) = x^2 from 1 to 3 that is f(1) = 1, f(3) = 9, and (9 - 1) / (3 - 1) = 8 / 2 = 4. The page prints those three lines with your own figures in them, so a number typed into the wrong field is easy to spot.
Is the average rate of change the same as the slope?
It is the slope of one particular line: the secant through (a, f(a)) and (b, f(b)). That is why the two-point mode exists here. Give it (1, 1) and (3, 9) and it returns 4, the same answer the function mode gives for x^2 on that interval, because the quotient is the same rise over run either way.
What is the difference between average and instantaneous rate of change?
The average is one number for the whole interval; the instantaneous rate is the derivative at a single point. For x^2 from 1 to 3 the average is 4, while the derivative is about 2 at x = 1 and about 6 at x = 3. Those two figures are printed beside the answer, along with the point inside the interval where the derivative equals the average, x = 2 here, which is the point the dashed tangent touches. The derivative figures are numerical estimates from a central difference and are labelled as estimates; the quotient itself is exact arithmetic.
Can the average rate of change be zero when the function is not flat?
Yes, and that is the case the page is built around. sin(x) from 0 to pi returns 0 because both endpoint values are 0, while the curve climbs to 1 and comes back down: the estimated derivative is 1 at one end and -1 at the other. A bare 0 would suggest nothing happened, so the page writes that sentence under the number rather than leaving it to be misread.
Does it matter which endpoint I call a and which I call b?
No. Reversing them negates the rise and the run together, so both cancel: x^2 from 3 to 1 is still 4. The tool shows the substitution in the order you typed it, so you can see (1 - 9) / (1 - 3) = -8 / -2 = 4 and check it by hand.
Can I use pi, a square root or an expression as an endpoint?
Yes. An endpoint is read by the same parser as the function, so pi, pi/2, 1+1 and 2e3 all work, and an endpoint written as a constant is kept as that constant on screen. That matters more than it looks: sin(pi) is 0, while the sine of pi cut to ten significant figures is -4.102069e-10, so the page substitutes pi rather than a rounded version of it.
Why does it refuse when a and b are the same?
Because b - a would be zero and the quotient has no answer. An average rate of change needs an interval rather than a point, and returning an infinity would be a wrong result that looks like a right one. Two points with the same x are refused the same way: the line through them is vertical and has no slope to divide out.
What can I type in the function, and does it run as code?
It never runs as code. A parser written for this page reads the text, so only the names in its own table exist: sin, cos, tan, sec, csc, cot, asin, acos, atan, sinh, cosh, tanh, sqrt, cbrt, abs, exp, ln, log, log2, floor, ceil, round, sign, mod, min, max, plus the constants pi, tau and e. A name that is not on the list comes back as an error with the list attached. Implicit multiplication is understood, so 2x and 3sin(x) are fine, and the variable does not have to be x: 16t^2 from t = 1 to t = 3 returns 64.
Does it work in degrees as well as radians?
Yes, and the setting is named beside the result so an answer can never be read under the wrong convention. In radians sin(x) from 0 to 1 is 0.8414709848; in degrees sin(x) from 0 to 90 is 0.01111111111, which is 1 divided by 90. The angle setting only affects the trigonometric functions.
What if the function has a pole or a gap inside the interval?
The quotient still runs, because it only needs the two endpoint values, and the page says what it found. 1/x from -2 to 2 returns 0.25 with a note that the sampled values flip from -63.5 to 63.5 either side of x = 0, which is how a pole shows up in samples, and that an average across a break does not describe one unbroken curve. An endpoint that is itself outside the domain is refused instead: sqrt(x) starting at -4 says so rather than returning a value that is not a number.
Why does it sometimes refuse to estimate the derivative?
Because there is nothing honest to print. At a corner the slope from the left and the slope from the right disagree, so abs(x) from -1 to 1 returns an average of 0 and no tangent point, while the derivative at the two ends is still reported as -1 and 1. Where a tangent is vertical the estimate will not settle and is dropped with the reason given, which is what happens at x = 0 for sqrt(x). The average rate of change itself is unaffected either way, because it only ever needed the two endpoint values.
How precise are the figures, and is anything I type stored or sent?
The arithmetic is ordinary double precision. Values are shown to ten significant figures, estimated derivatives to eight, and the distance between an exact figure and an estimated one to six, because subtracting two nearly equal numbers costs digits. A value smaller than 1e-12 of the largest value on the interval is reported as 0 with the raw figure named in a note, which is how sin(pi) reads as 0 rather than as 1.224647e-16, and a difference that is only cancellation noise is refused instead of divided. Everything happens in this browser: the last set you typed is remembered locally so the page opens where you left it, and if storage is blocked the calculator still works, it simply forgets.

Exact arithmetic on the two endpoint values, with the substitution written out step by step. This is the slope of the secant line between two points, which is an average across the interval and not the derivative at either end: the sin case above returns 0 for a function that is climbing at one end and falling at the other, and the page says so on screen rather than letting the number stand alone.