Tutorials › Calculus I › Averages of Piecewise-Defined Functions

Average Value and Accumulated Quantities · Tutorial 1289 of 1495

Averages of Piecewise-Defined Functions

Compute a piecewise function’s average by splitting its integral at every formula change and dividing the combined total by the full interval length.

Intermediate 9 min read

What You'll Learn

  • State when the average-value formula applies to a piecewise-defined function.
  • Identify every formula-change point inside the interval of averaging.
  • Integrate each formula over its corresponding subinterval.
  • Combine positive and negative integral contributions correctly.
  • Check an average by multiplying it by the interval length.

Why Piecewise Averages Need Care

A piecewise-defined function can follow one rule on part of an interval and a different rule on another part. Its average over the whole interval depends on all of those pieces, not on any one formula alone.

The essential procedure is simple: locate every point where the formula changes, integrate each rule over the subinterval where it applies, add those contributions, and divide by the length of the original interval. The integral contributions are signed, so a negative contribution reduces the total.

This procedure uses the average-value formula for a function on an interval. The earlier material on average values establishes that the integral represents the function’s signed total across that interval; here, the key task is to handle the changes in formula without omitting or miscounting any part.

Definition and Conditions

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. $$
For a piecewise-defined function, the integral is evaluated by using each formula on the subinterval where that formula applies.

A sufficient condition for the integral to exist is that \(f\) is piecewise continuous on \([a,b]\): it is continuous on finitely many subintervals and has only finitely many finite one-sided limits or finite discontinuities. The formulas may change abruptly at breakpoints; continuity at those points is not required.

To apply the definition, list the endpoints and all formula-change points in increasing order. If these are \(a=c_0<c_1<\cdots<c_n=b\), then the integral over the full interval is the sum of the integrals over the subintervals. Each subinterval must use the formula assigned to it.

$$ \int_a^b f(x)\,dx = \sum_{i=1}^{n}\int_{c_{i-1}}^{c_i} f(x)\,dx, \qquad f_{\mathrm{avg}} = \frac{1}{b-a}\sum_{i=1}^{n}\int_{c_{i-1}}^{c_i} f(x)\,dx. $$

The denominator is always the length of the full interval, \(b-a\), even when the function changes formula several times. The numerators being added are signed integral values, not necessarily positive areas.

A Reliable Calculation Process

1
Mark the interval and breakpoints.
Write the endpoints of the averaging interval and every formula-change point that lies between them, in increasing order.
2
Match formulas to subintervals.
For each pair of consecutive points, identify which formula for \(f\) applies there.
3
Evaluate the piece integrals.
Use the corresponding formula and the endpoints of that subinterval. Keep negative results negative.
4
Combine and divide.
Add all the integral contributions, then divide by the length of the original interval.
5
Check the scale.
Multiply the proposed average by the full interval length; the result must equal the combined integral.

Worked Calculations

Worked Example: Two Formula Changes

Find the average value of the function on \([0,4]\):

$$ f(x)= \begin{cases} 2, & 0\le x<1,\\ x+1, & 1\le x<3,\\ 5-x, & 3\le x\le 4. \end{cases} $$

The formula changes at \(x=1\) and \(x=3\), so split the integral into the three corresponding parts:

$$ \int_0^4 f(x)\,dx = \int_0^1 2\,dx + \int_1^3 (x+1)\,dx + \int_3^4 (5-x)\,dx. $$

Evaluate the first contribution:

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

Evaluate the second:

$$ \int_1^3 (x+1)\,dx = \left[\frac{x^2}{2}+x\right]_1^3 = \left(\frac{9}{2}+3\right)-\left(\frac{1}{2}+1\right) = \frac{15}{2}-\frac{3}{2} = 6. $$

Evaluate the third:

$$ \int_3^4 (5-x)\,dx = \left[5x-\frac{x^2}{2}\right]_3^4 = \left(20-8\right)-\left(15-\frac{9}{2}\right) = 12-\frac{21}{2} = \frac{3}{2}. $$

The full integral is \(2+6+\frac{3}{2}=\frac{19}{2}\). The interval length is \(4-0=4\), so

$$ f_{\mathrm{avg}} = \frac{1}{4}\cdot\frac{19}{2} = \frac{19}{8}. $$

Check: The proposed average times the full interval length is \(\frac{19}{8}\cdot 4=\frac{19}{2}\), which agrees with the combined integral.

Worked Example: A Negative Contribution

Find the average value on \([0,6]\) for

$$ g(x)= \begin{cases} 3-x, & 0\le x<2,\\ -1, & 2\le x<4,\\ x-5, & 4\le x\le 6. \end{cases} $$

The breakpoints are \(2\) and \(4\). Integrate the three formulas on their respective intervals:

$$ \int_0^6 g(x)\,dx = \int_0^2 (3-x)\,dx + \int_2^4 (-1)\,dx + \int_4^6 (x-5)\,dx. $$

