MathGroup Archive 2006

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

Search the Archive

Rapid execution of gaussian integrals

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 

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

  • Prev by Date: Re: namespace collision [bug]
  • Next by Date: Re: Product over an arbitrary index.
  • Previous by thread: Re: "Skip this Input cell" module?
  • Next by thread: word problem