i am learning fourier series and i am stuck on an integral.
So i am looking for $$a_n={1\over\pi}\int_0^{2\pi} f(x)\cos(nx)\ dx ={1\over\pi}\int_0^{2\pi} \frac{( \pi-x)^2}{4}\cos(nx)\ dx$$
$$={1\over4\pi}\int_0^{2\pi} ( \pi-x)^2\cos(nx)\ dx$$
I know that the answer is $ \frac{1}{n^2}$ but would really like someone to show me and explain a simple way of working this out as i am going to have exam questions like this and so assuming there must be a simple way of working this out..
Many thanks
We have an integral of a product of a polynomial and a sine/cosine. That is something we can fruitfully apply integration by parts to, the trigonometric functions switch between sine and cosine, and differentiating reduces the degree of the polynomial, until after finitely many steps, we reach a constant and are left with a pure integral over a sine or cosine. Let's ignore the constant factor, and just integrate:
$$\begin{align} \int_0^{2\pi} (x-\pi)^2\cos (nx)\,dx &= \left[(x-\pi)^2\frac{\sin (nx)}{n} \right]_0^{2\pi} - \frac2n \int_0^{2\pi} (x-\pi)\sin (nx)\,dx\\ &= \frac2n \int_0^{2\pi} (x-\pi)(-\sin (nx))\,dx\\ &= 2\left[(x-\pi)\frac{\cos (nx)}{n^2}\right]_0^{2\pi} - \frac{2}{n^2}\int_0^{2\pi} \cos (nx)\,dx\\ &= 2\left[\pi\frac{\cos (2n\pi)}{n^2} - (-\pi)\frac{\cos 0}{n^2}\right] - \frac{2}{n^2}\int_0^{2\pi} \cos (nx)\,dx\\ &= \frac{4\pi}{n^2} - \frac{2}{n^2}\int_0^{2\pi}\cos (nx)\,dx\\ &= \frac{4\pi}{n^2} - \left[\frac{2}{n^3}\sin (nx)\right]_0^{2\pi}\\ &= \frac{4\pi}{n^2}. \end{align}$$