# Gaussian integral by differentiating under the integral sign

• I
• murshid_islam

#### murshid_islam

TL;DR Summary
Attempting to evaluate the Gaussian integral by differentiating under the integral sign
Hi, I have recently learned the technique of integration using differentiation under the integral sign, which Feynman mentioned in his “Surely You’re Joking, Mr. Feynman”. So, I decided to try it on the Gaussian Integral (I do know the standard method of computing it by squaring it and changing to polar coordinates, but I wanted to do it with this method of differentiating under the integral sign). I didn’t manage to do it yet. Here’s what I have tried so far:

First attempt:
I tried to get an ##x## with the ##e^{-x^2}## after differentiating under the integral sign so that I could use the u-substitution ##u = x^2##. But I failed. Then I tried this:

Let ##I(t) = \int_0^{\infty}e^{-tx^2}dx##, where ##t>0## and ##2\cdot I(1) = \int_{-\infty}^{\infty}e^{-x^2}dx##
$$I'(t) = \frac{d}{dt} \int_0^{\infty}e^{-tx^2}dx = \int_0^{\infty} \frac{\partial}{\partial t} \left (e^{-tx^2}\right ) dx = \int_0^{\infty} -x^2 e^{-tx^2}dx$$
Now, I did integration by parts with ##u = -x, du = -dx, dv = xe^{-tx^2}dx, v = \frac{-1}{2t}e^{-tx^2}## and got
$$I'(t) = \frac{-1}{2t}\int_0^{\infty}e^{-tx^2}dx = \frac{-1}{2t} I(t)$$
$$\implies \int \frac{dI}{I} = -\frac{1}{2} \int \frac{dt}{t}$$
$$\implies \ln |I| = \ln \left\lvert \frac{1}{\sqrt{t}}\right\rvert + \ln C = \ln \left\lvert \frac{C}{\sqrt{t}}\right\rvert$$
$$\implies I(t) = \frac{C}{\sqrt{t}}$$
Now I can't find an initial value to use in order to find C. Have I gone down the wrong path?

Second attempt:

Let ##I(t) = \int_0^{\infty}e^{-x^2-tx^2}dx## , where ##t>0## and ##2\cdot I(0) = \int_{-\infty}^{\infty}e^{-x^2}dx##

$$I'(t) = \frac{d}{dt} \int_0^{\infty}e^{-x^2-tx^2}dx = \int_0^{\infty} \frac{\partial}{\partial t} \left (e^{-x^2-tx^2} \right ) dx= \int_0^{\infty} (-2tx)e^{-x^2-tx^2} dx = -2t\int_0^{\infty}xe^{-x^2}\cdot e^{-t^2x} dx$$
Now using integration by parts with ##u = e^{-t^2x}, du = -t^2e^{-t^2x}dx, dv = xe^{-x^2}dx, v = \frac{-1}{2}e^{-x^2}## led to this differential equation: ##I'(t) = -t + t^3I(t)##

Any ideas anyone? Am I choosing I(t) wrong?

Last edited:
• Delta2
What is b?

The usual way (very easy) to evaluate the integral is to square it and change to polar coordinates, where it can be readily evaluated.

What is b?
Oops! I meant to write 't'. I have edited and corrected my post.

The usual way (very easy) to evaluate the integral is to square it and change to polar coordinates, where it can be readily evaluated.
Yes, I do know that method. I was just trying to do it with this new tool I learned.
.

