# Gaussian function integral

1. Oct 12, 2013

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$$

2. Oct 12, 2013

### SteamKing

Staff Emeritus
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

3. Oct 12, 2013

### lurflurf

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.

4. Oct 13, 2013

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.

5. Oct 13, 2013

### lurflurf

^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: Oct 13, 2013
6. Oct 13, 2013

### D H

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.

7. Oct 13, 2013

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.

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.

8. Oct 13, 2013

### D H

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?

9. Oct 14, 2013

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?

10. Oct 14, 2013

### D H

Staff Emeritus
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.

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).

11. Oct 14, 2013

### SteamKing

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

12. Oct 16, 2013

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?

13. Oct 16, 2013

What do you mean by that?

14. Oct 17, 2013

### D H

Staff Emeritus
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).

15. Nov 4, 2013

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?

16. Nov 4, 2013

### SteamKing

Staff Emeritus
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.

17. Nov 4, 2013

### D H

Staff Emeritus
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$.

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.

18. Nov 4, 2013

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?

19. Nov 4, 2013

### D H

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)$$

20. Nov 4, 2013

### 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 (Text):

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