In order to be integrable, a real function does not have to be continuous. Examples are the step functions, which have a single point of discontinuity and are constant elsewhere. Such a point is well behaved in the sense that the right hand limit and left hand limit of the function at the discontinuity are real numbers. In order to enlarge the class of continuous functions with such useful functions for many applications, we introduce the notions of a piecewise continuous and a piecewise smooth function.
We recall that a functions is called smooth if it differentiable and its derivative is continuous.
Let #f# be a real function and let #I# be a closed interval on which #f# is defined.
- A point #a# of #I# is called a jump discontinuity of #f# if #f_{-}(x) = \lim_{x\uparrow a} f(x)# and #f_{+}(x) = \lim_{x\downarrow a} f(x)# are real numbers.
- \(f\) is called piecewise continuous on \(I\) if there is a finite set of points #a_1,\ldots,a_n# in #I# such that #f# is continuous at all points of #I# distinct from #a_1,\ldots,a_n#, and each discontinuity of \(f\) in #I# is a jump discontinuity.
- \(f\) is called piecewise smooth on the interval \(I=\ivcc{a}{b}\) if there is a finite set of points #a_1,\ldots,a_n# in #I#, ordered such that #a_0\le a_1\lt a_2\lt\cdots\lt a_n\le b=a_{n+1}# with the property that #f# is differentiable with continuous derivative on each open interval #\ivoo{a_i}{a_{i+1}}# #(i=0,\ldots,n)#, and that each #a_i# #(i=1,\ldots,n)# is either a point of continuity or a jump discontinuity of #f# and for #f'#.
The function \(f\) whose graph is plotted below is piecewise continuous on \(\ivcc{-1}{1}\) with jump discontinuities at \(x=-0.6\) and \(x=0.4\). We indicate an endpoint of a curve that does not belong to the graph of #f# by a small open circle and a point that does belong to the graph by a small closed circle.