Your first attempt looks correct to me (note that we can find the same result much faster by writing ##e^{-tx^2}=e^{-(\sqrt{t}x)^2}## and using the substitution ##u=\sqrt{t} x##), and it is $$C=I(1)=\int_0^{+\infty}e^{-x^2}dx$$. I am afraid there is no other way to compute C.

Your second attempt looks to me it has some typos. Perhaps you meant to define $$I(t)=\int_0^{\infty}e^{-x^2-t^2x}dx$$? Cause you have define it slightly different with## t## instead of ##t^2## but then you proceed and calculate the partial derivative as you have ##t^2## there and not t.

Your second attempt looks to me it has some typos. Perhaps you meant to define $$I(t)=\int_0^{\infty}e^{-x^2-t^2x}dx$$? Cause you have define it slightly different with## t## instead of ##t^2## but then you proceed and calculate the partial derivative as you have ##t^2## there and not t.
You're correct. I made typos. I can't edit my original post anymore. So, here's the edited version:

Second attempt:

Let ##I(t) = \int_0^{\infty}e^{-x^2-t^2x}dx## , where ##t>0## and ##2\cdot I(0) = \int_{-\infty}^{\infty}e^{-x^2}dx##

$$I'(t) = \frac{d}{dt} \int_0^{\infty}e^{-x^2-t^2x}dx = \int_0^{\infty} \frac{\partial}{\partial t} \left (e^{-x^2-t^2x} \right ) dx= \int_0^{\infty} (-2tx)e^{-x^2-t^2x} dx = -2t\int_0^{\infty}xe^{-x^2}\cdot e^{-t^2x} dx$$
Now using integration by parts with ##u = e^{-t^2x}, du = -t^2e^{-t^2x}dx, dv = xe^{-x^2}dx, v = \frac{-1}{2}e^{-x^2}## led to this differential equation: ##I'(t) = -t + t^3I(t)##

• Delta2
I can't argue very rigorously here but something tells me that your method can't lead you to where you want.

Finding a differential equation of first order on ##I(t)## looks nice and neat but to fully solve this differential equation of first order we need an initial condition $$I(t_0)=C$$. Which essentially means that you have to know the value of ##I(t_0)## that is to be able to calculate the integral ##I(t_0)## for some ##t_0## (which looks like ##t_0=0## in this case).

I can't argue very rigorously here but something tells me that your method can't lead you to where you want.

Finding a differential equation of first order on ##I(t)## looks nice and neat but to fully solve this differential equation of first order we need an initial condition $$I(t_0)=C$$. Which essentially means that you have to know the value of ##I(t_0)## that is to be able to calculate the integral ##I(t_0)## for some ##t_0## (which looks like ##t_0=0## in this case).
Yes, I see what you mean. The only initial values that seem to work in these cases are ##t_0 = 1## in my first attempt and and ##t_0 = 0## in my second one. Neither of those helps because they lead to the original Gaussian integral I'm trying to compute. Perhaps I need to choose a different I(t). I just can't figure out what.

Yes, I see what you mean. The only initial values that seem to work in these cases are ##t_0 = 1## in my first attempt and and ##t_0 = 0## in my second one. Neither of those helps because they lead to the original Gaussian integral I'm trying to compute. Perhaps I need to choose a different I(t). I just can't figure out what.
Basically I am arguing that whatever I(t) you choose, your method most likely will end up to a first order ODE for I(t), therefore we need an initial condition ##I(t_0)=C## ,that is, to be able to calculate I(t) for some value ##t_0##. So you must choose a I(t) for which you are able to calculate ##I(t_0)## for some specific value ##t_0## but this is contradiction, since I(t) most likely is defined in such a way that you can NOT compute it directly for any value t.

Yes, I do know that method. I was just trying to do it with this new tool I learned.
The point of the trick is that once you know the integral of ##e^{-x^2}## you can generalise to ##e^{-bx^2}## using the trick. Not that you can find the integral of ##e^{-x^2}## in the first place.

• hutchphd and Delta2
Basically I am arguing that whatever I(t) you choose, your method most likely will end up to a first order ODE for I(t), therefore we need an initial condition ##I(t_0)=C## ,that is, to be able to calculate I(t) for some value ##t_0##. So you must choose a I(t) for which you are able to calculate ##I(t_0)## for some specific value ##t_0## but this is contradiction, since I(t) most likely is defined in such a way that you can NOT compute it directly for any value t.
For example, to compute another integral altogether, i.e., ##\int_0^\infty e^{-x^2}\cos(x) dx##, we can take ##I(t) = \int_0^\infty e^{-x^2}\cos(tx)dx##

Then ##I'(t) = -\int_0^\infty xe^{-x^2}\sin(tx)dx##

Now using ##u=\sin(tx)##, ##du = t\cos(tx)dx##, ##dv=xe^{-x^2}dx##, ##v=\frac{-1}{2}e^{-x^2}##, we get

##I'(t) = -\frac{t}{2} \int_0^\infty e^{-x^2}\cos(tx)dx = -\frac{t}{2} I(t)##

## \implies \ln \lvert I(t) \rvert = - \frac{t^2}{4} + C_1##

## \implies I(t) = Ce^{\frac{-t^2}{4}}##

From our definition of ##I(t)##, we have ##I(0) = \int_0^\infty e^{-x^2} = \frac{\sqrt {\pi}}{2}## and from the solution of the differential equation, ##I(0) = C##. Therefore, ##C = \frac{\sqrt {\pi}}{2}## and ##I(t) = \frac{\sqrt {\pi}}{2} e^{\frac{-t^2}{4}}##. So, ##\int_0^\infty e^{-x^2}\cos(x) dx = \frac{\sqrt {\pi}}{2} e^{\frac{-1}{4}}##

However, in this case, we assumed that we know the value of Gaussian integral.

• lurflurf and Delta2
However, in this case, we assumed that we know the value of Gaussian integral.
If you generate a differential equation, you need some initial value to get a solution. I think this has already been pointed out.

• Delta2
If you generate a differential equation, you need some initial value to get a solution. I think this has already been pointed out.
Yes. I wasn't disputing that point.

• PeroK
We desire to find
$$I=\int_0^\infty e^{-x^2}\mathop{dx}$$
let
$$\mathrm{F}(t)=-\frac{1}{2} \int_0^\infty e^{-t^2(1+x^2)}\frac{\mathop{dx}}{1+x^2}$$
we differentiate to establish
$$I^2= \int_0^\infty\mathrm{F}^\prime(t)\mathop{dt}=\mathrm{F}(\infty)-\mathrm{F}(0)$$
hence
$$I=\sqrt{\mathrm{F}(\infty)-\mathrm{F}(0)}$$
as was desired to find

this and several other amusing methods are discribed here

edited to fix x t switch typo

Last edited:
• Delta2
Nice link @lurflurf but I think you got a typo you meant to write $$F(t)=-\frac 1 2\int_0^{\infty}\frac{e^{-t^2(1+x^2)}}{1+x^2}dx$$

• lurflurf
Yes. I wasn't disputing that point.
This turned up on YouTube today:

It might be interesting and/or useful.

• murshid_islam and Delta2
This turned up on YouTube today:

It might be interesting and/or useful.
The video considers f(t) related to F(t) above by
$$\mathrm{F}(t)=-\frac{1}{4}e^{-t^2}\mathrm{f}(t)$$
so
$$I=\sqrt{-\mathrm{F}(0)}=\frac{1}{2}\sqrt{\mathrm{f}(0)}$$

This turned up on YouTube today:

[...]

It might be interesting and/or useful.

Thanks. That's an Interesting video. After I watched it, YouTube recommended this video where he actually computed the Gaussian integral using the "differentiating under the integral" trick.

This is what he did:

##I = \int_0^\infty e^{-x^2}dx##

Let ##I(t) = \int_0^\infty \frac{e^{-t^2}(1+x^2)}{1+x^2}dx##, where ##I(0) = \frac{\pi}{2}## and ##I(\infty) = 0##

$$I'(t) = \int_0^\infty \frac{e^{-t^2(1+x^2)}(-2t)(1+x^2)}{1+x^2}dx = -2t e^{-t^2}\int_0^\infty e^{-t^2x^2}dx$$
Now, using the substitution ##u = tx##, ##du = tdx##,
$$I'(t) = -2e^{-t^2}\int_0^\infty e^{-u^2}du = -2e^{-t^2}\cdot I$$
$$\implies \int_0^\infty I'(t) = -2I \int_0^\infty e^{-t^2} dt$$
$$\implies I(\infty) - I(0) = -2I\cdot I$$
$$\implies 0-\frac{\pi}{2} = -2I^2$$
$$\implies I = \frac{\sqrt{\pi}}{2}$$

Edit: Just noticed that that was the method shown by lurflurf in his post above.

Last edited:
There is another derivation that uses Fourier transforms. Of course, the facts about Fourier transforms and their inverses are probably more difficult to prove than the original integral, but just for consideration:

Definition: Let ##C = \int_{-\infty}^{+\infty} e^{-x^2}##.

Fact 1: If ##f(x) = \int_{-\infty}^{+\infty} \tilde{f}(k) e^{ikx} dk##, then ##\tilde{f}(k) = \frac{1}{2\pi} \int_{-\infty}^{+\infty} f(x) e^{-ikx} dx## (assuming that ##f(x)## is a nicely behaved function).

Let ##\tilde{f}(k) = e^{-k^2}##. Then we can compute ##f(x)## using

##f(x) = \int_{-\infty}^{+\infty} \tilde{f}(k) e^{ikx} dk = \int_{-\infty}^{+\infty} e^{-k^2} e^{ikx} dk##

In the integral on the right, we can let ##u = k - ix/2##, so it becomes

##f(x) = \int_{-\infty}^{+\infty} e^{-(u + ix/2)^2 - x^2/4} du = e^{-x^2/4} C##

Now, integrate that:
##\int_{-\infty}^{+\infty} f(x) dx = C \int_{-\infty}^{\infty} e^{-x^2/4} dx = 2 C^2##

Using Fact 1 with ##k=0## gives us

##\tilde{f}(0) = \frac{1}{2\pi} \int_{-\infty}^{+\infty} f(x) dx = C^2/\pi##

But by definition of ##\tilde{f}##, ##\tilde{f}(0) = 1##

So we conclude ##C^2/\pi = 1## so ##C = \sqrt{\pi}##

Proof of Fact 1:

Proving Fact 1 is probably harder than doing the gaussian integral in the first place. Here's my attempt:

We assume that ##f(x) = \int_{\infty}^{\infty} \tilde{f}(k) e^{ikx}##

Now, multiply both sides by ##e^{-i k' x}## and integrate from ##-L## to ##+L##

##\int_{-L}^{L} f(x) e^{-ik'x} dx = \int_{-L}^{L} dx \int_{-\infty}^{\infty} dk \tilde{f}(k) e^{i (k-k')x}##

Assuming that ##\tilde{f}(k)## behaves nicely, we can interchange the order of integration to get

## \int_{-\infty}^{\infty} dk \tilde{f}(k) \int_{-L}^{L} dx e^{i (k-k')x}##

The inner integral evaluates to ##2 \dfrac{sin((k-k') L}{k-k'}##

So the double integral becomes:
## 2 \int_{-\infty}^{\infty} dk \tilde{f}(k) \dfrac{sin((k-k') L}{k-k'}##

At this point, we can change variables to ## u = (k-k') L##, so it becomes:

## 2 \int_{-\infty}^{\infty} du \tilde{f}(k' + \frac{u}{L}) \dfrac{sin(u)}{u}##

Now, we can take the limit as ##L \rightarrow \infty##. The answer is:

## 2 \tilde{f}(k') \int_{-\infty}^{\infty} \dfrac{sin(u)}{u} du##

If we call the integral ##K##, then we find:

##\tilde{f}(k') = \frac{1}{2K} \int_{-\infty}^{\infty} f(x) e^{-ik' x} dx##

So to get Fact 1, we need the following fact:

## \int_{-\infty}^{\infty} \dfrac{sin(u)}{u} du = \pi##

I don't know of an easy way to prove it (it can be proved by contour integration in the complex plane).

• etotheipi
## \int_{-\infty}^{\infty} \dfrac{sin(u)}{u} du = \pi##

I don't know of an easy way to prove it (it can be proved by contour integration in the complex plane).

Here's an easy way:

Here's an easy way:

Very nice. I wouldn't exactly call it "easy", but it doesn't require knowledge of complex integration.