Schwarz Inequality for Riemann-integrable I want to show the Schwarz inequality,
$$
\left(\int_Qfg\right)^2\le\int_Qf^2\int_Qg^2,
$$
for Riemann-integrable functions $f:Q\subset\mathbb{R}^n\to\mathbb{R}$, where $Q$ is a rectangle.
But in the case where $\int_Qf^2 = 0$ I'm not seeing how to get $\int_Qfg=0$ from it. I have seen this question but I don't know what norm they're using and really didn't understand the inequality proposed in the first answer.
 A: Some notation: for any function $\phi:Q \to \Bbb{R}$, let's define the set $Z_{\phi} := \{x \in Q| \, \phi(x) \neq 0\}$. Here is a definition, and a few theorems:

Definition/Theorem
A set $Z \subset \Bbb{R}^n$ is said to have ($n$-dimensional Lebesgue) measure zero if for every $\epsilon > 0$, there is a countable collection $\{R_k\}_{k=1}^{\infty}$ of rectangles such that
\begin{align}
Z \subset \bigcup_{k=1}^{\infty}R_k \qquad \text{and} \qquad \sum_{k=1}^{\infty}\text{vol}(R_k) < \epsilon
\end{align}
Here, we define the volume of a rectangle in the obvious manner. One can prove it doesn't matter whether the rectangles in this definition are open or closed. It is also easy to prove that if $Z$ has measure zero, then for every subset $X\subset Z$, $X$ has measure zero.

Now, we have two theorems

Theorem $1$.
Let $Q \subset \Bbb{R}^n$ be a closed rectangle, and $\phi: Q \to \Bbb{R}$ be a Riemann-integrable function. If $Z_{\phi}$ has measure zero, then $\int_Q \phi = 0$.
Theorem $2$.
Let $Q \subset \Bbb{R}^n$ be a closed rectangle, and $\phi: Q \to \Bbb{R}$ be a Riemann-integrable, non-negative function. If $\int_Q \phi = 0$ then $Z_{\phi}$ has measure zero.

If I recall correctly, in Analysis on Manifolds, Munkres gives a pretty nice and quick proof of these facts using the equivalent characterization of Riemann-integrability (a bounded function on a rectangle is Riemann-integrable if and only if the set of discontinuities has measure zero)

Now, for your actual question. Suppose $\int_Q f^2 = 0$. Since $f^2$ is a non-negative, Riemann integrable function whose integral vanishes, theorem $2$ implies that set $Z_{f^2}$ has  measure zero. Next, it is easily verified that $ Z_{fg} \subset Z_f = Z_{f^2}$; hence $Z_{fg}$ has measure zero. By theorem $1$, it follows that
\begin{align}
\int_Q fg &= 0.
\end{align}
Hence, we have an equality in the Cauchy-Schwarz inequality.

Edit:
Having taken a look at the answer in the link, I realized the issue is much simpler. It all boils down to the following simple lemma:

Let $a,b,c \in \Bbb{R}$, and consider the polynomial $p(x) = ax^2 + bx + c$. If for every $x \in \Bbb{R}$, we have $p(x) \geq 0$ (or for all $x \in \Bbb{R}$, $p(x) \leq 0$), then
\begin{align}
b^2 - 4ac \leq 0.
\end{align}

Note that if $a \neq 0$, this follows by a simple application of completeing the square: write $p(x) = a\left( x + \frac{b}{2a}\right)^2 - \frac{b^2 - 4ac}{4a}$, and from here, manipulate inequalities (there's like a few cases, but they're all easy to prove).
If $a = 0$, then we have $p(x) = bx + c$; but if $p(x)$ maintains a constant sign, then we must have $b=0$ (simply sketch the graph of $p(x)$ with $b \neq 0$ to convince yourself). Since $b=0$, and $a=0$, we of course have $b^2 - 4ac = 0 \leq 0$.
Now, we apply this simple lemma to our present situation. Consider the following polynomial in $\lambda$:
\begin{align}
p(\lambda) := \int_Q (\lambda f- g)^2 =  \left(\int_Q f^2\right) \lambda^2  + \left(-2 \int_Q fg\right) \lambda + \int_Q g^2 
\end{align}
Since $p(\lambda)$ was obtained by integrating a non-negative function, we clearly have that for every $\lambda \in \Bbb{R}$, we have $p(\lambda) \geq 0$.
Now, identify what $a,b,c$ are, and then you immediately find that $b^2 - 4 ac \leq 0$ implies the Cauchy-Schwarz inequality.
Finally, of course, if you wish to find out what the equality cases are, simply trace through the derivation above, and see when we can replace the $\leq$ with $=$. This I leave to you $\ddot{\smile}$.
