Suppose that \(f\in C^1([0,\pi])\) and \(f(0)=f(\pi)=0\). Prove that \[ \int_0^\pi f(x)^2\,dx\le\int_0^\pi f'(x)^2\,dx. \]
Solution
For \(0<\varepsilon<\pi/2\), expand the nonnegative integral \[ 0\le \int_\varepsilon^{\pi-\varepsilon} \bigl(f'(x)-f(x)\cot x\bigr)^2\,dx. \] We have \[ \begin{aligned} \int_\varepsilon^{\pi-\varepsilon} \bigl(f'-f\cot x\bigr)^2 &=\int_\varepsilon^{\pi-\varepsilon}(f')^2 +\int_\varepsilon^{\pi-\varepsilon}f^2\cot^2x -\int_\varepsilon^{\pi-\varepsilon}(f^2)'\cot x\\ &=\int_\varepsilon^{\pi-\varepsilon}(f')^2 -\int_\varepsilon^{\pi-\varepsilon}f^2 -\bigl[f(x)^2\cot x\bigr]_{\varepsilon}^{\pi-\varepsilon}, \end{aligned} \] because \((\cot x)'=-\csc^2x\) and \(\cot^2x-\csc^2x=-1\).
It remains to pass to the endpoints. Since \(f\in C^1\) and \(f(0)=0\), \[ f(x)=O(x)\qquad(x\downarrow0), \] so \(f(x)^2\cot x=O(x)\to0\). Similarly, \(f(x)^2\cot x\to0\) as \(x\uparrow\pi\). Therefore, letting \(\varepsilon\downarrow0\) gives \[ 0\le\int_0^\pi (f')^2-\int_0^\pi f^2. \] Hence \[ \boxed{\int_0^\pi f^2\le\int_0^\pi(f')^2}. \] Equality holds, for example, for scalar multiples of \(\sin x\), so the constant is sharp.