Integration of a piecewise defined discontinuous function In a proof i posted recently on this site (link) i made the mistake of thinking that a function $f$, which is bounded on a closed interval $[a,b]$, would assume its infimum at a certain $x$ in the domain of $f$. I was presented with a counter example which, for my ability, seemed rather complicated. So i tried to find an easier counter example. I found the following function:
$$ f(x) = \begin{cases}
x & x > 0 \\
1 & x = 0
\end{cases} $$
Here, $ inf \{ f(x) : 0 \le x \le 1 \} = 0 $ but $f(x) \neq 0$ for all $x$.
I guess this is suitable as a counter example. Then i came up with the idea of trying to integrate this function. So came to the following proposition:
Proposition: Let $f$ be a function defined on $[a,b]$ as follows:
$$ f(x) = \begin{cases}
x & x > 0 \\
1 & x = 0
\end{cases} $$
This function is integrable with:
$$ \int_0^b = \frac{b^2}{2}$$
Proof: I use a partition $ P = \{t_0, ... , t_n \} $ of $[a,b]$ with
$$ t_i - t_{i-1} = \frac{b}{n} $$
$$ t_i = \frac{ib}{n} $$
$$ t_{i-1} = \frac{(i-1)b}{n} $$
$$ m_i = inf \{ f(x) : t_{i-1} \le x \le t_i , i \neq 1 \} = \frac{(i-1)b}{n} $$
$$ m_1 = inf \{ f(x) : t_0 \le x \le t_1 \} = 0 $$
$$ M_i = sup \{ f(x) : t_{i-1} \le x \le t_i , i \neq 1 \} = \frac{ib}{n} $$
$$ M_1 = sup \{ f(x) : t_0 \le x \le t_1 \} = 1 $$
Then we have
$$ L(f, P) = \sum_{i=2}^n m_i \cdot \frac{b}{n} + m_1 \cdot \frac{b}{n} = \sum_{i=2}^n \frac{(i-1)b}{n} \cdot \frac{b}{n} + 0 \cdot \frac{b}{n} = \frac{b^2}{n^2} \cdot \sum_{j=1}^{n-1} j = \frac{b^2}{2} \cdot \frac{n-1}{n}$$
and
$$ U(f, P) = \sum_{i=2}^n M_i \cdot \frac{b}{n} + M_1 \cdot \frac{b}{n} = \sum_{i=2}^n \frac{ib}{n} \cdot \frac{b}{n} + 1 \cdot \frac{b}{n} = \Biggl[ \frac{b^2}{n^2} \cdot \sum_{j=1}^{n-1} j+1 \Biggl] + \frac{b}{n} = \frac{b^2}{2} \cdot \frac{n+1}{n} + \frac{b}{n}$$
For the difference of the upper and lower sums this results in
$$ U(f, P) - L(f, P) = \frac{b^2}{2} \cdot \frac{n+1}{n} + \frac{b}{n} - \frac{b^2}{2} \cdot \frac{n-1}{n} = \frac{b^2}{2} \cdot \frac{n+1}{n} - \frac{b^2}{2} \cdot \frac{n-1}{n} + \frac{b}{n} = \frac{b^2}{2} \cdot \frac{2}{n} + \frac{b}{n} = \frac{b^2+b}{n}$$
So in order get $ U(f, P) - L(f, P) < \epsilon$ we can choose $ n > \frac{b^2+b}{\epsilon} $. Thus $f$ is integrable and since
$$ \frac{b^2}{2} \cdot \frac{n-1}{n} \le \frac{b^2}{2} \le \frac{b^2}{2} \cdot \frac{n+1}{n} + \frac{b}{n}$$
and the integral is unique, if it exists, we have
$$ \int_0^b = \frac{b^2}{2}$$
as required. $ \blacksquare $
All these equations and manipulations are quite complex regarding my ability. So might anyone tell me if this is correct or point me towards my mistakes? Thanks in advance.
 A: Yes, the proof seems good and rock solid to me. If I could add something would be this: are you familiar with taking limits of successions?
One equivalent definition of (Riemann) Integrable function would be to check that $\lim_{n\to \infty}L(f,P_n)=\lim_{n\to \infty}U(f,P_n)$ , and using this definition of integrable function could speed up and also make a bit easier the calculations in the last part of your reasoning.
A: In retrospection i think i found a mistake in my proof. I used $\sum_{j=1}^{n-1} j+1 = \frac{n(n+1)}{2}$ which is false, since $\sum_{j=1}^{n-1} j+1 = \frac{n^2 + n -2}{2}$.
With this discovery and the hint of @Andrea S. i found
$$ U(f, P) = \sum_{i=2}^n M_i \cdot \frac{b}{n} + M_1 \cdot \frac{b}{n} = \sum_{i=2}^n \frac{ib}{n} \cdot \frac{b}{n} + 1 \cdot \frac{b}{n} = \Biggl[ \frac{b^2}{n^2} \cdot \sum_{j=1}^{n-1} j+1 \Biggl] + \frac{b}{n} = \frac{b^2}{2} \cdot \frac{(n-1)(n+2)}{n^2} + \frac{b}{n} = \frac{b^2}{2} \cdot \frac{(n-1)}{n} \cdot \frac{n+2}{n} + \frac{b}{n}$$
and
$$ L(f, P) = \frac{b^2}{2} \cdot \frac{n-1}{n}$$
Now, since $\lim_{n\to \infty} \frac{(n-1)}{n} = \lim_{n\to \infty} \frac{n+2}{n} = 1$ and $\lim_{n\to \infty} \frac{b}{n} = 0$ we have
$$\lim_{n\to \infty}L(f,P)=\lim_{n\to \infty}U(f,P_n)=\frac{b^2}{2}$$
as required. $\blacksquare$
