# Gaussian function integral

Is it possible to obtain a sigma function or Taylor series function for the indefinite integral of a general Gaussian function? If not, why not, and if so, where can I find this infinite series solution?

By general Gaussian function I mean

$$f(x) = a \cdot e^{-\frac{(x-b)^2}{2c^2}} + d$$

Staff Emeritus
Homework Helper
If you want to expand out f(x) into an infinite series and integrate term by term, you can certainly do that.

Happily, others have done that for you. Check out Abramowitz and Stegun, p. 931 and following:

http://people.math.sfu.ca/~cbm/aands/page_931.htm

Homework Helper
What sigma function do you mean The sum-of-divisors function σ(n), Weierstrass sigma function, Kronecker's sigma function, Rado's sigma function? Not sure any of those help. Indefinite integrals of Gaussians are often expressed in terms of special functions like the error function, the Faddeeva function, the Q-function, the normal cumulative distribution function, the Dawson function, and others. Such functions can be computed with tables, calculators, or computers. There are infinite series as well.

If you want to expand out f(x) into an infinite series and integrate term by term, you can certainly do that.

Happily, others have done that for you. Check out Abramowitz and Stegun, p. 931 and following:

http://people.math.sfu.ca/~cbm/aands/page_931.htm

I am afraid that I can't see where in the link the infinite series form of the general Gaussian I wrote is presented? Which of the equations is it, and if it's not given there, could you possibly suggest what the infinite series itself would be? I can work on integrating it separately if the integral is unavailable.

Homework Helper
^Did you keep reading? The power series is on page 932. There are some other good things past that. That you might be interested in. Your form is not common, can you write your integral in terms of P?

$$\mathrm{P}(x)=\frac{1}{\sqrt{2 \pi}}\int_{-\infty}^x \! e^{-t^2/2} \, \mathrm{dt} = \frac{1}{2} + \frac{1}{\sqrt{2 \pi}} \sum_{n=0 } ^\infty \frac{ (-1)^n x^{2n+1} }{n! 2^n (2n+1)}$$

Last edited:
Staff Emeritus
He apparently wants the power series of e-x2 rather than of the CDF.

This is trivial, Big Daddy. You are making it much more complex than needed by adding those terms a, b, c, and d. Just develop the power series of e-x2 and then substitute.

^Did you keep reading? The power series is on page 932. There are some other good things past that. That you might be interested in. Your form is not common, can you write your integral in terms of P?

$$\mathrm{P}(x)=\frac{1}{\sqrt{2 \pi}}\int_{-\infty}^x \! e^{-t^2/2} \, \mathrm{dt} = \frac{1}{2} + \frac{1}{\sqrt{2 \pi}} \sum_{n=0 } ^\infty \frac{ (-1)^n x^{2n+1} }{n! 2^n (2n+1)}$$

So this is the integral of the normalized distribution function? Ok but there are two remaining issues with it: 1) it is a definite integral whereas as in the OP I am looking for an indefinite integral; 2) it applies to a function where a, b, c, d are all treated as 1.

Just develop the power series of e-x2 and then substitute.

So first I have to develop this infinite series expansion of e-x2; then substitute in for a, b, c and d, to find the infinite series expansion of my OP function; then integrate each term with respect to x? Let me start about the task and I will post here when I hit a barrier.

Staff Emeritus
Oh. You do want the integral. I misread. Nonetheless, using the expansion of e-x2 is a good place to start.

Is this homework?

No. In fact I've heard from various sources it is not even possible (note please as I said I am looking for the indefinite, not infinite, integral). But since you guys are saying it is, I thought I would follow up with you.

So then

$$e^{-x^2} = \sum\limits_{j = 0}^\infty {\frac{(-x^2)^j}{j!}}$$

What next?

