Today I was trying to solve an integral for a Fourier series. I looked at the solution and this was the solution:
\begin{align*} C_n &= \frac{1}{2\pi} \int_0^{2\pi} x^2 e^{-inx} \,\text{d}x \\ \xrightarrow{\text{integration by parts}} C_n &= \frac{1}{2\pi} \left[ - \frac{x^2 e^{-inx}}{in} - \frac{2 x e^{-inx}}{-n^2} - \frac{2 e^{-inx}}{-in^2} \right]^{2\pi}_0 \\ &= \frac{1}{2\pi} \left[ \frac{4 i \pi^2}{n} + \frac{4 \pi}{n^2} \right] \end{align*}
I know how they solved it but cannot get how this part $$ C_n = \frac{1}{2\pi} \left[ - \frac{x^2 e^{-inx}}{in} - \frac{2 x e^{-inx}}{-n^2} - \frac{2 e^{-inx}}{-in^2} \right]^{2\pi}_0 $$ becomes this: $$ \frac{1}{2\pi} \left[ \frac{4 i \pi^2}{n} + \frac{4 \pi}{n^2} \right]. $$ Would you please clear it to me?
Thanks in advance
I will leave away the factor $\frac{1}{2\pi}$. Plug in to obtain $$\left.\left(-\frac{x^2 e^{-inx}}{in} - \frac{2x e^{-inx}}{-n^2}-\frac{2e^{-inx}}{-in^2}\right)\right|_{x=0}^{2 \pi} = \left(-\frac{(2 \pi)^2 e^{-2in \pi}}{in} - \frac{2(2\pi) e^{-2in\pi}}{-n^2}-\frac{2e^{-2in\pi}}{-in^2}\right)-\left(-\frac{2}{-in^2}\right).$$
Recall that $e^{2 i \pi n} = 1$ for all $n \in \mathbb{Z}$, and in this context clearly $n \in \mathbb{Z}$. Therefore, the expression becomes
$$-\frac{4 \pi^2}{in}-\frac{4 \pi}{-n^2}-\frac{2}{-in^2}+\frac{2}{-in^2}.$$
Multiply the two fractions which still have an $i$ in the denominator by $\frac{i}{i}$ to get $$-\frac{4 i\pi^2}{-n} - \frac{4 \pi}{-n^2}-\frac{2i}{n^2} + \frac{2i}{n^2}$$ which of course you can simplify to end up with the desired $$\frac{4i \pi^2 }{n}+\frac{4 \pi}{n^2}.$$