Question: Undoubtedly, this question is so easy but I'd like to ask it. We know that the way in which the indefinite integrals like $\int P(x)e^{ax}dx$ and $\int P(x)\sin(bx)dx$ wherein $P(x)$ is an arbitrary polynomial of $x$ and $a, b\in \mathbb R$ are evaluated is **Integrating by Parts** $\int udv=uv-\int vdu$.

So we should take $u$ and $dv$ frequently until the whole integral becomes an easy integral. Is there any fast method in which we can do above integrals without using the classic formula? Thank you for the help.

Answer: 
I know two tricks.
For the $\sin(bx)$ type of integral, notice that $P(x)\sin(bx)$ is the imaginary part of $P(x)e^{ibx}$, which you can integrate more easily and then extract the imaginary part.

For the $e^{ax}$ type, notice that $x^ne^{ax} = \frac{\partial^n}{\partial a^n}(e^{ax})$.
So then $$\int x^n e^{ax}dx = \int \frac{\partial^n}{\partial a^n}e^{ax}dx = \frac{\partial^n}{\partial a^n} \int e^{ax} dx$$
$$$$
$$ = \frac{\partial^n}{\partial a^n}\left(\frac{1}{a}\right) = \frac{(-1)^n}{n! a^{n+1}}$$if you're integrating from 0 to infinity.
Note that the solution to
$$
(D+a)u=f\tag{1}
$$
is computed, using integrating factors, to be
$$
u(x)=e^{-ax}\int f(x)\,e^{ax}\,\mathrm{d}x\tag{2}
$$
Therefore, by inverting $(1)$, we get
$$
\begin{align}
u(x)
&=\frac{1}{D+a}f(x)\\
&=\frac1a\sum\_{k=0}^\infty\left(\frac{-D}{a}\right)^kf(x)\tag{3}
\end{align}
$$
whenever the infinite sum in $(3)$ makes sense, which it does in the case of polynomials.

Equating $(2)$ and $(3)$, we get
$$
\int f(x)\,e^{ax}\,\mathrm{d}x=\frac{e^{ax}}{a}\sum\_{k=0}^\infty\left(\frac{-D}{a}\right)^kf(x)\tag{4}
$$
at least when $f$ is a polynomial.

---

Let $a=ib$ above and we get
$$
\int f(x)(\cos(bx)+i\sin(bx))\,\mathrm{d}x=\frac{\sin(bx)-i\cos(bx)}{b}\sum\_{k=0}^\infty\left(\frac{iD}{b}\right)^kf(x)\tag{5}
$$
and after separating real and imaginary parts, we get
$$
\small\int f(x)\cos(bx)\,\mathrm{d}x=\left[\frac{\sin(bx)}{b}\sum\_{k=0}^\infty(-1)^k\left(\frac{D}{b}\right)^{2k}+\frac{\cos(bx)}{b}\sum\_{k=0}^\infty(-1)^k\left(\frac{D}{b}\right)^{2k+1}\right]f(x)\tag{6}
$$
and
$$
\small\int f(x)\sin(bx)\,\mathrm{d}x=\left[\frac{\sin(bx)}{b}\sum\_{k=0}^\infty(-1)^k\left(\frac{D}{b}\right)^{2k+1}-\frac{\cos(bx)}{b}\sum\_{k=0}^\infty(-1)^k\left(\frac{D}{b}\right)^{2k}\right]f(x)\tag{7}
$$