Staff Emeritus
No. In fact I've heard from various sources it is not even possible (note please as I said I am looking for the indefinite, not infinite, integral). But since you guys are saying it is, I thought I would follow up with you.
Of course it's possible. Your various sources are probably assuming that since ∫e-x2dx cannot be expressed in "closed form" (a finite set of operations involving elementary functions) that it can't be expressed as an infinite series, either. That's just wrong. It's easy to express that integral as an infinite series.

So then

$$e^{-x^2} = \sum\limits_{j = 0}^\infty {\frac{(-x^2)^j}{j!}}$$

What next?
That series is absolutely convergent, so you can integrate it term by term. Voila! ∫e-x2dx as an infinite series. You do need to check whether the series is convergent (which it is).

Staff Emeritus
Homework Helper
'Street math' like 'Street physics' is not to be trusted.

That series is absolutely convergent, so you can integrate it term by term. Voila! ∫e-x2dx as an infinite series. You do need to check whether the series is convergent (which it is).

Ok so I found that the integral as an infinite series is

$$\sum\limits_{j = 0}^\infty {\frac{x(-x^2)^j}{2jj!+j!}}$$

What is the generalization of this to the case in the OP?

'Street math' like 'Street physics' is not to be trusted.

What do you mean by that?

Staff Emeritus
Ok so I found that the integral as an infinite series is

$$\sum\limits_{j = 0}^\infty {\frac{x(-x^2)^j}{2jj!+j!}}$$

What is the generalization of this to the case in the OP?
The final additive constant d is just noise, as is the multiplicative factor of a. Substitute x with (x-b)/(√2 c) in the series you wrote and you have the series representation of e(x-b)2/(2c2).

The final additive constant d is just noise, as is the multiplicative factor of a. Substitute x with (x-b)/(√2 c) in the series you wrote and you have the series representation of e(x-b)2/(2c2).

Wouldn't this be the series representation of the integral of e(x-b)2/(2c2) dx rather than of e(x-b)2/(2c2) itself?

And to modify for a and d we just need to multiply the above integral by a and add a +dx term (d being the symbol in the OP not the differential operator) to the end?

Staff Emeritus
Homework Helper
No. In fact I've heard from various sources it is not even possible (note please as I said I am looking for the indefinite, not infinite, integral). But since you guys are saying it is, I thought I would follow up with you.

So then

$$e^{-x^2} = \sum\limits_{j = 0}^\infty {\frac{(-x^2)^j}{j!}}$$

What next?

'Street math' like 'Street physics' is not to be trusted.

What do you mean by that?

People hear this or that from various unnamed sources and believe what they hear without verification. It's the equivalent of circulating a rumor: the rumor could sound entirely plausible but be totally untrue, and this situation will not become apparent unless some attempt is made to verify the rumor. That's why scientific writing is chock full of proofs and references, to avoid having misconceptions or outright falsehoods breed and propagate, preventing people from utilizing science correctly and sometimes not at all. The latter is what happened to you, albeit temporarily, until you got the straight dope here at PF.

Staff Emeritus
Wouldn't this be the series representation of the integral of e(x-b)2/(2c2) dx rather than of e(x-b)2/(2c2) itself?
Sorry about that. I omitted the integral sign (and dx). I also omitted a factor of ##2c## because the u substitution ##u = \frac {x-b} {2c}## means that ##dx = 2c\,du##.

And to modify for a and d we just need to multiply the above integral by a and add a +dx term (d being the symbol in the OP not the differential operator) to the end?
Correct.

Or you could just use the error function erf(x):
$$\int \left( a e^{-\left( \frac {x-b}{2c} \right)^2} + d \right)\, dx = \sqrt{\pi} \, a c \operatorname{erf} \left( \frac {x-b}{2c} \right) + dx$$

erf(x) is a non-elementary "special function" -- something that comes up so very often that it deserves a special name. You'll be able to find erf(x) as a library function in C/C++, Fortran, python, matlab, Mathematica, maple, and even Excel.

Thanks. So the final solution would be

