If $f$ and $g$ are continuous on $[a,b]$ and $g(x) > 0 \ \forall x \in [a,b]$ show $\exists c \in (a,b)$ s.t.
$$\int_{a}^{b} (fg)(x) dx = f(c) \int_{a}^{b} g(x)dx$$
Show that this conclusion fails if $g(x) < 0$.
I have seen this post: Prove $ f(c)\int_{a}^{b}g(x)dx=\int_{a}^{b}g(x)f(x)dx$
This proof makes sense to me; however, I have a different approach that uses the definition of integration involving upper and lower sums. I am quite uneasy about it, but I am curious because I would call the proof given in the post above "clever." At least for me it felt a bit clever since it made use of compactness and the extreme value theorem. What I'm saying is that I spent multiple hours on this problem, and I didn't think to use theorems outside of the definition, so I don't think I would have thought of that proof on an exam. That's why I'm curious if there is a way directly from first principles!
Since $fg$ is Riemann integrable, I know $\exists P = \{a,x_1,\dots,x_{n-1},b\}$ s.t.
$$L(fg,P) \leq \int_{a}^{b} (fg)(x) dx \leq U(fg,P)$$
Now, let's examine $U(fg,P)$.
$$U(fg,P) = \sum_{j = 0}^{n-1} \sup_{x \in [x_j,x_{j+1}]} ((fg)(x)) (x_{j + 1} - x_j) \leq \sum_{j = 0}^{n-1} \sup_{x \in [x_j,x_{j+1}]} (f(x)) * \sup_{x \in [x_j,x_{j+1}]} (g(x)) (x_{j + 1} - x_j)$$
Let $M_j = \sup_{[x_j,x_{j+1}]} (f(x))$ and let $M = \max_{j} (M_j)$. Then,
$$U(fg,P) \leq M \sum_{j = 0}^{n-1} \sup_{x \in [x_j,x_{j+1}]} (g(x)) (x_{j + 1} - x_j) = M U(g,P)$$
A similar thing can be done with the lower sum to get
$$L(fg,P) \geq -ML(g,P)$$
Now, I have
$$-M L(g,P) \leq \int_{a}^{b} (fg)(x) dx \leq MU(g,P)$$
Also, it is quite clear that $$-M L(g,P) \leq L(g,P) \leq \int_{a}^{b} g(x)dx \leq U(g,P) \leq MU(g,P)$$
Now, since $[a,b]$ is closed, and $f$ is continuous, the sup is included in the interval. Therefore, $\exists c \in (a,b)$ so that $f(c) = M$. Then,
$$-L(g,P) \leq \frac{\int_{a}^{b} (fg)(x) dx}{f(c)} \leq U(g,P)$$
Now, I am very close to getting something good here, but I need a positive sign on the left with $L(g,P)$. I am wondering if since $g > 0$, I can say $L(g,P) > 0$. So,
$$-L(g,P) \leq 0 \leq L(g,P)$$. Also, if we instead use the minimum of $f$, which I call $m$, instead of $-M$ in the definition, I would get
$$L(fg,P) = \sum_{j = 0}^{n-1} \inf_{x \in [x_j,x_{j+1}]} ((fg)(x)) (x_{j+1} - x_j) \geq \sum_{j = 0}^{n-1} \inf_{x \in [x_j,x_{j+1}]} (f(x)) * \inf_{x \in [x_j,x_{j+1}]} (g(x)) (x_{j+1} - x_j)$$ $$ \geq m \sum_{j = 0}^{n-1} \inf_{x \in [x_j,x_{j+1}]} (g(x))(x_{j+1} - x_j) = mL(g,P) \geq L(g,P)$$.
In total, $L(fg,P) \geq L(g,P)$, and to make use of this, $f(c) L(fg,P) \geq f(c) L(g,P)$
Therefore, I have the chain
$$-L(g,P) \leq 0 \leq L(g,P) \leq L(fg,P) \leq \frac{\int_{a}^{b} (fg)(x) dx}{f(c)} \leq U(fg,P) \leq U(g,P)$$
What I want to get from this is
$$L(g,P) \leq \frac{\int_{a}^{b} (fg)(x) dx}{f(c)} \leq U(g,P)$$
Because now, we already have $U(g,P) - L(g,P) < \epsilon$ by the integrability of $g$. Therefore, it must be that
$$\frac{\int_{a}^{b} (fg)(x) dx}{f(c)} = \int_{a}^{b} g(x)dx$$
Which after multiplication gives
$$\int_{a}^{b} (fg)(x) dx = f(c) \int_{a}^{b} g(x)dx$$
And that's my attempt. I do agree that the post I linked is much simpler, I am just very curious if this works because this is the proof that jumped out to me and, as I explained earlier, I don't think I would have thought of the other proof if I saw this on an exam. Maybe I would have gotten the compactness part, but on an integration problem, I definitely do not think I would have even considered the extreme value theorem. I know this is long, so I appreciate it if you made it this far! Thank you!
Let $m=\min\{f(x)\mid x\in[a,b]\}$ and $M=\max\{f(x)\mid x\in[a,b]\}$. Note that $m$ and $M$ are well-defined because $f$ is continuous. Choose $x_{m},x_{M}\in[a,b]$ such that $f(x_{m})=m$ and $f(x_{M})=M$. Denote $C=\int_{a}^{b}f(x)g(x)dx.$ Define $\theta:[a,b]\rightarrow\mathbb{R}$ by $\theta(t)=f(t)\cdot\int_{a}^{b}g(x)dx$. Clearly $\theta$ is continuous because it is a continuous function $f$ multiplied by a constant. Let $x\in[a,b]$ be arbitrary. Observe that $mg(x)\leq f(x)g(x)\leq Mg(x)$ because $g(x)>0$ (actually, it suffices that $g(x)\geq0$ for all $x\in[a,b]$). Therefore, $$ \int_{a}^{b}mg(x)dx\leq\int_{a}^{b}f(x)g(x)dx\leq\int_{a}^{b}Mg(x)dx. $$ That is, $$ \theta(x_{m})\leq C\leq\theta(x_{M}). $$ By Intermediate Value Theorem, there exists $c$ between $x_{m}$ and $x_{M}$ such that $\theta(c)=C$. That is, $\int_{a}^{b}f(x)g(x)dx=f(c)\cdot\int_{a}^{b}g(x)dx$.
Remark: In the above, the theorem still holds if the condition is modified to $g(x)\leq0$ for all $x\in[a,b]$.