Let P = {$-10,-2,0,1,5$} and $f:=[-10,5]-> \mathbb{R}$ given by:
$ f(x)= \begin{cases} 4&\text{if}\, x= 0\\ \frac{x+2|x|}{|x|}&\text{if}\, x\not=0 \end{cases} $
I need to find a partition Q of $[-10,5]$ such that $U(f,Q)-L(f,Q)<0.001$.
My method: I worked out that $Q_n$ = {$-10+\frac{15i}{n}, i =0,1,2,....,n-1,n $}, so $x_i = -10 + \frac{15i}{n}$ and $x_i - x_{i-1} = \frac{15}{n}$. Hence, $m_i = -10 + \frac{15i-15}{n}$ and $M_i = -10 + \frac{15i}{n}$.
Now, $L(f,Q_n)$ = $\sum \limits_{i-1}^{n}({-10} + \frac{15i-15}{n})(\frac{15}{n})$ = $\frac{-75n-225}{2n}$.
$U(f,Q_n)$ = $\sum \limits_{i-1}^{n}({-10} + \frac{15i}{n})(\frac{15}{n})$ = $\frac{225-75n}{2n}$.
Hence, $U(f,Q_n)$ - $L(f,Q_n)$ = $\frac{225}{n}$. We want $\frac{225}{n} < 0.001$, meaning $n>225000$. Hence, a partition Q satisfying this property splits the interval $[-10,5]$ into $2250000$ equal intervals. How bad is this - have I made any errors or missed out on something obvious for solving ?
I think my mistake is finding $m_i$ and $M_i$ because I did this assuming $f(x)$ = $x$ rather than piecewise.
Can someone please show me how to correctly calculate $m_i$ and then I can complete the rest ??!!
I'll assume that $M_i=\sup\{f(x):x_{i-1}\le x\le x_i\}$ and $m_i=\inf\{f(x):x_{i-1}\le x\le x_i\}$ (you should double check your notes on how you've defined $M_i$ and $m_i$, as this may be slightly different). Let's apply that to your example $P=\{-10,-2,0,1,5\}$:
This means that \begin{align*} L(f,P)&=(1)(8)+(1)(2)+(3)(1)+(3)(4)=25,\qquad\text{while}\\ U(f,P)&=(1)(8)+(4)(2)+(4)(1)+(3)(4)=32,\qquad\text{with a difference}\\ U(f,P)-L(f,P)&=(0)(8)+(3)(2)+(1)(1)+(0)(4)=7. \end{align*} The interesting thing to notice is that when $f$ is constant, then $M=m$, and they subtract to give zero when you find $U-L$. This means that any partition can use large intervals over the regions where $f$ is constant, and only needs small intervals when $f$ is changing. And in this case, $f$ is changing only around $0$, which allows you to use relatively few intervals overall.