# If $\int_0^{\pi}f(x)\cos(nx)\,dx=0$ for all $n$ then prove that $f\equiv 0$

If $f:[0,\pi]\to \mathbb R$ is continuous and $f(0)=0$ such that $\displaystyle \int_0^{\pi}f(x)\cos(nx)\,dx=0$ for all $n=0,1,2,\cdots$ then prove that $f\equiv 0$ in $[0,\pi]$.

I want to apply Weierstrass approximation theorem. As $f$ is continuous so there exists a sequence of polynomials $\{p_n(x)\}$ such that $p_n(x)\to f$ uniformly. If I expand $\cos nx=1+\frac{n^2x^2}{2!}+\cdots$ then $$\int_0^{\pi}f(x)\,dx+\frac{n^2}{2!}\int_0^{\pi}x^2f(x)\,dx+\cdots=0.$$which implies $\displaystyle \int_0^{\pi}x^{2n}f(x)\,dx=0$ for each $n=0,1,2,\cdots$. Is this step correct ? If yes then I can deduce from it that $f\equiv 0$. If I am Not correct then solve it please.

• What is the Fourier series for $f$ on $[0,\pi]$? Nov 5, 2015 at 5:24
• In your approach, the integrals $\int_0^{\pi} f(x)x^{2n}\,dx$ need not be zero since $f$ is not restricted to be non-negative. Nov 5, 2015 at 5:30
• $\int_0^{\pi}\cos nxf(x)\,dx=0$ should be retyped.
– zhw.
Nov 5, 2015 at 7:50

Extend $f$ to be even on $[-\pi,\pi].$ We then have

$$\hat f (n) = \frac{1}{2\pi}\int_{-\pi}^\pi f(x)e^{-inx}\,dx = \frac{1}{\pi}\int_{0}^\pi f(x)\cos (nx)\,dx = 0$$

for all $n\in \mathbb {Z}.$ Thus $$\frac{1}{2\pi}\int_{-\pi}^\pi|f|^2 = \sum |\hat f (n)|^2 = 0.$$

This implies $f\equiv 0.$ I did not use the condition $f(0)=0,$ which makes me think the problem should have been stated assuming $\int_0^\pi f(x)\sin (nx)\, dx =0, n=1,2,\dots.$

• You need zeroth fourier coefficient vanishes and thats where u used f vanishes at zero.
– Ben
Nov 5, 2015 at 14:03
• The $f(0)=0$ assumption is not necessary. Nov 5, 2015 at 14:06
• Sorry to resurrect an old post, but I think that the assumption $f(0) = 0$ is necessary. I didn't notice it when I read the post initially, and I couldn't understand why no one had pointed out that $f(x) = 1$ for all $x$ satisfies $$\int_0^\pi f(x) \cos(nx) dx = \int_0^\pi \cos(nx) dx = \frac{1}{n}[\sin(nx)]_{x=0}^{x=\pi} = 0-0=0.$$ But $f(x) = 1$ for all $x$ certainly doesn't satisfy $f(0) = 0$! Nov 28, 2015 at 18:52
• Your displayed equation fails when $n=0.$
– zhw.
Nov 28, 2015 at 18:56
• @jhw)) Why we need to use Persavals identity ? As we extend $f$ to $\hat f$ and we find that $\hat f=0$ then we can conclude $f \equiv 0$. Isn't it ? Aug 22, 2016 at 4:56

You can extend $f$ to $g$ on $[-\pi,\pi]$, s.t. $g(x)=f(-x)$ if $x<0$. Then $\hat{g}(n)=\frac{1}{\pi}\int_0^\pi f(x)cos(nx)dx=0$ for all $n$. By Parseval's identity, $\int |g|^2=0$ which implies $f=0$.

• Seems to me you would want to extend $f$ to be even.
– zhw.
Nov 5, 2015 at 7:56
• Yes. You are right .Otherwise, I cant get rid of the sine term.
– Ben
Nov 5, 2015 at 14:00
• @Ben)) Why we need to use Persavals identity ? As we extend $f$ to $\hat f$ and we find that $\hat f=0$ then we can conclude $f \equiv 0$. Isn't it ? Aug 22, 2016 at 4:57

(Complete revamp of my previous answer.)

Extend $f$ by $f(x) = f(-x)$ for $x \in [-\pi,0)$, then $f$ is $2\pi$ periodic and so for any $\epsilon>0$ there is a trigonometric polynomial $q$ such that $\|f-q\|_\infty = \sup_{|x|\le \pi} |f(x)-q(x)| < \epsilon$. (Recall that a trigonometric polynomial is of the form $q(t) = a_0+\sum_{k=1}^n (a_k \cos(kt) + b_k \sin (kt))$). (See, for example, Rudin's "Real & Complex Analysis", Theorem 4.25.)

Let $\tilde{q}(t) = {1 \over 2} (q(t)+q(-t))$ and note that $\|f-\tilde{q}\|_\infty \le {1 \over 2} (\|f-q\|+ \|f-q\|) < \epsilon$ (where we used evenness of $f$ for the last part). Hence we may assume that $q$ is even to begin with, in particular, $q$ has the form $q(t) = a_0+\sum_{k=1}^n a_k \cos(kt) = \sum_{k=0}^n a_k \cos(kt)$.

Note that, by assumption, $\int_{-\pi}^\pi f(x) q(x) dx = 0$.

Then $\int_{-\pi}^\pi f^2(x) dx = \int_{-\pi}^\pi f(x) (f(x)-q(x)+ q(x)) dx = \int_{-\pi}^\pi f(x) (f(x)-q(x)) dx$, hence $\int_{-\pi}^\pi f^2(x) dx \le \|f\|_\infty 2 \pi \epsilon$. Since $\epsilon>0$ was arbitrary, we see that $\int_{-\pi}^\pi f^2(x) dx = 0$. Since $f$ is continuous, and $f^2(x) \ge 0$ for all $x$ we see that $f(x) = 0$ for all $x$.

• What theorem did you use to have your convergence of $s_n$? Nov 5, 2015 at 14:27
• @user281591: Good question; I used the Riesz Fischer theorem and suspect there might be some circularity in my argument. Let me think about this for a while. Nov 5, 2015 at 15:57
• @user281591: I changed my answer. My original answer was OK, but to justify the $L^2$ convergence of the $s_n$ I needed to use density of the trigonometric polynomials in the continuous functions on the circle using the $\sup$ norm, so it was easier to prove it, using the density result, in a slightly different way. Nov 6, 2015 at 4:27
• thanks for clarifying your answer, I like this proof. +1 Nov 6, 2015 at 15:10