# Fastest method to calculate the integral: $\int^\pi_0 t^2 \cos(nt) dt$

Fastest method to calculate the integral: $\int^\pi_0 t^2 \cos(nt)dt$.

Now I am aware that this is done by doing parts twice, however from inspection I see that terms cancel in the method, is there therefore a straight forward formula I can use for integrals of this form (ie period/composition) which would allow me to calculate this faster?

Kind Regards,

• My edition of Rottmann's mathematical formulas says $$\int t^2\cos(nt)dt = \frac2{n^2}t\cos(nt) - \frac{2-n^2t^2}{a^3}\sin(nt) + C$$ Now you can just insert the limits and calculate. – Arthur Dec 3 '16 at 15:56
• observe that $\partial^2_n \cos(n t)=-t^2\cos(n t)$ – tired Dec 3 '16 at 16:21

Hint. One may start with $$\int_0^\pi e^{(a+in)t}dt=\left[\frac{e^{(a+in)t}}{a+in}\right]_0^\pi=\frac{e^{(a+in)\pi}-1}{a+in},\qquad a,n\in \mathbb{R}^2,\, an\neq0,$$ then one may differentiate twice with respect to $a$ and take $a=0$ in the real part of each side.
$$I(n) = -\int_0^\pi \cos (nt) \,dt = -\left[\frac{\sin(nt)}{n}\right]_0^\pi = -\frac{\sin(n\pi)}{n}$$
and take the derivative with respect to $n$ twice to get
$$I''(n) = \int_0^\pi t^2 \cos (nt) \,dt = \frac{n^2\pi^2 \sin(n\pi) + 2n\pi\cos(n\pi) - 2\sin(n\pi)}{n^3}$$