MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Rapid execution of gaussian integrals

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68812] Re: Rapid execution of gaussian integrals
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Sat, 19 Aug 2006 00:41:28 -0400 (EDT)
  • Organization: The University of Western Australia
  • References: <ec1b5t$p0b$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <ec1b5t$p0b$1 at smc.vnet.net>, AES <siegman at stanford.edu> 
wrote:

> I recently posted about very slow execution of infinite symbolic 
> integrals of the general form
> 
>    Integrate[const * Exp[-A x^2 + 2 B x], {x, -Infinity, Infinity},]
> 
> when A and B are constant-valued expressions of even modest complexity, 
> even when one inserts the necessary Assumptions to make the integral 
> convergent.
> 
> Daniel Lichtbau replied with some helpful suggestions on how to speed 
> things up a bit; but to really speed things up I've since been using the 
> brute force approach
> 
>    gaussianIntegral[func_, x_] : = Module[ {exp, A, B, C, const},        
>          exp = Exponent[func, E];    
>          A = Coefficient[-exp ,x, 2];    
>          B = Coefficient[ exp, x, 1]/2;    
>          C = Coefficient[ exp, x, 0];    
>          const=func/Exp[exp];    
>          const Sqrt[Pi/A] Exp[ (B^2/A) + C]]
> 
> Crude, but seems to work OK for everything I've thrown at it so far.  If 
> anyone has any criticism or warnings, I'll be glad to learn from them.

This approach should work fine as long as your integrals are convergent.

Another approach is to use pattern-matching. Don't work with integrals, 
just with integrands (as you are doing with gaussianIntegral):

 E^(a_ x^2 + b_ x + c_) :> (E^(c - b^2/(4 a)) Sqrt[Pi])/Sqrt[-a]

To get exponentials such as Exp[a (x+1)^2] into this form, one can use

  E^(z_) :> E^Collect[z, x]

Cheers,
Paul

_______________________________________________________________________
Paul Abbott                                      Phone:  61 8 6488 2734
School of Physics, M013                            Fax: +61 8 6488 1014
The University of Western Australia         (CRICOS Provider No 00126G)    
AUSTRALIA                               http://physics.uwa.edu.au/~paul


  • Prev by Date: Re: Re: word problem
  • Next by Date: Re: Simplifying a Boolean Expression
  • Previous by thread: Re: Problems solving using Solve
  • Next by thread: solve differential equation problem