Tutorials › AP Calculus › Average Values of Piecewise Functions

Accumulation and Average Value · Tutorial 617 of 999

Average Values of Piecewise Functions

Compute piecewise-function averages accurately by accounting for each subinterval’s integral and width.

Intermediate 9 min read

What You'll Learn

  • Set up the average-value formula for a piecewise-defined function.
  • Split an integral at every breakpoint where the formula changes.
  • Combine signed integrals before dividing by the total interval length.
  • Use subinterval widths to understand the weighted average of piecewise averages.
  • Identify why taking an unweighted average of the pieces can give the wrong result.

Why Piecewise Functions Need Interval-by-Interval Work

A piecewise-defined function uses different formulas on different parts of its domain. Its average value over an interval still depends on the function’s accumulated integral across the entire interval, but that integral must account for every formula on the subinterval where it applies.

The key procedure is straightforward: split at each breakpoint, integrate each formula over its own subinterval, add the resulting signed integrals, and divide by the length of the full interval. Careful bookkeeping matters: the subinterval widths need not be equal, and the integrals need not have the same sign.

Definition: If \(f\) is integrable on \([a,b]\), where \(a<b\), its average value on that interval is $$ f_{\mathrm{avg}}=\frac{1}{b-a}\int_a^b f(x)\,dx. $$ The denominator is the length of the entire interval.

When a Piecewise Function Can Be Integrated

Suppose the interval \([a,b]\) is divided by finitely many breakpoints. A standard sufficient condition for the function to be integrable is that it is bounded and piecewise continuous: on each open subinterval it is continuous, and at each breakpoint its finite one-sided limits exist. The function may have jump discontinuities at those points.

In particular, if each formula extends continuously to the closed subinterval on which it is used, the resulting piecewise function is integrable, even if its values or one-sided limits do not match at a breakpoint. Merely being continuous on an interval that excludes an endpoint is not enough: the formula could become unbounded as it approaches that endpoint.

For a finite piecewise-continuous function, changing its value at one or finitely many individual points does not change its definite integral. Thus, when splitting an integral at a breakpoint, it is the formula on each open subinterval that determines the integral; how the function is assigned at the breakpoint itself does not affect the calculation.

Adding the Integrals Across Pieces

Let \(a=x_0<x_1<\cdots<x_n=b\) be the breakpoints. On each subinterval \([x_{i-1},x_i]\), let the applicable formula be \(f_i(x)\), with the integrability condition stated above. Additivity of the definite integral gives the central calculation rule.

Theorem: The average value of a piecewise-defined function on \([a,b]\) is $$ f_{\mathrm{avg}} = \frac{1}{b-a} \sum_{i=1}^{n}\int_{x_{i-1}}^{x_i} f_i(x)\,dx. $$ Each formula is integrated only over the subinterval where it applies. The integrals are signed, so contributions below the \(x\)-axis count as negative.

This rule follows directly from additivity. The intervals \([x_{i-1},x_i]\) cover \([a,b]\) and meet only at their endpoints, so the integral over the whole interval is the sum of the integrals over the pieces. Dividing that total by the full length \(b-a\) gives the average value.

1
Mark the breakpoints.
List the endpoints of every subinterval where the formula changes.
2
Integrate each formula on its own subinterval.
Use that subinterval’s endpoints as the bounds for its formula.
3
Add the signed integrals.
This sum is the integral over the entire interval.
4
Divide by the total length.
Use \(b-a\), not the length of one piece or the number of pieces.

Worked Examples

Worked Example: Two Formulas on Equal-Length Pieces

Find the average value of $$ f(x)= \begin{cases} x+1,&0\le x<2,\\ 5-x,&2\le x\le4 \end{cases} $$ on \([0,4]\).

Step 1: Identify the pieces and their bounds. The formula changes at \(x=2\), so integrate \(x+1\) from \(0\) to \(2\), and \(5-x\) from \(2\) to \(4\).

Step 2: Compute the first integral.

$$ \int_0^2(x+1)\,dx = \left[\frac{x^2}{2}+x\right]_0^2 = \left(\frac{2^2}{2}+2\right)-\left(\frac{0^2}{2}+0\right) = 4. $$

The antiderivative checks because \(\frac{d}{dx}\left(\frac{x^2}{2}+x\right)=x+1\).

Step 3: Compute the second integral.

$$ \int_2^4(5-x)\,dx = \left[5x-\frac{x^2}{2}\right]_2^4 = \left(20-\frac{16}{2}\right)-\left(10-\frac{4}{2}\right) = 12-8 = 4. $$

The antiderivative checks because \(\frac{d}{dx}\left(5x-\frac{x^2}{2}\right)=5-x\).

Step 4: Add, then divide by the full length. The total integral is \(4+4=8\), and the length of \([0,4]\) is \(4-0=4\). Therefore, $$ f_{\mathrm{avg}}=\frac{8}{4}=2. $$

Check: The two computed integrals sum to the whole-interval integral, \(8\); dividing by the whole-interval length, \(4\), gives the stated average value \(2\).

Worked Example: A Jump at the Breakpoint

Find the average value of $$ g(x)= \begin{cases} x^2,&0\le x<1,\\ 2x,&1\le x\le3 \end{cases} $$ on \([0,3]\).

The left-hand formula approaches \(1\) as \(x\) approaches \(1\), while the right-hand formula gives \(2\) at \(x=1\). This jump does not prevent integration: both formulas extend continuously to their respective closed subintervals.

