Calculus Topic: Integrating Piecewise Discontinuous Bounded Functions
Standard calculus texts handle integration of unbounded functions under "improper integrals". This note is a quick supplement covering integration of bounded discontinuous functions, a topic which usually has little coverage in standard calculus texts.If we restrict to bounded functions (and so exclude infinite discontinuties found in improper integrals), the existence of integrals is guaranteed by a standard theorem on Riemann integrability: A bounded function defined on any interval has a continuous integral (antiderivative) if it has only finitely many discontinuities. Here our focus will be on actually computing such integrals.
Existence and uniqueness for integrals of piecewise defined bounded functions
A piecewise defined function in general will have \(n\) pieces, but for definiteness we illustrate the idea using the specific value \(n = 3\).Suppose that the interval \(a \leq x \leq b\) is partitioned into three subintervals \[ a = a_0 \lt a_1 \lt a_2 \lt a_3 = b \] and that we have a function \(f\) on the whole interval \(a \leq x \leq b\) defined piecewise as three separate functions \(f_1\), \(f_2\), and \(f_3\) on the three subintervals as follows:
\[ f(x) = \begin{cases} f_1(x), \quad & a_0 \lt x \lt a_1 \\ f_2(x), & a_1 \lt x \lt a_2 \\ f_3(x), & a_2 \lt x \lt a_3 \end{cases}. \]Also assume that each individual piece function \(f_k(x)\) (\(k = 1, 2, 3\)) is continuous and bounded (i.e., no vertical asymptotes) on its open subinterval \(a_{k-1} \lt x \lt a_k\), but has possible discontinuties (either jump or essential) at the subinterval endpoints.Under the above setup, the function \(f(x)\) can be "integrated" into an antiderivative function \(F(x)\) on the whole interval, and moreover, the antiderivative (primitive) function will be unique if we require it to be continuous on the whole interval \(a \leq x \leq b\) and satisfy the initial condition \(F(a) = y_0\).
Piecewise IVP Existence-Uniqueness TheoremIf the interval \(a \leq x \leq b\) is partitioned into \(n\) subintervals as \(a = a_0 \lt a_1 \lt a_2 \lt \cdots \lt a_n = b\), and if on each open subinterval \(a_{k-1} \lt x \lt a_k\) (\(k = 1,2, \dots, n\)) we have a function-piece \(f_k\) that is bounded and continuous on that open subinterval, then the Piecewise Initial Value Problem (Piecewise IVP)
\[ F'(x) = f_k(x) \quad \text{over} \quad a_{k-1} \lt x \lt a_k \quad (\text{for each }k = 1, 2, \dots, n), \qquad F(a) = y_0, \]has a unique continuous solution \(F(x)\) over the entire interval \(a \leq x \leq b\).The main point here is that the IVP will have a unique continuous solution even for piecewise functions with discontinuities at the subinterval endpoints \(x = a_0\), \(x = a_1\), \(x = a_2\), \(x = a_3\), etc.
The proof of the theorem is immediate from the fact that a function is Riemann integrable if it is bounded and has only finitely many discontinuities (or more generally if the set of discontinuity points has measure zero). In fact, the existence-uniqueness theorem above applies to any function defined on any interval (even unbounded ones) with finitely many discontinuities, so long as the function remains bounded in the neighborhoods of its discontinuities.An example (with essential and jump discontinuities)
Let \(f\) be the function defined piecewise over the interval \(-1 \leq x \lt \infty\) as follows:\[ f(x) = \begin{cases} -x, & -1 \lt x \lt 0 \\ 2x\sin \frac{1}{x} - \cos \frac{1}{x}, \quad & 0 \lt x \lt \frac{2}{\pi} \\ 1/x^2, & \frac{2}{\pi} \lt x \lt \infty \end{cases}. \]The graph of \(f\) is shown below. We use, as usual, the notation \(f(c+)\) to denote \(\displaystyle \lim_{x \to c+} f(x)\), and \(f(c-)\) to denote \(\displaystyle \lim_{x \to c-} f(x)\).
The function \(f\) is bounded; it has no vertical asymptotes. Moreover:
Now consider the IVP corresponding to the above function with the initial condition \(F(-1) = 1\):
- It has an essential discontinuity at \(x = 0\), since \(f(0+)\) does not exist: The function oscillates infinitely many times near \(0+\) without damping down. You can zoom/pan near \(0+\) to observe this.
- It has a jump discontinuity at \(x = \frac{2}{\pi}\), since \(f(\frac{2}{\pi}-) = \frac{4}{\pi} \lt f(\frac{2}{\pi}+) = \frac{\pi^2}{4}\).
\[ F(-1) = 1,\quad F'(x) = \begin{cases} -x, & -1 \lt x \lt 0 \\ 2x\sin\frac{1}{x} - \cos\frac{1}{x}, \quad & 0 \lt x \lt \frac{2}{\pi} \\ 1/x^2, & \frac{2}{\pi} \lt x \lt \infty \end{cases} \]By the fact mentioned in the last section, there is a unique continuous solution \(F(x)\) of the above IVP, defined on the entire interval \(a \leq x \leq b\). We will find this solution below.Integrating piecewise defined functions: Solving the IVP
The solution \(F(x)\) of the general IVP above can be expressed piecewise in terms of definite integrals as below, and it will be automatically continuous over the entire interval \(a = a_0 \leq x \leq a_3 = b\):
IVP Solution: Definite Integral Form\[ F(x) = \begin{cases} y_0 + \int_{a_0}^x f_1(t)\,dt, & a_0 \leq x \leq a_1 \\ y_0 + \int_{a_0}^{a_1} f_1(t)\,dt + \int_{a_1}^x f_2(t)\,dt, & a_1 \leq x \leq a_2 \\ y_0 + \int_{a_0}^{a_1} f_1(t)\,dt + \int_{a_1}^{a_2} f_2(t)\,dt + \int_{a_2}^x f_3(t)\,dt, \quad & a_2 \leq x \leq a_3 \end{cases}. \]Alternatively, instead of using definite integrals as above, it may be more convenient to use the following method: Pick an (any) anti-derivative \(F_k(x)\) for each component piece function \(f_k(x)\) over the interval \(a_{k-1} \lt x \lt a_k\), (\(k = 1, 2, 3\)), and then express the solution \(F(x)\) of the IVP as:
IVP Solution: Piecewise Antiderivative Form\[ F(x) = \begin{cases} y_0 - F_1(a_0+) + F_1(x), & a_0 \lt x \lt a_1 \\ y_0 - F_1(a_0+) + F_1(a_1-) - F_2(a_1+) + F_2(x), & a_1 \lt x \lt a_2 \\ y_0 - F_1(a_0+) + F_1(a_1-) - F_2(a_1+) + F_2(a_2-) - F_3(a_2+) + F_3(x), \; & a_2 \lt x \lt a_3 \end{cases} \]The resulting function \(F(x)\) will again be automatically continuous at the points \(x = a_0, a_1, a_2, a_3\) once we define \(F(a_k)\) as \(F(a_k+)\) or \(F(a_k-)\).
The two forms of solutions (definite integrals or piecewise anti-derivatives) are equivalent.
Finally, the indefinite integral \(\int f(x)\,dx\) of the piecewise function \(f(x)\) (i.e., the family of all anti-derivatives of \(f(x)\)) can be obtained by taking the intial value \(y_0\) to be an arbitrary constant \(C\) (instead of a specific numerical value).
The example solved
Let's use the piecewise anti-derivative form of solution to solve the example IVP.First, we find the three piecewise anti-derivatives,
\[ \begin{align*} F_1(x) & = \int (-x)\,dx = -\frac{x^2}{2},\\ F_2(x) & = \int [ 2x \sin \tfrac{1}{x} - \cos \tfrac{1}{x} ] \, dx = x^2 \sin \tfrac{1}{x},\\ F_3(x) & = \int \frac{1}{x^2} \, dx = - \frac{1}{x}. \end{align*} \]Next, we compute the one-sided limits of these anti-derivatives over their sub-intervals:\[ \begin{alignat*}{2} F_1(-1+) & = -\tfrac{1}{2}, \qquad & F_1(0-) & = 0\\ F_2(0+) & = 0 , & F_2\left(\tfrac{2}{\pi}-\right) & = \tfrac{4}{\pi^2}, \\ F_3\left(\tfrac{2}{\pi}+\right) & = - \tfrac{\pi}{2}, \quad & F_3(\infty-) & = 0. \end{alignat*} \]Finally, we substitute the above limit values and the initial condition is \(y_0 = F(-1) = 1\) into the IVP solution above in piecewise antiderivative form, to get:\[ F(x) = \begin{cases} \frac{3}{2} - \frac{x^2}{2}, & -1 \lt x \lt 0 \\ \frac{3}{2} + x^2 \sin\frac{1}{x}, & 0 \lt x \lt \frac{2}{\pi} \\ \frac{3}{2} + \frac{4}{\pi^2} + \frac{\pi}{2} - \frac{1}{x}, \quad & \frac{2}{\pi} \lt x \lt \infty \end{cases} \]
Continuity of the integral solution \(\boldsymbol{F(x)}\). The solution \(F(x)\) is continuous over the entire interval \(-1 \leq x \lt \infty\). Near \(0+\), it still oscillates infinitely many times, but continuity is achieved because the oscillations damp down fast! You can use zoom/pan near \(0+\) to observe this.
Differentiability of \(\boldsymbol{F(x)}\). Clearly, \(F(x)\) is differentiable (the derivative \(F'(x)\) exists) separately on the interior of each of the three open subinterval pieces, \(-1 \lt x \lt 0\), \(0 \lt x \lt \frac{2}{\pi}\), and \(\frac{2}{\pi} \lt x \lt \infty\). But what about \(F'(0)\) and \(F'(\frac{2}{\pi})\), do they exist? It turns out that \(F(x)\) is indeed differentiable at \(x = 0\): \(F'(0)\) exists, and is \(= 0\). This is because the left side tangent at \(x = 0\) is horizontal (being at the vertex of the parabola \(y = \frac{3}{2} - \frac{x^2}{2}\)), and the right side tangent at \(x = 0\) is also horizontal, again since the oscillations near \(0+\) die down sufficiently fast! On the other hand, \(F(x)\) is not differentiable at \(x = \frac{2}{\pi}\) since the left and right derivatives at that point differ (notice the slight corner there, where the left side of the curve meets the right side at an angle, instead of lining up straight).
(For more on the subtle nature of differentiability of the integral function, see this note.)