Evaluation of integral of product of three functions How can I evaluate $\int_0^\infty x^2e^{-kx}\cos (kx)dx$ where $k>0$ ? I tried Laplace transforms and integration by parts. Those methods did not work. Help solicited.   
 A: HINT:
Assuming $k_1>0$, we can write 
$$I(k_1,k_2)=\int_0^\infty x^2e^{-k_1x}\cos(k_2x)\,dx=\text{Re}\left(\frac{\partial^2}{\partial k_1^2}\int_0^\infty e^{-(k_1-ik_2)x}\,dx\right) \tag 1$$
SPOILER ALERT:  Scroll over the highlighted area to reveal the solution

Using the right-hand side of $(1)$, we obtain $$\begin{align}I(k_1,k_2)&=\text{Re}\left(\frac{\partial^2}{\partial k_1^2}\frac{1}{k_1-ik_2}\right)\\\\&=\text{Re}\left(\frac{2}{(k_1-ik_2)^3}\right)\tag 2\end{align}$$Setting $k_1=k_2=k$ in $(2)$ reveals $$\begin{align}\int_0^\infty x^2e^{-kx}\cos(kx)\,dx&=\text{Re}\left(\frac{2}{k^3(1-i)^3}\right)\\\\&=\frac{\cos(3\pi/4)}{\sqrt{2}\,k^3}\\\\&=-\frac{1}{2k^3}\end{align}$$

A: Concerning the antiderivative, we can do it considering $$I=\int x^2e^{-kx}\cos (kx)\,dx$$ $$J=\int x^2e^{-kx}\sin (kx)\,dx$$ $$I+iJ=\int x^2e^{-kx}e^{i kx}\,dx=\int x^2e^{-k(1-i)x}\,dx$$ Now, two integrations by parts give, after some simplifications $$I+iJ=-\frac{\left(\frac{1}{2}+\frac{i}{2}\right) e^{(-1+i) k x} (k x+i) (k x+1)}{k^3}$$ Integrating between $0$ and $\infty$ then leads to $$-\frac{\frac{1}{2}-\frac{i}{2}}{k^3}$$ which make $$\int_0^\infty x^2e^{-kx}\cos (kx)dx=-\frac 1{2k^3}$$ $$\int_0^\infty x^2e^{-kx}\sin(kx)dx=+\frac 1{2k^3}$$
It could have been a good idea to start changing variable $kx=y$ at the beginning to handle simpler expressions.
