How can we find the closed form of $\int_{0}^{\infty}{1+x+x^2+\cdots+x^{n}\over x^2}\cdot{1-\cos(ax)\over e^x} dx=f(a,n)+a\arctan(a)?$ How can we find the closed form of

$$\int_{0}^{\infty}{1+x+x^2+\cdots+x^{n}\over x^2}\cdot{1-\cos(ax)\over e^x}\mathrm dx=f(a,n)+a\arctan(a)\color{red}?\tag1$$

$$\int_{0}^{\infty}{1-x^{n+1}\over x^2-x^3}\cdot{1-\cos(ax)\over e^x}\mathrm dx=I+J\tag2$$
$$I=\int_{0}^{\infty}{1-\cos(ax)\over x^2-x^3}e^{-x}\mathrm dx$$
$$J=\int_{0}^{\infty}{1-\cos(ax)\over x^2-x^3}x^{1+n}e^{-x}\mathrm dx$$
So the general integral we have to evaluate is

$$k=\int_{0}^{\infty}{1-\cos(ax)\over 1-x}x^{N}e^{-x}\mathrm dx\tag3$$

Split $(3)$
$$\int_{0}^{\infty}{x^Ne^{-x}\over 1-x}\mathrm dx-\int_{0}^{\infty}{x^Ne^{-x}\cos(ax)\over 1-x}\mathrm dx\tag4$$
Applying Laplace transform:
$$L\left({x^N\over 1-x}\right)=?$$
and 
$$L\left({x^N\cos(ax)\over 1-x}\right)=?$$
$$...$$
 A: I assume $a>0$ below.
