# If $f$ is continuous and $g$ is integrable on $[a,b]$, with $g(x) \ge 0$ for all $x \in [a,b]$ …

Suppose $f : [a,b] \to \mathbb{R}$ is continuous and $g \in \mathcal{R}[a,b]$ with $g(x) \ge 0$ for all $x \in [a,b]$. Show that there exists a $c \in [a,b]$ such that $$\int_a^b f(x)g(x) \, dx = f(c) \int_a^b g(x) \, dx.$$

My attempt:

My class proved a theorem which states that $f$ attains its minimum and maximum ($m$ and $M$, respectively), since $f$ is continuous on a closed interval like $[a,b]$. So we would have $m \le f(x) \le M$. Multiplying both sides by $g$ and integrating, we get $$m \int_a^b g(x) \, dx \le \int_a^b f(x) g(x) \, dx \le M \int_a^b g(x) \, dx.$$

I am stuck after this. Where can I go from here?

We know that $\forall$ $x \in [a,b]$, $m \le f(x)$ $\le$ M, where $m =\inf(f)$ and $M = \sup(f)$. Then $mg(x)$ $\le$ $f(x)g(x)$ $\le$ $Mg(x)$, $\forall$ $x$ $\in$ $[a,b]$. It follows that $$m\int_a^b g(x)dx \le \int_a^b f(x)g(x)dx \le M\int_a^b g(x)dx$$
Therefore, $\exists$ $d$ $\in$ $[m,M]$ such that $d\int_a^b g(x)dx = \int_a^b f(x)g(x)dx$. Since $f$ is continuous, $\exists c \in [a,b]$ such that $d=f(c)$ .
If $\int_a^b g(x)dx=0$, then you are done - you can take any $c$. If not, divide both sides of your inequality by $\int_a^b g(x)dx$ and apply intermediate value theorem.