Given that $f(x) = x^2$,
$$f(x) \sim \frac{a_0}{2}+\sum_{n=1}^\infty\bigl(a_n \cos(nx)+b_n \sin(nx)\bigr)$$
on the interval $[\pi,3\pi]$.
I need to find $a_n$ and $b_n$; I just want to check that I am correct in saying that
$$a_n = \frac{1}{\pi} \int_\pi^{3\pi} x^2\cos(nx)\,\mathrm{d}x,$$
$$b_n = \frac{1}{\pi} \int_\pi^{3\pi} x^2\sin(nx)\,\mathrm{d}x.$$
From there, I would just need to evaluate the integrals using integration by parts.
Any help is much appreciated.
You are indeed correct, and using integration by parts to compute the integrals is a good way to go.