$$a \cdot \sum\limits_{j = 0}^\infty {\frac{\frac{x-b}{\sqrt{2}c} \cdot (-\frac{(x-b)^2}{2c^2})^j}{2jj!+j!}} + dx$$

For the integral in the OP?

Staff Emeritus
You dropped some multiplicative factors. That should be
$$dx + a c \surd 2 \sum_{k=0}^{\infty} \frac {(-1)^k \bigl( \frac {x-b}{\surd 2 c} \bigr)^{2k+1}} {(2k+1)k!}$$

Or, much more simply,

$$dx + \sqrt{\frac {\pi} 2} \, a c \, \operatorname{erf}\bigl( \frac {x-b}{\surd 2 c} \bigr)$$

jackmell
Why don't we just expand $e^{u}$ as it's Taylor series, and then just integrate. When I do that, I get:

$$\int a e^{-\frac{(x-b)^2}{2 c^2}}+d=a\left(x+\sum_{n=1}^{\infty} \frac{(-1)^n (x-b)^{2n+1}}{(2n+1) 2^n c^{2n} n!}\right)+dx+k$$

Now, let's check that with:

$$\int_1^5 \left(a e^{-\frac{(x-b)^2}{2 c^2}}+d\right) dx$$

with: a=1/2, b=2/3, c=4/5, and d=-6:

Code:
In[1347]:=
a = 1/2;
b = 2/3;
c = 4/5;
d = -6;
f[x_] := a*Exp[-((x - b)^2/(2*c^2))] + d;
NIntegrate[f[x], {x, 1, 5}]
mysum[x_] :=
a*(x + Sum[((-1)^n*(x - b)^(2*n + 1))/
((2*n + 1)*2^n*c^(2*n)*n!), {n, 1, 50}]) +
d*x
N[mysum[5] - mysum[1]]

Out[1352]=
-23.660641545629247

Out[1354]=
-23.660641542363546

Thanks for the help. I take it the two solutions above are ultimately equivalent though they do not obviously seem so to me.

This series would not be convergent for the well-known infinite integral (from -infinity to +infinity) of the simple Gaussian (a=1, b=0, c=1, d=0) which gives the famous sqrt(pi) result, would it?

jackmell
This series would not be convergent for the well-known infinite integral (from -infinity to +infinity) of the simple Gaussian (a=1, b=0, c=1, d=0) which gives the famous sqrt(pi) result, would it?

Please provide empirical data to substantiate your claim and shouldn't that be $c=1/\sqrt{2}$? Do this: code the series in Mathematica and study it's behavior for a larger and larger symmetric interval about the origin as a function of number of terms. That is, say compute the series with 100 terms for an integral in the interval (-5,5), then 500 terms for (-10,10), 5000 terms for (-25,25) and so on. Does the numerical data suggest the series data is converging to $\sqrt{\pi}$ or diverging? By next Monday morning would be fine. :)

Last edited:
Please provide empirical data to substantiate your claim and shouldn't that be $c=1/\sqrt{2}$?

Yes of course, that's right. Silly mistake.

Do this: code the series in Mathematica and study it's behavior for a larger and larger symmetric interval about the origin as a function of number of terms. That is, say compute the series with 100 terms for an integral in the interval (-5,5), then 500 terms for (-10,10), 5000 terms for (-25,25) and so on. Does the numerical data suggest the series data is converging to $\sqrt{\pi}$ or diverging? By next Monday morning would be fine. :)

I'm afraid that I don't have Mathematica nor any mathematical computing program with this power (unless Excel can somehow integrate, in which case I'm not sure how). I was hoping you could confirm whether or not the integral from -infinity to +infinity will converge to sqrt(pi) but, from a glance looking at the integral, it does not seem to obviously simplify to this answer. We could and should be able to find the sqrt(pi) solution using limits that are approximations of -infinity and +infinity, of course, and watching the result tend to sqrt(pi).

jackmell
I do not know how to prove or disprove the sum converges to the value of the improper integral.

Last edited: