$\displaystyle \int e^x\cos x\,\mathrm{d}x$

$\displaystyle \int e^x\cos x\,\mathrm{d}x \,\overset{\substack{ u=\cos x\quad u'=-\sin x\\ v'=e^x\quad v=e^x\\ \phantom{\downarrow}}}{=}\, e^x\cos x-\int -e^x\sin x\,\mathrm{d}x= e^x\cos x+\int e^x\sin x\,\mathrm{d}x \,\overset{\substack{ u=\sin x\quad u'=\cos x\\ v'=e^x\quad v=e^x\\ \phantom{\downarrow}}}{=}\,\\ \qquad\displaystyle e^x\cos x+e^x\sin x-\int e^x\cos x\,\mathrm{d}x \Longrightarrow \int e^x\cos x\,\mathrm{d}x= \bbox[#FFECB3,5px]{\dfrac{1}{2}e^x(\cos x+\sin x)+k}$

Both times we have assigned the trigonometric part to $u$ and the exponential part to $v$. Switching roles works too:

$\displaystyle \int e^x\cos x\,\mathrm{d}x \,\overset{\substack{ u=e^x\quad u'=e^x\\ v'=\cos x\quad v=\sin x\\ \phantom{\downarrow}}}{=}\, e^x\sin x-\int e^x\sin x\,\mathrm{d}x \,\overset{\substack{ u=e^x\quad u'=e^x\\ v'=\sin x\quad v=-\cos x\\ \phantom{\downarrow}}}{=}\, e^x\sin x-\left(-e^x\cos x-\int -e^x\cos x\,\mathrm{d}x\right)=\\ \qquad\displaystyle e^x\sin x+e^x\cos x-\int e^x\cos x\,\mathrm{d}x \Longrightarrow \int e^x\cos x\,\mathrm{d}x= \bbox[#FFECB3,5px]{\dfrac{1}{2}e^x(\cos x+\sin x)+k}$

But mixing roles would not work:

$\displaystyle \int e^x\cos x\,\mathrm{d}x \,\overset{\substack{ u=\cos x\quad u'=-\sin x\\ v'=e^x\quad v=e^x\\ \phantom{\downarrow}}}{=}\, e^x\cos x-\int -e^x\sin x\,\mathrm{d}x= e^x\cos x+\int e^x\sin x\,\mathrm{d}x \,\overset{\substack{ u=e^x\quad u'=e^x\\ v'=\sin x\quad v=-\cos x\\ \phantom{\downarrow}}}{=}\,\\ \qquad\displaystyle e^x\cos x-e^x\cos x-\int -e^x\cos x\,\mathrm{d}x=\int e^x\cos x\,\mathrm{d}x$

having the very same integral we began with

$\displaystyle \int e^{ax}\cos (bx)\,\mathrm{d}x$

$\displaystyle \int e^{ax}\cos (bx)\,\mathrm{d}x \,\overset{\substack{ u=\cos (bx)\quad u'=-b\sin (bx)\\ v'=e^{ax}\quad v=\frac{1}{a}e^{ax}\\ \phantom{\downarrow}}}{=}\, \dfrac{1}{a}e^{ax}\cos (bx)-\int -\dfrac{b}{a}e^{ax}\sin (bx)\,\mathrm{d}x=\\ \qquad\displaystyle \dfrac{1}{a}e^{ax}\cos (bx)+\dfrac{b}{a}\int e^{ax}\sin (bx)\,\mathrm{d}x \,\overset{\substack{ u=\sin (bx)\quad u'=b\cos (bx)\\ v'=e^{ax}\quad v=\frac{1}{a}e^{ax}\\ \phantom{\downarrow}}}{=}\,\\ \qquad\displaystyle \dfrac{1}{a}e^{ax}\cos (bx)+\dfrac{b}{a^2}e^{ax}\sin (bx)-\dfrac{b^2}{a^2}e^{ax}\cos (bx)\,\mathrm{d}x \Longrightarrow \\ \qquad\displaystyle \int e^x\cos x\,\mathrm{d}x=\dfrac{1}{1+\frac{b^2}{a^2}}\left(\dfrac{1}{a}e^{ax}\cos (bx)+\dfrac{b}{a^2}e^{ax}\sin (bx) \right)= \bbox[#FFECB3,5px]{\dfrac{1}{a^2+b^2}e^{ax}(a\cos (bx)+b\sin (bx))+k}$

This result may be obtained in a much less formal, but certainly very beautiful way, by means of Euler's identity on complex exponentiation:

$$e^{(a+bi)x}=e^{ax}(\cos(bx)+i\sin(bx))$$

Integrating both sides,

$$\dfrac{1}{a+bi}e^{(a+bi)x}+k=\int e^{(a+bi)x}\,\mathrm{d}x=\int e^{ax}\cos (bx)\,\mathrm{d}x + i\int e^{ax}\sin (bx)\,\mathrm{d}x$$

but

$$\begin{array}{rcl} \dfrac{1}{a+bi}e^{(a+bi)x} & = & \dfrac{1}{a+bi}\dfrac{a-bi}{a-bi}e^{ax}(\cos(bx)+i\sin(bx))\\ & = & \dfrac{1}{a^2+b^2}e^{ax}(a-bi)(\cos(bx)+i\sin(bx))\\ & = & \dfrac{1}{a^2+b^2}e^{ax}(a\cos(bx)+b\sin(bx))+i\dfrac{1}{a^2+b^2}e^{ax}(a\sin(bx)-b\cos(bx)) \end{array}$$

and equating real and imaginary parts returns

$$\int e^{ax}\cos (bx)\,\mathrm{d}x=\dfrac{1}{a^2+b^2}e^{ax}(a\cos(bx)+b\sin(bx))+k$$ $$\int e^{ax}\sin (bx)\,\mathrm{d}x=\dfrac{1}{a^2+b^2}e^{ax}(a\sin(bx)-b\cos(bx))+k$$

derivation which centainly is most remarkable

$\displaystyle \int \cos(\ln x)\,\mathrm{d}x$

$\displaystyle \int \cos(\ln x)\,\mathrm{d}x \,\overset{\substack{ u=\cos(\ln x)\quad u'=-\sin(\ln x)\frac{1}{x}\\ v'=1\quad v=x\\ \phantom{\downarrow}}}{=}\, x\cos(\ln x) - \int-\sin(\ln x)\frac{1}{x}x\,\mathrm{d}x=\\ \qquad\displaystyle x\cos(\ln x) + \int\sin(\ln x)\,\mathrm{d}x \,\overset{\substack{ u=\sin(\ln x)\quad u'=\cos(\ln x)\frac{1}{x}\\ v'=1\quad v=x\\ \phantom{\downarrow}}}{=}\, x\cos(\ln x) + x\sin(\ln x) - \int\cos(\ln x)\frac{1}{x}x\,\mathrm{d}x\\ \qquad\displaystyle \Longrightarrow \int \cos(\ln x)\,\mathrm{d}x = \bbox[#FFECB3,5px]{\dfrac{1}{2}x\left(\cos(\ln x)+\sin(\ln x)\right) + k}$

Surprisingly enough, a change of variable $e^t=x$, $e^t\,\mathrm{d}t=\mathrm{d}x$ would lead to $\int e^t\cos t\,\mathrm{d}t$, which is solved with the very same double integration by parts technique