# A question about derivation of Fourier coefficients [duplicate]

As the textbook said:

Trigonometrical polynomials \begin{align} f(x)=\frac{a_0}{2} + \sum_{v=1}^{n}(a_v\cos{vx}+b_v\sin{vx}) \tag{1} \end{align} The Fourier coefficients can be expressed simply by the following formulas: $$a_u=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\cos{ux}\,dx, {\ } b_u=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\sin{ux}\,dx. \tag{2}$$ The proof follows if we multiply Eq. (1) by $$\cos{ux}$$ or $$\sin{ux}$$ and then integrate.

///////////////////////////////////////////////////////////////////////

My derivation:

\begin{align} \cos{ux}\,f(x) & = \frac{a_0}{2} \cos{ux} + \sum_{v=1}^{n}(a_v\cos{vx} \cos{ux} +b_v\sin{vx} \cos{ux}) \\ \int_{-\pi}^{\pi}\cos{ux}\,f(x)\,dx & = \frac{a_0}{2} \int_{-\pi}^{\pi} \cos{ux}\,dx \\ & \phantom{={}} + \sum_{v=1}^{n}\left(a_v \int_{-\pi}^{\pi}\cos{vx} \cos{ux}\,dx +b_v \int_{-\pi}^{\pi}\sin{vx} \cos{ux}\,dx\right) \end{align} According to the orthogonality relations of the trigonometric functions, we get:

\begin{align} & \int_{-\pi}^{\pi} \cos{ux}\,dx =0, \\ & \int_{-\pi}^{\pi}\cos{vx} \cos{ux}\,dx = \pi, \quad \text{if } u=v, \\ & \int_{-\pi}^{\pi}\sin{vx} \cos{ux}\,dx =0. \end{align} So, if $$u=v$$ \begin{align} \int_{-\pi}^{\pi}\cos{ux}\,f(x)\,dx & = \sum_{v=1}^{n} a_v \int_{-\pi}^{\pi}\cos{vx} \cos{ux}\,dx = \sum_{v=1}^{n} a_v \pi \end{align} I can’t get the Eq. (2), where’s the mistake? Thanks.

my question's unique part is, derivate this equation: \begin{align} \sum_{v=1}^{n} a_v \int_{-\pi}^{\pi}\cos{vx} \cos{ux}\,dx = a_v \pi \end{align} and it was solved by @Ak19.

• Except at $v=u$, the sum is $0$ . So on the RHS you'll simply have $a_v\pi=a_u\pi$ – Ak. Aug 12 '19 at 15:16
• As I mentioned in the comment, $$\sum_{v=1}^na_v\int_{-\pi}^{\pi}\cos vx \cos ux \ dx = a_1\int_{-\pi}^{\pi}\cos x \cos ux \ dx+a_v\int_{-\pi}^{\pi}\cos 2x \cos ux \ dx+\cdots +\\a_u\int_{-\pi}^{\pi}\cos ux \cos ux \ dx+\cdots+ a_n\int_{-\pi}^{\pi}\cos nx \cos ux \ dx\\=a_1\cdot0 +a_2\cdot0+\cdots a_u\cdot\pi+\cdots a_n\cdot0 = a_u\pi$$ So, $$a_u\pi = \int_{-\pi}^{\pi}f(x)\cos(ux)dx \implies a_u =\frac1\pi\int_{-\pi}^{\pi}f(x)\cos(ux)dx$$ – Ak. Aug 12 '19 at 15:29
• @Ak19 I got it, thank you very much. – mathisbeauty Aug 12 '19 at 16:14
• @Shogun no, my question is just for my “cancel-out” step, it’s specific. – mathisbeauty Aug 12 '19 at 16:54

To generalize, the derivation is easier if you prove it for a complex variable; i.e: $$c_n = \frac{1}{2\pi}\int_{-\pi}^{\pi}f(x)e^{-inx}dx:n\in\mathbb{Z}$$

where the Fourier expansion is of the form $$f(x)=\sum_{n\in\mathbb{Z}}c_n e^{inx}$$.

for $$f:\mathbb{R}\rightarrow\mathbb{C}$$; simply consider $$\mathbb{R}$$ as a subset of $$\mathbb{C}$$ and you can use this method for $$f:\mathbb{R}\rightarrow\mathbb{R}$$.

Proof:

Fix $$m\in\mathbb{Z}$$. Consider the integral:

$$\int_{-\pi}^{\pi}f(x)e^{-imx}dx=\int_{-\pi}^{\pi}\sum_{n\in\mathbb{Z}}c_n e^{inx}e^{-imx}dx$$ $$=\sum_{n\in\mathbb{Z}}\int_{-\pi}^{\pi}c_n e^{inx}e^{-imx}dx.$$

Clearly if there is any residual exponential term, integrating that term from $$-\pi$$ to $$\pi$$ will yield $$0$$, regardless of the magnitude of the coefficient of that term, as any exponential term refers simply to a rotation, which will be the same at $$-\pi$$ and $$\pi$$. We have: $$=\cdots+0+\int_{-\pi}^{\pi}c_n dx + 0 + \cdots$$ $$=2\pi c_n,$$

divide by $$2\pi$$ to find $$c_n$$.

This proof comes with a nice visualization with epicycles: see here.

There's no mistake in your proof; you just need the last 'canceling-out' step.

• Thank you very much. – mathisbeauty Aug 12 '19 at 16:19