Mean Value Theorem for Integrals/Generalization

Theorem
Let $f$ and $g$ be continuous real functions on the closed interval $\closedint a b$ such that:
 * $\forall x \in \closedint a b: \map g x \ge 0$

Then there exists a real number $k \in \closedint a b$ such that:


 * $\displaystyle \int_a^b \map f x \, \map g x \rd x = \map f k \int_a^b \map g x \rd x$

Proof
In the case that $\displaystyle \int_a^b \map g x \rd x = 0$ it follows from $\map g x \ge 0$ for all $x \in \closedint a b$ that $\map g x = 0$ for all $x \in \closedint a b$ giving:


 * $\displaystyle \int_a^b \map f x \ \cdot 0 \rd x = \map f k \cdot 0$

and so the result holds for any choice of $k$.

Otherwise, assume $\displaystyle \int_a^b \map g x \rd x \neq 0$.

From Continuous Function is Riemann Integrable, $f$ is Riemann integrable on $\closedint a b$.

By the Extreme Value Theorem, there exist $m, M \in \closedint a b$ such that:


 * $\displaystyle \map f m = \min_{x \mathop \in \closedint a b} \map f x$
 * $\displaystyle \map f M = \max_{x \mathop \in \closedint a b} \map f x$

Then the following inequality holds for all $x$ in $\closedint a b$:


 * $\displaystyle \map f m \leq \map f x \leq \map f M$

Multiplying by $\map g x$ and using that $ \map g x \ge 0, \forall x \in \closedint a b$ gives:


 * $\displaystyle \map f m \map g x \leq \map f x \map g x \leq \map f M \map g x$

Integrating from $a$ to $b$ gives:


 * $\displaystyle \int_a^b \map f m \map g x \rd x \leq \int_a^b \map f x \map g x \rd x \leq \int_a^b \map f M \map g x \rd x$

By the constant factor rule in integration we may pull out the constants:


 * $\displaystyle \map f m \int_a^b \map g x \rd x \leq \int_a^b \map f x \map g x \rd x \leq \map f M \int_a^b \map g x \rd x$

Dividing by $\int_a^b \map g x \rd x$ gives:


 * $\displaystyle \map f m \leq \dfrac{\int_a^b \map f x \map g x \rd x} {\int_a^b  \map g x \rd x} \leq \map f M $

By the Intermediate Value Theorem, there exists some $k \in \openint a b$ such that: