2

I was watching this: https://youtu.be/qQ-56b_LvOw?t=4484

And this integral came up. $$\int_{0}^{\infty}{(2x^2+1)e^{-x^2}}dx$$

To which the answer was $\sqrt{\pi}$.

They made it clear that you didn't need knowledge about erf$(x)$ to solve this integral, although it looks like one of the competitors tried to solve it using that. How can you solve this without "extra knowledge"?(Assuming you only have mastered the techniques of integral calculus)

fridge
  • 25
  • Do you know how to integrate in polar coordinates? – Cameron Williams Mar 28 '16 at 01:07
  • No. I'll learn it right now, though. – fridge Mar 28 '16 at 01:08
  • Okay well I will provide an answer that will rely on it so you should read up on it. It is pretty easy once you see it though. – Cameron Williams Mar 28 '16 at 01:09
  • @fridgemagnet that's the spirit!! I love to see when the person asking the question actually goes out and tries to learn the concept instead of just pestering for an answer.... It makes answering easier and neater and is more beneficial to the OP!! +1!! – Brevan Ellefsen Mar 28 '16 at 01:15
  • The technique being used is to note that $\int_{-\infty}^\infty e^{-x^2} dx = \left ( \left ( \int_{-\infty}^\infty e^{-x^2} dx \right )^2 \right )^{1/2} = \left ( \int_{-\infty}^\infty \int_{-\infty}^\infty e^{-x^2-y^2} dx dy \right )^{1/2}$. Then this inner integral is computed in polar coordinates, where you "magically" have the extra factor that you need to be able to integrate. Next, to integrate $x^2 e^{-x^2}$, you integrate by parts, reducing the problem to the previous one. Finally you need a symmetry argument to change the domain to $[0,\infty)$. – Ian Mar 28 '16 at 01:23

2 Answers2

2

We need to first compute the integral

$$ I = \int_0^{\infty} e^{-x^2}\,dx.$$

Note that

$$I^2 = \left(\int_0^{\infty} e^{-x^2}\,dx\right)^2 = \int_0^{\infty} e^{-x^2}\,dx\int_0^{\infty} e^{-y^2}\,dy.$$

I used a different variable for the second integral since the two integrals would get confused if we used the same integration variable for each.

Recombining our integrals, we get

$$ I^2 = \int_0^{\infty}\int_0^{\infty} e^{-x^2-y^2}\,dxdy.$$

Let us now switch to polar coordinates so that $x^2 + y^2 = r^2$ and $dxdy = r\,drd\theta$. In the $xy$ plane we are integrating over the first quadrant which corresponds to $r$ ranging from $0$ to $\infty$ and $\theta$ ranging from $0$ to $\frac{\pi}{2}$. We then have

$$ I^2 = \int_0^{\frac{\pi}{2}}\int_0^{\infty} e^{-r^2}r\,drd\theta.$$

Letting $z = r^2$, we have $dz = 2r\,dr$ and so

$$ I^2 = \int_0^{\frac{\pi}{2}} \int_0^{\infty} e^{-z}\frac{1}{2}dzd\theta.$$

We can do the $z$ integral very easily now: $\int_0^{\infty} e^{-z}\,dz = 1$, giving

$$ I^2 = \frac{1}{2}\int_0^{\frac{\pi}{2}} d\theta = \frac{\pi}{4}.$$

Taking a square root, we see that $I = \frac{\sqrt\pi}{2}$. This accounts only for the second half of the integral. The first half will have to be treated in a different manner.


Consider then

$$ J(\alpha) = \int_0^{\infty} e^{-\alpha x^2}\,dx.$$

Note that if we take an $\alpha$ derivative of both sides, we have

$$ J'(\alpha) = \frac{d}{d\alpha} \int_0^{\infty} e^{-\alpha x^2}\,dx = \int_0^{\infty} (-x^2)e^{-\alpha x^2}\,dx.$$

The way to think about this is that with respect to $\alpha$, $x$ is constant so if we differentiate the integrand $e^{-\alpha x^2}$ with respect to $\alpha$, the $-x^2$ just comes out front via chain rule. So then if we plug in $\alpha=1$, we have that

$$ J'(1) = -\int_0^{\infty} x^2 e^{-\alpha x^2}\,dx$$

which is quite nearly exactly what we wanted (modulo a factor of $-2$). This means that if we can evaluate $J(\alpha)$ in terms of $\alpha$, we would be done. Let us do so. Setting $z = \sqrt{\alpha} x$, $dz = \sqrt{\alpha}\,dx$, we get

$$ J(\alpha) = \int_0^{\infty} e^{-\alpha x^2}\,dx = \int_0^{\infty} e^{-z^2}\,\frac{dz}{\sqrt{\alpha}}.$$

We already computed the integral above, so we get that

$$ J(\alpha) = \frac{\sqrt{\pi}}{2\sqrt{\alpha}}$$

and so

$$ J'(\alpha) = -\frac{\sqrt{\pi}}{4\alpha^{\frac{3}{2}}}.$$

Plugging in $\alpha = 1$ and doing some minor adjustments, you can get your answer.

  • Note that you can do integration by parts on the first integral, but this technique is a little more fun in my opinion and doesn't really require you to do any more "real" work. – Cameron Williams Mar 28 '16 at 01:28
  • +1 Brilliant and elegant. Answers such as these are why I love MSE so much! – Xoque55 Mar 28 '16 at 01:39
  • Thanks. I sort of understand why you combined those integrals, I think you are integrating over more than one dimension, but I can't see why you made , $dydx = r drd{\theta}$. Also, are you actually integrating in polar coordinates, or just making a substitution that resembles switching to polar coordinates?(If that made sense) – fridge Mar 28 '16 at 01:52
  • @fridgemagnet I am integrating in polar coordinates, but I think you're right in thinking that there is simply a substitution going on. If you make the changes of variables $x = r\cos\theta$ and $y = r\sin\theta$, what you can show is that $dxdy = r,drd\theta$. One way to see that this should be true intuitively is if you integrate the constant function $1$ over the unit circle, you should get $\pi$. If you used $drd\theta$ instead of $r,drd\theta$, you'd get the wrong answer. – Cameron Williams Mar 28 '16 at 01:58
  • Thanks again, it's a very creative response. It surprises me how a competitor was supposed to do that in 4 minutes! – fridge Mar 28 '16 at 02:04
  • 1
    @fridgemagnet It's a matter of practice and experience (and some luck/insight). Best of luck on your calculus endeavors :) – Cameron Williams Mar 28 '16 at 02:05
1

Using integration by parts we get $$ \begin{align} \int\limits_0^\infty (2x^2 + 1) e^{-x^2} \, dx &= \int\limits_0^\infty \underbrace{x}_f (\underbrace{2x e^{-x^2}}_{g'}) \, dx + \int\limits_0^\infty e^{-x^2} \, dx \\ &= \left[\underbrace{x}_f \, (\underbrace{-e^{-x^2}}_g) \right]_{x=0}^{x\to\infty} - \int\limits_0^\infty(\underbrace{1}_{f'})(\underbrace{-e^{-x^2}}_g) \, dx + \int\limits_0^\infty e^{-x^2} \, dx \\ &= 2 \int\limits_0^\infty e^{-x^2} \, dx \\ &= \int\limits_{-\infty}^\infty e^{-x^2} \, dx \\ &= I \end{align} $$ To solve $I = \sqrt{\pi}$ one uses the trick by Poisson (solving $I^2$ as integral over the plane in polar coordinates), as answered many times on this site already, e.g. here.

mvw
  • 34,562