I would like to evaluate the following integral in Mathematica

$$\int _{-\infty }^{\infty }\int _{-\infty }^{\infty }\frac{\exp \left(-\frac{\frac{\left(x-\mu _1\right){}^2}{\sigma _1^2}-\frac{2 \rho \left(x-\mu _1\right) \left(y-\mu _2\right)}{\sigma _1 \sigma _2}+\frac{\left(y-\mu _2\right){}^2}{\sigma _2^2}}{2 \left(1-\rho ^2\right)}+i \left(x k_x+y k_y\right)\right)}{2 \pi \sqrt{1-\rho ^2} \sigma _1 \sigma _2}dydx,$$

Where all of the variables besides the integration variables are real and $\rho \neq 1$. Currently, Mathematica simply returns the input. Anyway to force it to evaluate?


Integrate[E^(I (x Subscript[k, x] + y Subscript[k, y]) - ((x - Subscript[μ, 1])^2/ \!\(\*SubsuperscriptBox[\(σ\), \(1\), \(2\)]\) + (y - Subscript[μ, 2])^2/\!\(\*SubsuperscriptBox[\(σ\), \(2\), \(2\)]\) - (2 ρ (x - Subscript[μ, 1]) (y - Subscript[μ, 2]))/(Subscript[σ, 1] Subscript[σ, 2]))/(2 (1 - ρ^2)))/(2 π Sqrt[1 - ρ^2] Subscript[σ, 1] Subscript[σ,2]), {x, -∞, ∞}, {y, -∞, ∞}]
  • $\begingroup$ It would make it easier for others to help you if you would provide some code to copy... $\endgroup$ – Henrik Schumacher Jul 5 '17 at 15:36
  • $\begingroup$ Seems like you could simplify this integral by changing the variables of integration to a basis which is around ($\mu_1$,$\mu_2$). So basically doing a main axis transformation that maps your ellipse with center ($\mu_1$,$\mu_2$) with semi major axes ($\sigma_1$,$\sigma_2$) to the unit circle. $\endgroup$ – Thies Heidecke Jul 5 '17 at 15:38
  • 1
    $\begingroup$ Mathematica can't figure out how Subscript[k, x] depends on your variable x. $\endgroup$ – John Doty Jul 5 '17 at 16:02
  • 2
    $\begingroup$ @JohnDoty, Yes! I see it highlighted! I didn't notice it was linking the integration variable to the subscripts. $\endgroup$ – Sid Jul 5 '17 at 16:12
  • 3
    $\begingroup$ @JohnDoty Good point. Subscript is a nasty things to use. @Sid You probably make many implicit assumptions on what values all the parameters have: sigmas are positive, 0<rho<1 etc. You can help Integrate by making your hidden assumptions official with the help of the option Assumptions. See the documentation on how to use it. You might also consider to use FourierTransform. $\endgroup$ – Henrik Schumacher Jul 5 '17 at 16:21

For integrals involving Gaussians, I've often found it to be more convenient to get integrals via the Expectation value of the MultinormalDistribution.

You can directly apply a convenience function gaussMoment that I posted for that purpose in my answer to How to deal with complicated Gaussian integrals in Mathematica. I'm copying it here:

gaussMoment[fPre_, fExp_, vars_] := 
 Module[{coeff, dist, ai, μ, norm}, 
  coeff = CoefficientArrays[fExp, vars, "Symmetric" -> True];
  ai = Inverse[2 coeff[[3]]];
  μ = -ai.coeff[[2]];
  dist = MultinormalDistribution[μ, -ai];
  norm = 1/PDF[dist, vars] /. Thread[vars -> μ];
   norm Exp[1/2 coeff[[2]].μ + coeff[[1]]] Distribute@
     Expectation[fPre, vars \[Distributed] dist]]]

In the first argument, you have to specify the quantity whose expectation value you're interested in, and in the second argument you enter the quadratic polynomial in the exponent of your Gaussian. The integral is done over the variables that you provide as the third argument.

The function doesn't assume that the Gaussian is normalized (it undoes the normalization in Expectation). You could adapt that to your needs if desired.

In your application, I would then use the complex exponentials representing the Fourier basis as the first argument. For the second argument, I just copy the polynomial from your question:

 Exp[I (kx x + ky y)], 
  -((x - μ1)^2/σ1^2) - (y - μ2)^2/σ2^2 + (2 ρ (x - μ1) (y - μ2))/(σ1 σ2), 
  {x, y}]

$$\pi \sqrt{-\frac{\text{$\sigma $1}^2 \text{$\sigma $2}^2}{\rho ^2-1}} \exp \left(\frac{\text{kx}^2 \text{$\sigma $1}^2+2 \text{kx} \left(\text{ky} \rho \text{$\sigma $1} \text{$\sigma $2}+2 i \text{$\mu $1} \left(\rho ^2-1\right)\right)+\text{ky} \left(\text{ky} \text{$\sigma $2}^2+4 i \text{$\mu $2} \left(\rho ^2-1\right)\right)}{4 \left(\rho ^2-1\right)}\right)$$

As mentioned in the comments to the question, it's a good idea to avoid using Subscript except in typesetting formulas for presentation only, so I made that change.

|improve this answer|||||

Just following the advice of @HenrikSchumacher and @JohnDoty gets you an explicit result:

Integrate[E^(I (x kx + y ky) - ((x - μ1)^2/ σ1^2 + (y - μ2)^2/σ2^2 -
  (2 ρ (x - μ1) (y - μ2))/(σ1 σ2))/(2 (1 - ρ^2)))/(2 π Sqrt[1 - ρ^2] σ1 σ2),
  {x, -∞, ∞}, {y, -∞, ∞}, 
  Assumptions -> {μ1 ∈ Reals, μ2 ∈ Reals, σ1 > 0, σ2 > 0, kx ∈ Reals, ky ∈ Reals,
  -1 < ρ < 1}]

E^(I kx μ1 + I ky μ2 - (kx^2 σ1^2)/2 -kx ky ρ σ1 σ2 - (ky^2 σ2^2)/2)

The same answer is obtained using the Expectation function:

Expectation[Exp[I (kx x + ky y)],
  {x, y} \[Distributed] BinormalDistribution[{μ1, μ2}, {σ1, σ2}, ρ]]
|improve this answer|||||

As explained by John Dotty in the comments, Mathematica can't figure out how Subscript[k, x] depends on your variable x. The solution is to change the Fourier variables so that they don't contain the integration variables.

|improve this answer|||||

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