# How to calculate $\int_{-\infty}^{+\infty} \frac{x \sin x}{x^2+4x+20}\, dx$?

I get the answer that it equals $$\frac{\pi(2\cos2+\sin2)}{2e^4}$$ by mathematica.

But I don't know how it can equal this form.

My idea is to construct equations so that problems can be transformed.
Like these: $$\int_{-\infty}^{+\infty} \frac{x \sin x}{x^2+4x+20}\, dx=\int_{-\infty}^{+\infty} \frac{(y+4) \sin (y+4)}{y^2+4y+20}\, dy$$ $$\int_{-\infty}^{+\infty} \frac{x \cos x}{x^2+4x+20}\, dx=-\int_{-\infty}^{+\infty} \frac{(y+4) \cos (y+4)}{y^2+4y+20}\, dy$$ So only by calculating $$\int_{-\infty}^{+\infty} \frac{ \sin x}{x^2+4x+20}\, dx$$ and $$\int_{-\infty}^{+\infty} \frac{ \cos x}{x^2+4x+20}\, dx$$ then we can get the values of $$\int_{-\infty}^{+\infty} \frac{x \sin x}{x^2+4x+20}\, dx$$ and $$\int_{-\infty}^{+\infty} \frac{x \cos x}{x^2+4x+20}\, dx$$.

What's more I found that $$\int_{-\infty}^{+\infty} \frac{ \sin x}{x^2+4x+20}\, dx=- \frac{\pi \sin 2}{4e^4}$$ $$\int_{-\infty}^{+\infty} \frac{ \cos x}{x^2+4x+20}\, dx= \frac{\pi \cos 2}{4e^4}$$

So I guess I can solve the problem only by calculating $$\int_{-\infty}^{+\infty} \frac{ \sin x}{x^2+ c}\, dx$$ and $$\int_{-\infty}^{+\infty} \frac{ \cos x}{x^2+ c}\, dx$$

Can you help me?

• Do you know residue calculus? – MisterRiemann Nov 25 '18 at 10:55
• @MisterRiemann sorry I didn't know that – Zero Nov 25 '18 at 10:58
• What can we say about $c$ in terms of being positive or negative? – user150203 Nov 26 '18 at 6:50

As you've already noted, the substitution $$y=x-2$$ gives$$\int_{\mathbb{R}}\frac{x\sin xdx}{x^{2}+4x+20} =2C_{0}\sin 2-2S_{0}\cos 2+S_{1}\cos 2-C_{1}\sin 2$$with $$C_{n}:=\int_{\mathbb{R}}\frac{y^{n}\cos ydy}{y^{2}+16},\,S_{n}:=\int_{\mathbb{R}}\frac{y^{n}\sin ydy}{y^{2}+16},$$i.e. $$C_{n}+iS_{n}=\int_{\mathbb{R}}\frac{\exp iydy}{y^{2}+16}.$$The characteristic function of the Cauchy distribution is$$\int_{\mathbb{R}}\frac{\gamma}{\pi}\frac{\exp itydy}{\left(y-y_{0}\right)^{2}+\gamma^{2}}=\exp\left(iy_{0}t-\gamma\left|t\right|\right),$$so in particular$$\int_{\mathbb{R}}\frac{\exp itydy}{y^{2}+16}=\frac{\pi}{4}\exp-4\left|t\right|.$$Differentiating with respect to t,$$\int_{\mathbb{R}}\frac{y\exp itydy}{y^{2}+16}=\pi i\operatorname{sgn}t\exp-4\left|t\right|.$$Hence$$C_{0}+iS_{0}=\frac{\pi}{4e^{4}},\,C_{1}+iS_{1}=\frac{\pi i}{e^{4}}\implies C_{1}=S_{0}=0,\,C_{0}=\frac{\pi}{4e^{4}},\,S_{1}=\frac{\pi}{e^{4}}.$$Finally,$$\int_{\mathbb{R}}\frac{x\sin xdx}{x^{2}+4x+20}=\frac{\pi}{2e^{4}}\left(2\cos2+\sin2\right).$$

An Alternative approach. Employ a combination of Feynman's Trick and Laplace Transforms.

Here let:

$$I(t) = \int_{-\infty}^{\infty} \frac{x\sin(xt)}{x^2 + 4x + 20}\:dx$$

Take the Laplace Transform w.r.t '$$t$$':

