# Fourier Series solution giving wrong answer

How this answer came by solving "$a_n$" of Fourier series.

$$a_n=\int_{-1}^1 t^2 \cos (n\pi t) dt = 4(-1)^n / (\pi n)^2$$

?

$$2 \sin n\pi (t^2/n\pi - 2/(n\pi)^2)$$

How can I derive the above mentioned answer

-
What if I replace cos(nπt) in the question with sin(nπt)? What will be the answer than – Umer Farooq Nov 1 '12 at 12:51
You don't say how you get your answer, but, given that the integral is a definite integral, there shouldn't be a $t$ in the result – Thomas Andrews Nov 1 '12 at 13:01

$$a_n=\int_{-1}^1 t^2 \cos (n\pi t) dt = 2\,{\frac {-2\,\sin \left( n\pi \right) +{n}^{2}{\pi }^{2}\sin\left( n\pi \right) +2\,n\pi \,\cos \left( n\pi \right) }{{\pi }^{3 }{n}^{3}}}\,.$$

Now, since $n$ is a positive integer, then you can see that $\sin(n\pi)=0$ and $\cos(n\pi)=(-1)^n$. So, the above answer reduces to

$$a_n = 4(-1)^n / (\pi n)^2\,.$$

-

Well, remember that $\sin(n\pi)=0$ for all integers $n$, so that is a clear indicator that your answer is not correct. Besides, you have $t^2$ in your expression, which does not make sense since it is the integration variable in a definite integral.

I will guide you part of the way to get you going. We have to perform two partial integrations to get rid of $t^2$. To start off, we have the integral

$a_n=\int_{-1}^1 t^2 \cos(n\pi t)dt=[\frac{1}{n\pi}\sin(n\pi t) t^2]_{-1}^1-\frac{2}{n\pi}\int_{-1}^1 t\sin(n\pi t)dt$

Now, the bracket is zero (Why?). Thus, we get

$[\frac{-2}{n^2\pi^2}\cos(n\pi t)t]_{-1}^1+\frac{2}{n^2\pi^2}\int_{-1}^1 \cos(n\pi t)dt$

Can you derive the answer now?

-
Why is the first bracket = 0 and the second one is not? Even when both the brackets contain sin(nπt) – Umer Farooq Nov 1 '12 at 12:22
$$\left.t\cos n\pi t\right|_{-1}^1=\cos n\pi-(-1)\cos(-n\pi )=\cos n\pi+\cos n\pi=2\cos n\pi =\pm 2\neq 0$$ so why do you say the second time that the bracket is zero? Of course, I could have made a mistake... – DonAntonio Nov 1 '12 at 12:25
No, I was too hasty. I removed that comment. Thank you for pointing it out. – Espen Nielsen Nov 1 '12 at 12:28
Ok I finally got it. But one thing is still bugging me. Why did you put integral limit in t even when t wasn't the part of Sin nπt. That t was the result of derivative of t^2 – Umer Farooq Nov 1 '12 at 12:42
@espen180 , I still don't understand what are you referring to with that sum of integrals at the end of your answer...?? – DonAntonio Nov 1 '12 at 12:46

By parts:

$$u=t^2\,\,,\,u'=2t\;\;\;,\;\;v'=\cos n\pi t\,\,,\,v=\frac{1}{n\pi}\sin n\pi t\Longrightarrow$$

$$a_n=\int_{-1}^1 t^2\cos n\pi t\,dt=\left.\frac{t^2\sin n\pi t}{n\pi}\right|_{-1}^1-\frac{2}{n\pi}\int_{-1}^1\,t\sin n\pi t\,dt$$

The first summand in the RHS is zero, and for the integral we do again parts:

$$u=t\,\,,\,u'=1\;\;\;,\;\;v'=\sin n\pi t\,\,,\,v=-\frac{1}{n\pi}\cos n\pi t\Longrightarrow$$

$$-\frac{2}{n\pi}\int_{-1}^1\,t\sin n\pi t\,dt=\left.\frac{2}{n^2\pi^2}t\cos n\pi t\right|_{-1}^1-\frac{2}{n^2\pi^2}\int_{-1}^1\cos n\pi t\,dt$$

Since now you'll get $\,\sin n\pi t\,$ in the solution of the second integral above, it's easy to see it equals zero, so we finally get (see my comment above):

$$\left.\frac{2}{n^2\pi^2}t\cos n\pi t\right|_{-1}^1=\left\{\begin{array} \,\;\;\;\frac{4}{n^2\pi^2}&\,,\text{ if}\,\,n\,\,\text{ is even}\\{}\\-\frac{4}{n^2\pi^2}&\,,\text{ if}\,\,n\,\,\text{ is odd}\end{array}\right.$$

Which is exactly what you have.

-