How would I integrate the following by parts:

Integral of: (x^2)(sin (ax))dx, where a is any constant.

Just like you did x^2 exp(x) below.

Also partial integration is not the easiest way to do this integral. You can also use this method.

Evaluate first:

integral of sin(ax)dx = -1/a cos(ax)

Differentiate both sides twice w.r.t. the parameter a.