\begin{align} \mathscr{L}\left[I(t)\right] &= \int_{-\infty}^{\infty} \frac{x\mathscr{L}\left[\sin(xt)\right]}{x^2 + 4x + 20}\:dx \\ &= \int_{-\infty}^{\infty} \frac{x}{x^2 + 4x + 20}\frac{x}{x^2 + s^2}\:dx = \int_{-\infty}^{\infty} \frac{x^2}{\left(x^2 + 4x + 20\right)\left(x^2 + s^2\right)}\:dx \\ &= \frac{1}{s^4 - 24s^2 + 400}\int_{-\infty}^{\infty}\left[\frac{s^4 - 20s^2}{x^2 + s^2} + \frac{4s^2x}{x^2 + s^2} - \frac{4\left( 5s^2 - 100\right)}{x^2 + 4x + 20} - \frac{4s^2x}{x^2 + 4x + 20} \right]dx \\ &=\frac{1}{s^4 - 24s^2 + 400}\left[ \underbrace{\int_{-\infty}^{\infty}\frac{s^4 - 20s^2}{x^2 + s^2}\:dx}_{(1)} + \underbrace{\int_{-\infty}^{\infty}\frac{4s^2x}{x^2 + s^2}\:dx}_{(2)} - \underbrace{\int_{-\infty}^{\infty}\frac{4\left( 5s^2 - 100\right)}{x^2 + 4x + 20}\:dx}_{(3)} - \underbrace{\int_{-\infty}^{\infty}\frac{4s^2x}{x^2 + 4x + 20}\:dx}_{(4)}\right] \end{align}

We can now evaluate each individually

For (1):

$$\int_{-\infty}^{\infty}\frac{s^4 - 20s^2}{x^2 + s^2}\:dx = \left(s^4 - 20s^2\right)\left[\frac{\arctan\left(\frac{x}{s} \right)}{s}\right]_{-\infty}^{\infty} = \left(s^4 - 20s^2\right)\frac{\pi}{s} = \left(s^3 - 20s\right)\pi$$

For (2)

$$\int_{-\infty}^{\infty}\frac{4s^2x}{x^2 + s^2}\:dx = 0$$

For (3)

\begin{align} \int_{-\infty}^{\infty}\frac{4\left( 5s^2 - 100\right)}{x^2 + 4x + 20}\:dx &= \int_{-\infty}^{\infty}\frac{4\left( 5s^2 - 100\right)}{\left(x + 2\right)^2 + 4^2}\:dx =\int_{-\infty}^{\infty}\frac{4\left( 5s^2 - 100\right)}{x^2 + 4^2}\:dx \\ &= 4\left( 5s^2 - 100\right)\left[\frac{\arctan\left(\frac{x}{4} \right)}{4}\right]_{-\infty}^{\infty} =4\left( 5s^2 - 100\right)\frac{\pi}{4}\\ &= \left( 5s^2 - 100\right)\pi \end{align}

For (4)

\begin{align} \int_{-\infty}^{\infty}\frac{4s^2x}{x^2 + 4x + 20} &= \int_{-\infty}^{\infty}\frac{4s^2x}{\left(x + 2\right)^2 + 4^2} \:dx = \int_{-\infty}^{\infty}\frac{4s^2\left(x - 2\right)}{x^2 + 4^2} \:dx \\ &= \int_{-\infty}^{\infty}\frac{4s^2x}{x^2 + 4^2} \:dx - \int_{-\infty}^{\infty}\frac{8s^2}{x^2 + 4^2}\:dx \\ &= 2s^2\cdot 0 - 8s^2\left[\frac{\arctan\left(\frac{x}{4} \right)}{4}\right]_{-\infty}^{\infty} \\ &= - 8s^2\cdot\frac{\pi}{4} = -2s^2\pi \end{align}

Thus, in combining we have:

\begin{align} \mathscr{L}\left[I(t)\right] &= \frac{1}{s^4 - 24s^2 + 200}\left[\left(s^3 - 20s\right)\pi + 0 - \left( 5s^2 - 100\right)\pi - -2s^2\pi\right] \\ &= \frac{\left(s^3 - 3s^2 - 20s + 100 \right)}{s^4 - 24s^2 + 400}\pi \end{align}

We now take the inverse Laplace Transform

\begin{align} I(t) &= \mathscr{L}^{-1}\left[\frac{s^3 - 3s^2 - 20s + 100 }{s^4 - 24s^2 + 400}\pi \right] \\ &= \frac{1}{4}e^{-2\left(2 + i \right)t}\left(\left(2 - i\right)e^{4it} + (2 + i) \right)\pi \end{align}

Hence

\begin{align} I = I(1) &= \frac{1}{4}e^{-2\left(2 + i \right)}\left(\left(2 - i\right)e^{4i} + (2 + i) \right) \\ &= \left(\sin(2) + 2\cos(2)\right)\frac{\pi}{2e^4} \end{align}