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,

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.
