I'm successively integrating $x^{n} \cos{k x}$ for increasing values of positive integer n. I'm finding:
$\frac{\sin{kx}}{k}$,
$\frac{\cos{kx}}{k^2}+\frac{x\sin{kx}}{k}$,
$\frac{2 x \cos{kx}}{k^2}+\frac{\left(-2+k^2 x^2\right)sin{kx}}{k^3}$,
$\frac{3 \left(-2+k^2 x^2\right) \cos{kx}}{k^4}+\frac{x \left(-6+k^2 x^2\right) \sin(kx)}{k^3}$
Is there a name for the sequence of polynomials: $x$, $2x$, $k^2x^2-2$, $3(k^2x^2-2)$, $x(k^2x^2-6)$ ... ?
Here is more:
$\frac{\sin{kx}}{k}$
$\frac{\cos{kx}}{k^2}+\frac{x \sin{kx}}{k}$
$\frac{2 x \cos{kx}}{k^2}+\frac{\left(-2+k^2 x^2\right) \sin{kx}}{k^3}$
$\frac{3 \left(-2+k^2 x^2\right) \cos{kx}}{k^4}+\frac{x \left(-6+k^2 x^2\right) \sin{kx}}{k^3}$
$\frac{4 x \left(-6+k^2 x^2\right) \cos{kx}}{k^4}+\frac{\left(24-12 k^2 x^2+k^4 x^4\right) \sin{kx}}{k^5}$
$\frac{5 \left(24-12 k^2 x^2+k^4 x^4\right) \cos{kx}}{k^6}+\frac{x \left(120-20 k^2 x^2+k^4 x^4\right) \sin{kx}}{k^5}$
$\frac{6 x \left(120-20 k^2 x^2+k^4 x^4\right) \cos{kx}}{k^6}+\frac{\left(-720+360 k^2 x^2-30 k^4 x^4+k^6 x^6\right) \sin{kx}}{k^7}$
The polynomials are recursive in nature, and this behavior is most apparent when the given integral
$$ \int x^n \cos(k x)\,dx $$
is viewed as the real part of the function
$$ F_{n,k}(x) = \int x^n e^{i k x}\,dx = \int x^n \cos(k x)\,dx + i\!\int x^n \sin(k x)\,dx. $$
Using integration by parts twice we can derive an inhomogeneous recurrence relation for these functions,
$$ k^2 F_{n,k}(x) - i k (n-1) F_{n-1,k}(x) + (n-1) F_{n-2,k}(x) = e^{i k x}\left(x^{n-1}-i k x^n\right). \tag{1} $$
Here we can define the polynomials
$$ P_{n,k}(x) = k^{n+1} e^{-i k x} F_{n,k}(x), $$
and then use $(1)$ to derive their recurrence relation
$$ P_{n,k}(x) - i (n-1) P_{n-1,k}(x) + (n-1) P_{n-2,k}(x) = (kx)^{n-1} - i (kx)^n. \tag{2} $$
Now, if we write
$$ k^{n+1} \int x^n \cos(k x)\,dx = A_{n,k}(x) \cos(kx) - B_{n,k}(x) \sin(kx), $$
where $A_{n,k}(x)$ and $B_{n,k}(x)$ are polynomials, we have
$$ A_{n,k}(x) = \operatorname{Re} P_{n,k}(x) \qquad \text{and} \qquad B_{n,k}(x) = \operatorname{Im}\, P_{n,k}(x). $$
The first few polynomials $P_{n,k}(x)$ are
$$ \begin{align} P_{1,k}(x) &= 1-i k x \\ P_{2,k}(x) &= 2 i+2 k x-i k^2 x^2 \\ P_{3,k}(x) &= -6+6 i k x+3 k^2 x^2-i k^3 x^3 \\ P_{4,k}(x) &= -24 i-24 k x+12 i k^2 x^2+4 k^3 x^3-i k^4 x^4 \\ P_{5,k}(x) &= 120-120 i k x-60 k^2 x^2+20 i k^3 x^3+5 k^4 x^4-i k^5 x^5 \\ P_{6,k}(x) &= 720 i+720 k x-360 i k^2 x^2-120 k^3 x^3+30 i k^4 x^4+6 k^5 x^5-i k^6 x^6 \\ P_{7,k}(x) &= -5040+5040 i k x+2520 k^2 x^2-840 i k^3 x^3-210 k^4 x^4+42 i k^5 x^5+7 k^6 x^6-i k^7 x^7 \end{align} $$