I'm trying to evaluate the following integral

$$\int_{-\infty}^\infty \int_{-\infty}^\infty \exp\left(-\frac{(x-x_0)^2}{2}-\frac{(y-y_0)^2}{2}\right)\log\left(e^{-x x_0}+e^{x x_0}+2\cos(x_0(y+y_0))\right) \mathrm dx\mathrm dy$$

where the parameters $x_0$ and $y_0$ are positive real numbers.

p0 = 2

fct = Exp[-(1/2)*(x - x0)^2 - (1/2)*(y - y0)^2] * Log[Exp[-x*x0] + 
  Exp[x*x0] + 2*Cos[x0*(y + y0)]]

intfct = Integrate[fct, {x, -∞, ∞}, {y, -∞, ∞}, Assumptions -> x0 >= 0]

Is there any way to solve the integral analytically or numerically?

  • 1
    $\begingroup$ To enable people to copy and paste, enter your code in code blocks rather than TeX or images of expressions. See How to copy code from Mathematica so it looks good on this site $\endgroup$
    – Bob Hanlon
    May 23, 2017 at 5:11
  • $\begingroup$ @user448659, if this is your question, please go here to get your accounts merged. $\endgroup$ May 23, 2017 at 6:30
  • $\begingroup$ The second term in your integrand seems to be causing the difficulty. If I look at With[{x0=6, y0=2}, Plot3D[Log[Exp[-x x0]+Exp[x x0]+2 Cos[x0 (y+y0)]], {x,-8,8}, {y,-4,4}]] it seems your second term might be close to a constant times x (must make this work for + and - x without introducing ABS). Then Integrate[Exp[-(x+x0)^2/2 - (y-y0)^2/2] 5 Sqrt[x^2], {x,-Infinity,Infinity}, {y,-Infinity,Infinity}] quickly gives a result. BUT you have to determine whether this is a good enough approximation. $\endgroup$
    – Bill
    May 23, 2017 at 6:52

1 Answer 1


Because of the $\log$ term, I doubt that there is any tractable analytic solution. However, numerical integration is immediate:

int[a_, b_][x_, y_] := Exp[-(1/2)(x + a)^2 - (1/2)(y - b)^2] *
  Log[E^(-a x) + E^(a x) + 2 Cos[a (y + b)]]

nint[a_, b_] := NIntegrate[
  int[a, b][x, y], {x, -Infinity, Infinity}, {y, -Infinity, Infinity}]

E.g. try nint[1,2].

One useful transformation for (doubly-)infinite integrals, especially those involving Gaussian functions, is to observe that the integral must be invariant under linear transformation of each variable, e.g. $x\to x-a$ and $y\to y+b$. Applying this transformation to the integrand,

int[a, b][x - a, y + b] // FullSimplify

yields a (somewhat) simplified expression.

One sees that this integral is independent of $b$ for $a=0$ and evaluates to $\pi \log (16)$.

Also, because the transformed integral involves $\cos (a (2 b+y))$—and this is the only place that $b$ appears in the integrand—the integral has to be periodic in $b$ with period $\frac{\pi }{a}$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.