Starting with something well-known
We work with Laplace transforms. Let $f(t)=1-\cos t$. Then
$$
\begin{aligned}
\Phi_0(s)&:=F(s)=\mathcal L(f)(s)=\int_0^{+\infty}(1-\cos t)e^{-st}\,dt\\
&=\frac{1}{s}-\frac{s}{1+s^2}.
\end{aligned}
$$
Using the classical rules of the Laplace transform we find that
$$
\begin{aligned}
\Phi_{-1}(s)&:=\int_0^{+\infty}\frac{1-\cos t}{t}e^{-st}\,dt=\int_s^{+\infty}F(\sigma)\,d\sigma\\
&=\frac{1}{2}\ln(1+1/s^2)
\end{aligned}
$$
and
$$
\begin{aligned}
\Phi_{-2}(s)&:=\int_0^{+\infty}\frac{1-\cos t}{t^2}e^{-st}\,dt\\
&=\int_s^{+\infty}\frac{1}{2}\ln(1+1/\sigma^2)\,d\sigma\\
&=\arctan(1/s)-\frac{1}{2}s\ln(1+1/s^2).
\end{aligned}
$$
If we instead multiply by $t$, then, for $k\geq 1$,
$$
\begin{aligned}
\Phi_{k}(s)&:=\int_0^{+\infty}(1-\cos t)t^k e^{-st}\,dx=(-1)^k F^{(k)}(s)\\
&=(-1)^k\frac{d^k}{ds^k}\Bigl(\frac{1}{s}-\frac{s}{1+s^2}\Bigr)
\end{aligned}
$$
Making your integral fit into this
We note that (with $t=ax$)
$$
\begin{aligned}
\int_0^{+\infty}(1-\cos a x)x^k e^{-x}\,dx&=\frac{1}{a^{k+1}}\int_0^{+\infty}(1-\cos t)t^ke^{-(1/a)t}\,dt\\
&=\frac{1}{a^{k+1}}\Phi_{k}(1/a).
\end{aligned}
$$
Thus, your integral equals
$$
\sum_{k=-2}^n\frac{1}{a^{k+1}}\Phi_{k}(1/a)
$$
Note that when $k=-2$ we have a term $a\arctan a$. The rest of the sum will be what you call $f(a,n)$. I don't know if this is explicit enough for you, but this is as far as I have the motivation to take it.
A: Writing $a=2\alpha$, the desired integral can be written as
$$2\alpha^2\int_0^{\infty}\!\!\!\mathrm{d}x\,(1+x+x^2+\dotsi x^n)~\mathrm{sinc}^2(\alpha\,x)\,e^{-x}=:I_n$$
Consider the Laplace transform of $$\mathrm{sinc}(\alpha\,x):=\frac{\sin(\alpha\,x)}{\alpha\,x},$$
given by
$$L(s)=\int_0^{\infty}\!\!\!\mathrm{d}x~\mathrm{sinc}^2(\alpha\,x)\,e^{-sx}=\alpha^{-2}\int_0^{\infty}\!\!\!\mathrm{d}y~\sin^2\left(\alpha/y\right)\,e^{-\frac{s}{y}},$$
where $y=x^{-1}$. This integral can be written in closed form (see Gradshteyn and Ryzhik, eqn 3.927 p.486):
$$L(s)=\frac{1}{\alpha}\tan^{-1}\left(\frac{2\alpha}{s}\right)+\frac{s}{4\alpha^2}\ln\left(\frac{s^2}{s^2+4\alpha^2}\right).$$
Now, since
$$\int_0^{\infty}\!\!\!\mathrm{d}x~x^k\,\mathrm{sinc}^2(\alpha\,x)\,e^{-x}=(-1)^k\left\{\int_0^{\infty}\!\!\!\mathrm{d}x~\,\mathrm{sinc}^2(\alpha\,x)\,\frac{\partial^k}{\partial s^k}e^{-sx}\right\}_{s=1}\!\!=(-1)^kL^{(k)}(1),$$
where the superscript denotes $k^{\text{th}}$ derivative of $L$ w.r.t $s$, we have
$$I_n=\tilde{L}(1)+\sum_{k=1}^n(-1)^k\tilde{L}^{(k)}(1),$$
writing
$$\tilde{L}(s):=2\alpha^2L(s)=a\tan^{-1}\left(\frac{a}{s}\right)+\frac{s}{2}\ln\left(\frac{s^2}{s^2+a^2}\right).$$
I have replaced $2\alpha$ by $a$ in the previous step. Now, all one needs to do is differentiate successively.
But, we can easily identify $f(a,n)$, viz.
$$\boxed{f(a,n)=-\frac{1}{2}\ln\left(1+a^2\right)+\sum_{k=1}^n(-1)^k\tilde{L}^{(k)}(1).}$$
For particular values of $n$, we have
$$f(a,1)=-\ln\left(1+a^2\right)$$
$$f(a,2)=1-\ln\left(1+a^2\right)$$
$$f(a,3)=1-\ln\left(1+a^2\right)+\frac{a^2(a^2+3)}{a^2+1}$$
and so on.
Cheers !
A: Hint:
$$\int_0^\infty x^ne^{-x}dx=\Gamma(n+1)=n!$$
and with $t=(1-ia)x$ 
$$\int_0^\infty x^ne^{(-1+ia)x}dx=(1-ia)^{-n-1}\int_Ct^ne^{-t}dt$$ is a modified Gamma, where the integration path $C$ is an oblique line in the direction of $1/(1-ia)$. Applying the theorem of residues in a wedge, the integral is also $n!$ as the integral along the arc at infinity vanishes.
Hence, taking the real part,
$$\int_0^\infty x^ne^{-x}\cos(ax)\,dx=n!\,\Re(1-ia)^{-n-1}.$$
Ignoring the first two terms in the fraction, we get the expression
$$g(n,a)=\sum_{k=0}^{n-2}k!\left(1-\Re(1-ia)^{-k-1}\right)=\sum_{k=0}^{n-2}k!\left(1-(1+a^2)^{-(k+1)/2}\cos\left((k+1)\arctan a\right)\right).$$
