# Topic 17: Integration of piecewise

```Topic 17: Integration of piecewise-defined functions
Math 122, Spring 2008
Recall that a function is a rule which associates an input to a particular output. Functions have various
representations in mathematics. One way of representing a function is a graph. The graph tells us which
output is associated with a particular input. In calculus, it is common to express functions in terms of
formulas. For example, the function f (x) = ex tells us that the formula for finding the output is to raise the
number e to the power of the input.
Many functions which arise in practice cannot be described by a single formula. In these cases, we can
often benefit by defining a function piecewise. A piecewise-defined function tells us which rule to follow
under specific circumstances. For example, the function
(
2x − 5 if x &lt; 2
g(x) =
x2
if x ≥ 2
is defined piecewise. The function g is the rule which says to double the input and subtract 5 if the input is
less than two, and to square the input otherwise. You have probably graphed such functions. In Calculus I,
you likely examined such functions to see if they were continuous. Is this one continuous?
Often times, piecewise-defined functions can be integrated. That is, I can ask about the area under the
graph of the function g, even though it is piecewise defined. For those interested, convince yourself that the
definition of definite integral (involving rectangles and Riemann sums) can often be applied to such functions.
In order to evaluate these integrals, we use a property analagous to property 2 of Theorem 5.2 (page 246)
on definite integrals, which says that when f is continuous,
Z c
Z b
Z b
f (x) dx +
f (x) dx =
f (x) dx.
a
c
a
R 4 Here’s an example of how to use this property. Consider the function g given above. In order to find
g(x) dx, we compute
0
Z
4
Z
2
g(x) dx =
0
Z
4
g(x) dx +
0
Z
g(x) dx
2
2
Z
(2x − 5) dx +
=
0
= −6 +
4
x2 dx
2
56
.
3
Notice that in the second line of arguments above, the function g(x) was replaced with the appropriate
formula for the interval in question. In particular, in the first integral we replaced g(x) with 2x − 5 because
that is how we compute g(x) when x &lt; 2. On the other hand, the second integral saw g(x) replaced by x2 ,
because there x ≥ 2.
Practice: 1. Consider the function f defined by

3

if x &lt; −2
−x
f (x) = −3x + 2 if − 2 ≤ x &lt; π


sin x
if x ≥ π.
(a) Sketch a graph of the function f .
(b) Where is the function f continuous?
Z 0
(c) Calculate
f (x) dx.
−3
Z
0
f (x) dx.
(d) Calculate
Z −2
5π/4
(e) Calculate
f (x) dx.
−3
2. Consider the function q(x) defined by
(
0
if x ≤ 0
q(x) =
−5x
5e
dx if x &gt; 0.
(a) Sketch a graph of the function q.
(b) Where is the function q continuous?
Z 0
(c) Calculate
q(x) dx.
Z−38
(d) Calculate
q(x) dx.
Z −∞
∞
(e) Calculate
f (x) dx.
−∞
Assignment:
3. Consider the function h defined by

2

−2x
h(x) = 5x


ln x
if x &lt; 0
if 0 ≤ x &lt; 2
if x ≥ 2.
(a) Sketch a graph of the function h.
(b) Where is the function h continuous?
Z 0
(c) Calculate
f (x) dx.
−2
Z 1
(d) Calculate
f (x) dx.
Z −2
5
(e) Calculate
f (x) dx.
−2
4. Consider the function r defined by

0



9x
r(x) =

xex



0
(a) Sketch a graph of the function r.
(b) Where is the function r continuous?
Z 0
(c) Calculate
r(x) dx.
−3
if
if
if
if
x &lt; −1
−1≤x&lt;3
3≤x≤5
x &gt; 5.
Z
4
r(x) dx.
(d) Calculate
Z −2
∞
(e) Calculate
r(x) dx.
−∞
```