Step 1: Integrate on \([0,1]\).

$$ \int_0^1x^2\,dx = \left[\frac{x^3}{3}\right]_0^1 = \frac{1^3}{3}-\frac{0^3}{3} = \frac13. $$

The derivative of \(\frac{x^3}{3}\) is \(x^2\), as required.

Step 2: Integrate on \([1,3]\).

$$ \int_1^3 2x\,dx = \left[x^2\right]_1^3 = 3^2-1^2 = 9-1 = 8. $$

The derivative of \(x^2\) is \(2x\), so this antiderivative is correct.

Step 3: Combine and divide by the full interval length. The total integral is \(\frac13+8=\frac{25}{3}\), and the full interval has length \(3-0=3\). Hence, $$ g_{\mathrm{avg}} = \frac{\frac{25}{3}}{3} = \frac{25}{9}. $$

Check: Multiplying the proposed average by the interval length recovers the total integral: $$ \frac{25}{9}\cdot3=\frac{25}{3}=\frac13+8. $$

Worked Example: Three Pieces with Different Widths

Find the average value on \([0,6]\) of $$ h(x)= \begin{cases} 4,&0\le x<2,\\ 1+x,&2\le x<5,\\ 10-x,&5\le x\le6. \end{cases} $$

Step 1: Integrate the constant formula on \([0,2]\).

$$ \int_0^2 4\,dx = [4x]_0^2 = 4(2)-4(0) = 8. $$

The derivative of \(4x\) is \(4\).

Step 2: Integrate \(1+x\) on \([2,5]\).

$$ \int_2^5(1+x)\,dx = \left[x+\frac{x^2}{2}\right]_2^5 = \left(5+\frac{25}{2}\right)-\left(2+\frac{4}{2}\right) = \frac{35}{2}-4 = \frac{27}{2}. $$

The derivative of \(x+\frac{x^2}{2}\) is \(1+x\).

Step 3: Integrate \(10-x\) on \([5,6]\).

$$ \int_5^6(10-x)\,dx = \left[10x-\frac{x^2}{2}\right]_5^6 = (60-18)-\left(50-\frac{25}{2}\right) = 42-\frac{75}{2} = \frac92. $$

The derivative of \(10x-\frac{x^2}{2}\) is \(10-x\).

Step 4: Add all contributions and divide by \(6\). The total integral is $$ 8+\frac{27}{2}+\frac92 = 8+\frac{36}{2} = 26. $$ The full interval length is \(6-0=6\), so $$ h_{\mathrm{avg}}=\frac{26}{6}=\frac{13}{3}. $$

Check: The interval lengths are \(2\), \(3\), and \(1\), which add to \(6\). The total integral is \(26\), so the stated average satisfies \(\frac{13}{3}\cdot6=26\).

Why Piece Averages Must Be Weighted

The integral over each piece can also be written as that piece’s average value multiplied by its width. If the \(i\)-th subinterval has width \(x_i-x_{i-1}\) and average value \(A_i\), then its integral is \(A_i(x_i-x_{i-1})\). Consequently, the whole-interval average is a weighted average of the piece averages, with each width as its weight:

$$ f_{\mathrm{avg}} = \frac{\displaystyle\sum_{i=1}^{n} A_i(x_i-x_{i-1})}{b-a}. $$

This follows because \(A_i=\frac{1}{x_i-x_{i-1}}\int_{x_{i-1}}^{x_i}f_i(x)\,dx\), so \(A_i(x_i-x_{i-1})\) is exactly the integral on that piece. Adding those integrals and dividing by \(b-a\) gives the displayed formula. Equal weighting is justified only when the pieces have equal widths.

A Common Mistake: Averaging the Pieces Equally

In the second worked example, the subinterval \([0,1]\) has width \(1\), and its average value is \(\frac13\). The subinterval \([1,3]\) has width \(2\), and its average value is \(\frac{8}{2}=4\). A tempting but incorrect calculation is to take the ordinary mean of these two piece averages:

$$ \frac{\frac13+4}{2}=\frac{13}{6}. $$

This gives the two pieces equal weight, even though one is twice as long as the other. The correction is to weight each piece average by its width, then divide by the total width:

$$ \frac{1\left(\frac13\right)+2(4)}{1+2} = \frac{\frac13+8}{3} = \frac{\frac{25}{3}}{3} = \frac{25}{9}. $$

This agrees with the result obtained by adding the two integrals. The safest procedure is to calculate the piece integrals first; their sum automatically gives each piece the correct contribution.

Check Your Understanding

For each question, split the integral at the stated breakpoint or breakpoints before finding the average.

  1. For \(f(x)=2\) on \(0\le x<1\) and \(f(x)=x\) on \(1\le x\le3\), find the average value on \([0,3]\).
  2. Why does a finite jump at a breakpoint not prevent a piecewise function from being integrable when its formulas extend continuously to their closed subintervals?
  3. A function has piece averages \(3\) and \(7\) on subintervals of widths \(1\) and \(3\), respectively. What is its average over the combined interval?
  4. What condition on a formula near an excluded endpoint is missing from the claim that “continuity on each piece guarantees integrability”?
  5. Explain why the denominator in the piecewise average formula is the length of the entire interval, not the number of pieces.

Test yourself: AP Calculus practice exams

Ready to check what you know? Work an AP-style practice exam, then open the full solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers all of AP Calculus AB & BC: full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon