Solution (source code)

= Solution

Pointwise on $[a,b]$,
$$
mg(x)\leq f(x)g(x)\leq Mg(x)
$$
because $g(x)>0$. To see the implication directly from the definition, every Riemann sum of the nonnegative continuous function $(f-m)g$ is nonnegative, so its limit is nonnegative:
$$
\int_a^b(f-m)g\geq0.
$$
Applying the same argument to $(M-f)g$ gives $\int_a^b(M-f)g\geq0$. By linearity, these are exactly the <monotonicity of the Riemann integral> bounds
$$
\boxed{
m\int_a^bg(x)\,dx
\leq\int_a^bf(x)g(x)\,dx
\leq M\int_a^bg(x)\,dx}.
$$