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.
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.
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.
List the endpoints of every subinterval where the formula changes.
Use that subinterval’s endpoints as the bounds for its formula.
This sum is the integral over the entire interval.
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.
The antiderivative checks because \(\frac{d}{dx}\left(\frac{x^2}{2}+x\right)=x+1\).
Step 3: Compute the second integral.
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]\).
The derivative of \(\frac{x^3}{3}\) is \(x^2\), as required.
Step 2: Integrate on \([1,3]\).
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]\).
The derivative of \(4x\) is \(4\).
Step 2: Integrate \(1+x\) on \([2,5]\).
The derivative of \(x+\frac{x^2}{2}\) is \(1+x\).
Step 3: Integrate \(10-x\) on \([5,6]\).
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:
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:
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:
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.
- 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]\).
- 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?
- A function has piece averages \(3\) and \(7\) on subintervals of widths \(1\) and \(3\), respectively. What is its average over the combined interval?
- What condition on a formula near an excluded endpoint is missing from the claim that “continuity on each piece guarantees integrability”?
- Explain why the denominator in the piecewise average formula is the length of the entire interval, not the number of pieces.