Lower and Sup Sums [Integration, partitions] So i have this problem.
Let 
$f(x)$= {$x^2$ if -3$\le$ $x$ $\le$ 1, $-2x$ if $1$$\lt$$x$$\le$$2$
And $P$={$x_0$,...,$x_n$} a partition of [-3,2]. If $1$$\in$[$x_i-1$,$x_i$], find $m_i$, $M_i$, i.e, $m_i$=inf and $M_i$=$sup${$f(x)$:$x$$\in$[$x_{i-1}$,$x_i$]} and for the given partition write the expretion for the sup and low sums. 
And b) Let $g$ be a continous function in $[a,b]$, if 
$L(g,P)$$\le$$2018A$$\le$$U(g,P)$, for any partition of $[a,b]$, show that 
$A=$$\frac{1}{2018}$$\int_a^b$$g(t)dt$.
So this is my attempt for (a) (i know im wrong but i dont know what to do im a little confused in both problems hope that you guys help me)
So we know that 1$\in$[$x_{i-1}$,$x_i$] and for $x^2$ and $-2x$ then
$m_i$=$inf${-2}$=-2$
$M_i$=$sup${1}$=1$
Hence for low and sup sums respectively and because [-3,2] we have
$L(f,P)$=$\sum_{i=1}^n$$-2$$(b-a)$=$-10$
And similarly for the sup sum
we have that is equal to 5.
But i know that in this problem we have four cases right? and in 1 we have troubles but i dont see it can you guys help me to solve this?
In part (b) i have this 
Because g es continous in $[a,b]$ then g is integrable.
Given $\epsilon$$\gt$0 we have 
0$\le$$L(g,P)$-$U(g,P)$$\le$$\epsilon$
then by hypotesis 
$L(g,P)$$\le$$2018A$$\le$$U(g,P)$ for all partition in [a,b], then
0$\le$$L(g,P)$-$U(g,P)$$\le$$2018A$$\le$$\epsilon$
And for $L(g,P)$-$U(g,P)$ 
given an arbitrary partition such that for this partition occurs:
0$\le$$|g-A|$$\le$$\epsilon$
0$\le$$|g-2018A|$$\le$$\epsilon$
$|g-2018A|$=0
$A$=$\frac{1}{2018}$$\int_a^b$$g(t)dt$
In this problem i dont know how to argue or i dont know if this is right for an arbitrary partition. Help please 
$|g-A|$$\le$$\epsilon$
 A: (a) I think the definition of $M_i$ should be $M_i=\sup \left\{ f(x):x \in [x_{i-1},x_i] \right\}$, if so i suggest you to edit your post.
To answer this question is really helpfull to draw the graph of $f$
Now you only know that $1 \in [x_{i-1},x_i]$ but you don't know how long is $[x_{i-1},x_i]$ .
So you have to study different cases, for example:
if $x_{i-1} \leq -1$ then $M_i=f(x_{i-1})$
if $x_{i-1} \geq -1$ then $M_i=f(1)=1$, (remember that there is a condition on $[x_{i-1},x_i]$, namely $1 \in [x_{i-1},x_i]$
Can you continue with the study of the different cases?
The same strategy can be adopted to find $m_i$ in the different cases.
(b)$g$ is continuous so if we write $\delta=\max \left\{ |x_{i+1}-x_i|:x_i \in P \right\}$ then $\lim_{\delta \to 0}L(g,P)=\int_a^b g dx= \lim_{\delta \to 0}U(g,P)$ so if we do the limit of the inequality $L(g,P) \leq 2018A \leq U(g,P)$ we can conclude that  $\int_a^b g dx \leq 2018 A \leq \int_a^b g dx$, from wich we can conclude the thesis.
In the proof I stealthy used some important stuff on the limits, for examples that the above limit preserve the inequalities in this sense:
$L(g,P) \leq 2018A \implies \lim_{\delta \to 0}L(g,P) \leq 2018A $.
A: 
I draw this and i dont know, i see that there must be four summatory right?, and if we zoom that part of the graphic we see that 0 is the inf right? im a little confused in this problem
