Rapid execution of gaussian integrals

*To*: mathgroup at smc.vnet.net*Subject*: [mg68732] Rapid execution of gaussian integrals*From*: AES <siegman at stanford.edu>*Date*: Thu, 17 Aug 2006 04:18:40 -0400 (EDT)*Organization*: Stanford University*Sender*: owner-wri-mathgroup at wolfram.com

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.