The first contribution is

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

The constant negative piece contributes

$$ \int_2^4 (-1)\,dx = [-x]_2^4 = -4-(-2) = -2. $$

The last piece contributes

$$ \int_4^6 (x-5)\,dx = \left[\frac{x^2}{2}-5x\right]_4^6 = (18-30)-(8-20) = -12-(-12) = 0. $$

Thus the combined integral is \(4+(-2)+0=2\). Since the full interval has length \(6\),

$$ g_{\mathrm{avg}} = \frac{2}{6} = \frac{1}{3}. $$

Check: \(\frac{1}{3}\cdot 6=2\), the combined signed integral. In particular, replacing the negative contribution \(-2\) by \(2\) would give the wrong total.

Worked Example: Combining Three Different Rules

Find the average value on \([0,5]\) for

$$ h(x)= \begin{cases} x, & 0\le x<2,\\ 4, & 2\le x<3,\\ 6-x, & 3\le x\le 5. \end{cases} $$

Split at both formula changes:

$$ \int_0^5 h(x)\,dx = \int_0^2 x\,dx + \int_2^3 4\,dx + \int_3^5 (6-x)\,dx. $$

For the first piece,

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

For the constant piece,

$$ \int_2^3 4\,dx = [4x]_2^3 = 12-8 = 4. $$

For the last piece,

$$ \int_3^5 (6-x)\,dx = \left[6x-\frac{x^2}{2}\right]_3^5 = \left(30-\frac{25}{2}\right)-\left(18-\frac{9}{2}\right) = \frac{35}{2}-\frac{27}{2} = 4. $$

The sum is \(2+4+4=10\). Dividing by the full interval length \(5-0=5\) gives

$$ h_{\mathrm{avg}} = \frac{10}{5} = 2. $$

Check: \(2\cdot 5=10\), agreeing with the sum of the three integrals. Each local contribution has been included once, and together their subintervals cover all of \([0,5]\).

Why Splitting Works

The splitting rule follows from additivity of the definite integral. If \(a<c<b\) and \(f\) is integrable on \([a,b]\), then

$$ \int_a^b f(x)\,dx = \int_a^c f(x)\,dx+\int_c^b f(x)\,dx. $$

This property applies whether or not the formula for \(f\) changes at \(c\). For a piecewise-defined function, choose \(c\) to be a formula-change point so each integral can be evaluated using one formula. Repeating the property at each breakpoint gives the sum over all subintervals.

Justification: For a partition of \([a,b]\) that includes \(c\), the Riemann sum for the whole interval is the sum of the terms from \([a,c]\) and the terms from \([c,b]\). Taking the limits of these sums gives the two subinterval integrals, so the whole-interval integral equals their sum. Applying this argument repeatedly proves the formula for any finite list of breakpoints. Dividing both sides by \(b-a\), as required by the definition of average value, gives the piecewise average formula.

The proof also explains why the denominator does not change when the numerator is split. The calculation still finds the average on \([a,b]\); the subinterval integrals are only a way to evaluate its one full-interval integral.

Common Mistake: Averaging the Piece Formulas Separately

A frequent error is to find an average on each piece and then take an unweighted average of those local averages. That generally gives the wrong result when the pieces have different lengths. For example, in the first worked example the three subinterval lengths are \(1\), \(2\), and \(1\), not three equal lengths.

The three local averages there are \(2\), \(3\), and \(\frac{3}{2}\). Simply averaging those three numbers gives

$$ \frac{2+3+\frac{3}{2}}{3} = \frac{13}{6}, $$

which is not the correct full-interval average \(\frac{19}{8}\). The correction is to add the integrals, which already account for the lengths of their subintervals, and then divide once by the total length:

$$ \frac{2+6+\frac{3}{2}}{4} = \frac{19}{8}. $$

Another way to see the issue is that an integral on a longer subinterval typically represents a contribution across more of the domain. Giving every piece equal weight ignores that difference. The full-interval integral avoids this error by combining each contribution over its actual interval.

Practical Checks

Before accepting a result, check that the split covers the full interval with no gaps or overlaps of positive length, and that each formula is integrated only where it applies. Then confirm that the denominator is \(b-a\), not the number of pieces or the length of just one piece.

Finally, multiply the proposed average by \(b-a\). The product should equal the sum of the piece integrals. If a piece has a negative integral, retain its sign when adding: the average is determined by the net signed contribution over the whole interval.

Check Your Understanding

For each question, identify the full interval and the formula-change points before setting up any integrals.

  1. What is the average-value formula for an integrable function on \([a,b]\)?
  2. Why must a piecewise integral be split at each formula-change point inside the interval?
  3. If a piece contributes a negative integral, how does it affect the combined total?
  4. Why is the denominator the length of the full interval rather than the number of formulas?
  5. A proposed average on an interval of length \(7\) is \(3\). What should the combined integral equal if the answer is correct?

Test yourself: Calculus I final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): 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