Finding $L(h,P_n)$ , $U(h, P_n)$ in discontinous functions Let $h:[-1,1] \rightarrow \mathbb R $ be the function
$$
h(x) = \begin{cases}
1+x,& -1\leqslant x<0\\
0,& x = 0\\
1-x,& 0<x\leqslant 1.
\end{cases}
$$
For each $n\in \mathbb{N}$, let $P_n$ be the partition that divides the interval $[-1,1]$ into $2n$ subintervals of equal lengths.
Find $U(h,P_n)$ and $L(h, P_n)$.
 A: Observe that
$$ P_n = \bigcup_{k=0}^n \left\{-\frac kn, \frac kn \right\}. $$
There are a few things to note about this function:


*

*$h$ is increasing (and continuous) on $[-1,0)$, so the minimum (resp. maximum) value will be obtained at the left (resp. right) endpoint of any subinterval of $P_n$ that is contained in $[-1,0)$.

*Since $h(x)=0$, for any subinterval containing a point $x_0$ such that $h(x_0)=0$, the contribution of that subinterval to the lower Darboux sum will be $0$. Meanwhile, as $\lim_{x\to0}h(x)=1$, the contribution to the upper sum will simply be the width of the subinterval, $\frac1n$.

*$h$ is decreasing (and continuous) on $(0,1]$, so the minimum (resp. maximum) value will be obtained at the right (resp. left) endpoint of of any subinterval of $P_n$ that is contained in $(0,1]$.

*We can see readily that the length of a subinterval of $P_n$ is $\frac1n$, since the length of $[-1,1]$ is $2$ and $2n\left(\frac1n\right)=2$.


From this, the computation follows (a bit tediously):
\begin{align}
U(h,P_n) &= \sum_{k=1}^n \left(\frac1n\right)\left(1 + \left(\frac{-n+k}n\right) \right) + \sum_{k=1}^n\left(\frac1n\right)\left(1 - \frac{k-1}n \right) \\
&= \frac1n\sum_{k=1}^n \left(\frac kn\right) + \frac1n\sum_{k=1}^n \left(\frac{n-k+1}n\right)\\
&= \frac1{n^2}\left( \sum_{k=1}^n k + \sum_{k=1}^n (n-k+1)\right)\\
&= \left(\frac2{n^2}\right)\left(\frac{n(n+1)}2\right)\\
&= 1 + \frac1n.
\end{align}
As for the lower sum,
\begin{align}
L(h, P_n) &= \sum_{k=1}^n\left(\frac1n\right)\left(1 + \left(\frac{-n-1+k}n\right) \right) + \sum_{k=1}^n \left(\frac1n\right)\left(1 - \frac kn \right)\\
&= \frac1n\left( \sum_{k=1}^n\left(\frac{k-1}n\right) + \sum_{k=1}^n \left(\frac{n-k}n\right)  \right)\\
&= \frac1{n^2}\left( \sum_{k=1}^n (k-1) + \sum_{k=1}^n (n-k) \right)\\
&= \frac2{n^2}\left( \sum_{k=1}^{n-1}k\right)\\
&= \left(\frac2{n^2}\right)\left(\frac{(n-1)n}2\right)\\
&= 1-\frac1n.
\end{align}
Hence $$U(h, P_n) - L(h, P_n) = \left(1+\frac1n\right)-\left(1-\frac1n\right)=\frac2n\stackrel{n\to\infty}\longrightarrow 0,$$
from which we conclude that $$\int_{-1}^1 h(x)\ \mathsf dx = 1.$$
As a side note, it is a well-known theorem that changing the value of an integrable function at a finite (even countably infinite) number of points does not change the value of the integral. So with the Lebesgue theory we would simply note that $h(x) = (1+x)\chi_{[-1,0)} + (1-x)\chi_{(0,1]}$ and $h=f$ a.e. where $f = h + \chi_{\{0\}}$. Then $f$ is a continuous, bounded function with compact support, so it is Riemann-integrable and the Riemann integral agrees with the Lebesgue integral:
$$
\int_{[-1,1]} h\ \mathsf dm = \int_{-1}^1 f(x)\ \mathsf dx.\\
$$
Noticing that $f$ is an even function ($f(x) = f(-x)$), we have
\begin{align}
\int_{-1}^1 f(x)\ \mathsf dx &= 2\int_0^1 f(x)\ \mathsf dx\\
&= 2\int_0^1(1-x)\ \mathsf dx\\
&= 2\left[x-\frac12 x^2\right]_0^1\\
&= 2\left(1 - \frac12\right)\\
&= 1.
\end{align}