A function defined on all but a finite number of points of an interval #I# is sometimes called piecewise on #I#. The derivative of a piecewise smooth function is an example.
In many instances, the values of a piecewise function at the exceptional points can be chosen to suit the situation at hand. For instance, for the purpose of approximation of a piecewise function #f# by Fourier series we will be discussing later, it is convenient to choose the value at such a point #x# to be the midpoint between the left-hand limit and right-hand limit of #f# at #x#.
Therefore, we will often view the derivative #f'# for a piecewise smooth function to be defined on all of #I#. With this interpretation of #f'#, the derivative of a piecewise smooth function #f# is piecewise continuous.
Piecewise functions are not the same as piecewise defined functions. The term piecewise defined refers to a function rule that is given in pieces, depending on the interval to which the argument #x# belongs. The function #f# on #\ivcc{0}{1}# given by #f(0)=0# and #f(x) = n # if #x\in\ivoc{\frac{1}{n+1}}{\frac{1}{n}}# for #n=1,2,\ldots# is piecewise defined, defined at each point of the interval.
Piecewise continuous functions are Riemann integrable and their integral can be expressed in terms of integrals of continuous functions.
Suppose that #f# is piecewise continuous on a closed interval #\ivcc{a}{b}# and let #a_1,\ldots,a_n# be the jump discontinuities of #f# in increasing order. For #i=1,\ldots,n+1#, denote by #f_i# the function on the closed interval #\ivcc{a_{i-1}}{a_{i}}#, where #a_0=a# and #a_{n+1} = b#, which is equal to #f# on the open interval #\ivoo{a_{i-1}}{a_{i}}# and takes the values #f_+(a_{i-1})# at #a_{i-1}# and #f_-(a_{i})# at #a_{i}#. Then #f_i# is continuous on #\ivcc{a_{i-1}}{a_{i}}# for #i=1,\ldots,n+1# and we have
\[\int_a^b f(x)\dd x= \sum_{i=1}^{n+1} \int_{a_{i-1}}^{a_{i}} f_i(x)\dd x\]
By the choice of jump discontinuities, the function #f_i# is continuous on the open interval #\ivoo{a_{i-1}}{a_{i}}#. Since #\lim_{x\downarrow a_{i-1}}f(x) = f_+(a_{i-1}) = f_i(a_{i-1})#, the function #f_i# is continuous at #a_{i-1}# and, for similar reasons, it is continuous at #a_i#, so #f_i# is continuous at every point of #\ivcc{a_{i-1}}{a_{i}}#. This means that it is continuous on #\ivcc{a_{i-1}}{a_{i}}#. In particular, #f_i# is Riemann integrable on #\ivcc{a_{i-1}}{a_{i}}#. The sum #\sum_{i=1}^{n+1} f_i# differs from #f# only at the points #a_i# (#i=1,\ldots,n#), and so
\[\int_a^b f(x)\dd x= \int_{a_{i-1}}^{a_{i}}\sum_{i=1}^{n+1} f_i(x)\dd x= \sum_{i=1}^{n+1} \int_{a_{i-1}}^{a_{i}} f_i(x)\dd x\]
When applied to the derivative #f'# of a piecewise smooth function #f#, with no jump discontinuous for #f# and #f'# outside the #a_i#, we find
\[\begin{array}{rcl}\int_a^b f'(x)\dd x &=&\displaystyle\sum_{i=1}^{n+1} \int_{a_{i-1}}^{a_{i}} (f')_i(x)\dd x \\&=&\displaystyle\sum_{i=1}^{n+1} \int_{a_{i-1}}^{a_{i}} f_i(x)\dd x\\&=&\displaystyle\sum_{i=1}^{n+1} \left(f_-(a_{i}) - f_+(a_{i-1})\right)\\&=&\displaystyle f_-(b)-f_+(a) + \sum_{i=1}^{n}\left( f_-(a_{i}) - f_+(a_{i})\right)\end{array}\]
Here is a reformulation of integration by parts, in which the hypotheses are tailored to our needs.
Let #\ivcc{a}{b}# be a closed interval of finite length and suppose that #f# and #g# are continuous and piecewise smooth real functions on #\ivcc{a}{b}#. Then #f'\cdot g# and #f\cdot g'# are piecewise continuous and hence integrable on #\ivcc{a}{b}# and the definite integral of the product #f'\cdot g# on #\ivcc{a}{b}# satisfies \[ \int_a^b f'(x)\cdot g(x)\dd x = f(b)\cdot g(b)-f(a)\cdot g(a) -\int_a^b f(x) \cdot g'(x)\dd x\]
The product rule for differentiation gives #(f\cdot g)'= f\cdot g'+ f'\cdot g =f+g#, which can be rewritten to \[ f'\cdot g = (f\cdot g)'- f\cdot g'\]
By the hypotheses, both sides represent integrable functions. Indeed, #f#, #f'#, #g# and #g'# are piecewise continuous on the interval, which implies that also #f\cdot g'# and #f'\cdot g# are piecewise continuous, and hence their Riemann integrals exist. By taking the integral on #\ivcc{a}{b}# at both sides of the product rule, we find
\[\int_a^b f'(x)\cdot g(x)\dd x = f(b)\cdot g(b)-f(a)\cdot g(a) -\int_a^b f(x) \cdot g'(x)\dd x\]
The proof of the theorem relies on the integration by parts technique, which fails if the functions are piecewise smooth and one of these is not continuous. Consider for instance the functions on #\ivcc{0}{1}# given by
\[ f(x)=\frac{x^2}{2} \text{ } \quad \text{ and }\quad g(x) = \begin{cases} 1 & 0 \leq x \leq \frac{1}{2} \\ 0 & \frac{1}{2} \lt x \leq 1 \end{cases} \]
Both functions are piecewise smooth and #f# is continuous, but #g# has a discontinuity at #\frac{1}{2}#.
Suppose we want to compute the integral
\[\int_0^1 f' (x)\cdot g(x) \, \dd x \]
Because #g'=0#, #g(1) = 0# and #f(0)=0#, the right hand side of the integration by parts formula gives
\[ f(1)\cdot g(1) - f(0)\cdot g(0) - \int_0^1 f(x)\cdot g' (x)\, \dd x = 0\]
On the other hand,
\[\begin{array}{rcl}\displaystyle \int_0^1 f'(x) \cdot g(x) \, \dd x = \int_0^{\frac12} x \,\dd x = \left. \frac{x^2}{2} \right|_0^{\frac12} = \frac{1}{8} \neq 0 \end{array}\]
We conclude that the right hand side of the integration by parts formula differs from the left hand side.
Applying the formula to the closed intervals #\ivcc{0}{\frac{1}{2}}# and #\ivcc{\frac{1}{2}}{1}# gives
\[\begin{array}{rcl}\int_0^1 f' (x)\cdot g(x) \, \dd x &=& \int_0^{\frac{1}{2} }f' (x)\cdot g(x) \, \dd x + \int_{\frac{1}{2}}^{1} f' (x)\cdot g(x) \, \dd x\\ &=& f(\frac{1}{2})\cdot g_-(\frac{1}{2}) - f(0)\cdot g(0) - \int_0^{\frac{1}{2}} f(x)\cdot g' (x)\, \dd x\\ &&+ f(1)\cdot g(1)-f(\frac{1}{2})\cdot g_+(\frac{1}{2}) - \int_{\frac{1}{2}}^{1} f(x)\cdot g' (x)\, \dd x\\ &=&\frac{1}{8}-0-0+0-0 -0\\ &=&\frac{1}{8}\end{array}\]
which is a correct application of the integration by parts formula since the function #f# is continuous and #g# is continuous on the intervals #\ivco{0}{\frac{1}{2}}# and #\ivoc{\frac{1}{2}}{1}# and can be extended to a continuous function on the corresponding closed intervals by use of #g_-# and #g_+#, respectively, at the boundary point #\frac12#.
Let #f# be the function on #\ivcc{-1}{1}# given by
\[f(x) = \begin{cases} -x & \text{if } \,-1\le x \lt 0\\ \euler^ {- x }& \text{if }\quad 0\le x \le 1\end{cases}\]
Calculate \[\int_{-1}^{1} f(x){\dd x}\]
\(\int_{-1}^{1} f(x){\dd x}=\) \( {{3}\over{2}}-\euler^ {- 1 }\)
The integrand #f# is piecewise continuous on #\ivcc{-1}{1}#. Its only jump of discontinuity occurs at #0#. By the theorem
Definite integral of a piecewise continuous function, we have
\[\begin{array}{rcl} \displaystyle \int_{-1}^{1} f(x){\,\dd x} &=&\displaystyle \int_{-1}^{0} -x\, {\dd x} + \int_{0}^{1} \euler^ {- x }\,{\dd x} \\
&&\phantom{xxx}\color{blue}{\text{the above-mentioned theorem}}\\
&=&\displaystyle \left[ -{{x^2}\over{2}}\right]_{-1}^{0} + \left[-\euler^ {- x }\right]_{0}^{1} \\
&&\phantom{xxx}\color{blue}{\text{Fundamental theorem of Calculus}}\\
&=&\displaystyle {{1}\over{2}} +1-\euler^ {- 1 } \\
&&\phantom{xxx}\color{blue}{\text{boundary values used}}\\
&=&\displaystyle {{3}\over{2}}-\euler^ {- 1 } \\
&&\phantom{xxx}\color{blue}{\text{simplified}}\\ \end{array}\]