Home » Blog » Compute integrals of piecewise defined functions

Compute integrals of piecewise defined functions

Compute the following:

  1. \displaystyle{\int_0^2 f(x) \, dx} where

        \[ f(x) = \begin{cases} x^2 & \text{for } 0 \leq x \leq 1, \\ 2-x & \text{for } 1 \leq x \leq 2. \end{cases} \]

  2. \displaystyle{\int_0^1 f(x) \, dx} where c \in \mathbb{R} is fixed with 0 < c < 1 and,

        \[ f(x) = \begin{cases} x & \text{for } 0 \leq x \leq c, \\ c \frac{1-x}{1-c} & \text{for } c \leq x \leq 1. \]


To evaluate the integrals of these piecewise defined functions we break the integral into parts so that the intervals of integration correspond to the definition of the functions we have. (We can always split the interval of integration into pieces since the integral is additive with respect to the interval of integration by Theorem 1.17 of Apostol.)

  1. We split the interval [0,2] into [0,1] and [1,2] to obtain,

        \begin{align*}  \int_0^2 f(x) \, dx &= \int_0^1 f(x) \, dx + \int_1^2 f(x) \, dx \\  &= \int_0^1 x^2 \, dx + \int_1^2 (2-x) \, dx \\  &= \left. \frac{x^3}{3}\right|_0^1 + \left. \left( 2x - \frac{x^2}{2} \right) \right|_1^2 \\  &= \left(\frac{1}{3} -  0 \right) + \left( 2 - \frac{3}{2} \right) \\  &= \frac{1}{3} + \frac{1}{2} \\  &= \frac{5}{6}. \end{align*}

  2. We split the interval [0,1] into the two intervals [0,c] and [c,1] and compute,

        \begin{align*}  \int_0^1 f(x) \, dx &= \int_0^c f(x) \, dx + \int_c^1 f(x) \, dx \\  &= \int_0^c x \, dx + \int_c^1 \left( \frac{c}{1-c} \right)(1-x) \, dx \\  &= \left. \frac{x^2}{2} \right|_0^c + \frac{c}{1-c} \left. \left( x - \frac{x^2}{2} \right) \right|_c^1 \\  &= \frac{c^2}{2} + c - \frac{c}{2(1-c)} + frac{c^3}{2(1-c)} \\  &= \frac{c^2}{2} + c + \frac{c^3-c}{2(1-c)} \\  &= \frac{c^2}{2} + c + \frac{c(c+1)}{2} \\  &= \frac{c^2}{2} + c - \frac{c^2}{2} - \frac{c}{2} \\  &= \frac{c}{2}. \end{align*}

Point out an error, ask a question, offer an alternative solution (to use Latex type [latexpage] at the top of your comment):