# indefinite integral of $x^n\sin(x)$

In school we have just started with integration by parts. We had examples like $∫x\sin(x)\,dx$ or $∫x^2\sin(x)\,dx$ I asked myself if it is possible to integrate terms like $∫x^{25}\sin(x)\,dx$ without doing integration by parts 25 times. I can't tell how exactly I did it, but I integrated some explicit terms and created this: $$\int x^n\sin x\,dx=\sum_{k=0}^{\lfloor n/2\rfloor}(-1)^{k+1}x^{n-2k}{n!\over(n-2k)!}\cos x+\sum_{k=0}^{\lfloor(n-1)/2\rfloor}(-1)^kx^{n-2k-1}{n!\over(n-2k-1)!}\sin x$$

with $n\in \Bbb N$.

I tested it a few times and I think that it is correct, but I don't have any idea how to prove it. How can I do that?

-
If an integration formula is correct, you can prove it by differentiating. – Gerry Myerson Nov 5 '12 at 22:57
I took the liberty to type in your formula in LaTeX. Check if I haven't made some mistakes. Also, if anyone has a better idea how to type it in in terms of formatting, feel free to do so (is there a good way to type in formulae as long as this?). – tomasz Nov 5 '12 at 23:24
Alternatively, are you familiar with proof by mathematical induction? You could try to prove it by induction on $n$. – Gerry Myerson Nov 5 '12 at 23:31
Nice job, Gunnar. I think you are a future mathematician. – Grumpy Parsnip Nov 5 '12 at 23:35
Those interested in this question should see also math.stackexchange.com/questions/231100/… – Gerry Myerson Nov 6 '12 at 5:16

How about $$\begin{eqnarray} c_n &=& a_n + i b_n = \int dx \ x^n e^{i x} = \int dx \ x^n \sin x + i \int dx \ x^n \cos x \\ &=& - i\int dx \ \left[\frac{d}{dx}\left(x^n e^{i x}\right) - n x^{n-1} e^{i x}\right] \\ &=& - i \left(x^n e^{i x} - n c_{n - 1}\right) \end{eqnarray}$$ where $a_n = {\mathcal{Re}} \left(c_n\right)$, $b_n = {\mathcal{Im}} \left(c_n\right)$, and there is a constant term added for each $c_n$. Presumably you could express this in terms of a sum that, hopefully, would agree with your result.