Integral Inequality There is a problem in my book that says:
Show that (assuming $f,g,f^2, g^2, $and$ fg$ are integrable) $$\int_{a}^{b}fg\leq \sqrt{\int_{a}^{b}f^2}\sqrt{\int_{a}^{b}g^2}$$.  I know this is the Cauchy-Shwarz Inequality for integrals, but my book says to prove it by defining $$p(\lambda)=\int_{a}^{b}[f-\lambda g]^2$$ for each real number $\lambda$, and then show that $p(\lambda)$ is a quadratic polynomial for which $p(\lambda)\geq0$, for all $\lambda$, and thus the discriminant is not positive. How does this help?

Since $p(\lambda)$ is the integral of a square, it is non-negative:
$$
\begin{align}
0
&\le p(\lambda)\\
&=\int f(x)^2\,\mathrm{d}x-2\lambda\int f(x)g(x)\,\mathrm{d}x+\lambda^2\int g(x)^2\,\mathrm{d}x\\
\end{align}
$$
Therefore, for $\lambda\gt0$,
$$
\int f(x)g(x)\,\mathrm{d}x
\le\frac1{2\lambda}\int f(x)^2\,\mathrm{d}x+\frac\lambda2\int g(x)^2\,\mathrm{d}x
$$
If we set $\lambda=\sqrt{\frac{\int f(x)^2\,\mathrm{d}x}{\int g(x)^2\,\mathrm{d}x}}$, we get
$$
\int f(x)g(x)\,\mathrm{d}x
\le\sqrt{\int f(x)^2\,\mathrm{d}x}\sqrt{\int g(x)^2\,\mathrm{d}x}
$$
