# Evaluating this generalised integral

I have the following integral

$$\int _{-\infty }^{\infty }\int _{-\infty }^{\infty }\exp \left(a u^2+b v^2+c u v\right) \; dvdu,$$

which returns the following solution:

$$\frac{2 \pi }{\sqrt{4 a b-c^2}}.$$

I would like to generalise the integral to define the following function:

$$f[x, y] := \int _{-\infty }^{\infty }\int _{-\infty }^{\infty }\exp \left(a u^2+b v^2+c u v\right) u^x v^y\; dvdu,$$

which Mathematica generates a solution to in terms of Hypergeometric functions but crucially it is a function of x and y. I would like to use this function for a range of different x and y, i.e.

Table[f[x,y], {x,0,10}, {y,0,10}]


As a cross check, I would like to get a consistent result when $$x=y=0$$. The issue is that when I try to evaluate f[0,0], I get Indeterminate due to a 0 ComplexInfinity. I.e. this doesn't reproduce the result at the top. A same issue occurs for f[0,2].

Is there a fix to this? Can I define cases where it breaks?

• Can you use Limit to find the value at zero? – mikado Apr 10 at 10:01
• @mikado, I would like to use the function for higher values of x and y. I get a complex infinity with x=0 and y=2 too – Sid Apr 10 at 10:14
• @Sid I get a real result like this: With[{x = 0, y = 2}, Integrate[Exp[a u^2 + b v^2 + c u v] u^x v^y, {v, -∞, ∞}, {u, -∞, ∞}]]  – flinty Apr 10 at 11:26
• Looks like: $$\fbox{\frac{\pi }{\sqrt{-a} \sqrt{-b} \sqrt{1-\frac{c^2}{4 a b}}}\text{ if }b<0\land a<0\land c^2 \Re\left(\frac{1}{a b}\right)<4}$$ – Mariusz Iwaniuk Apr 10 at 11:37
• Integrate[ Exp[a*u^2 + b*v^2 + c*u*v]*v^2, {u, -Infinity, Infinity}, {v, -Infinity, Infinity}] results in ConditionalExpression[-(( 4 a Sqrt[-b] Sqrt[-4 a + c^2/b] \[Pi])/(-4 a b + c^2)^2), Re[a - c^2/(4 b)] < 0] which is not true (see at the result of Plot3D[Exp[2*u^2 + 1*v^2 + 2*u*v]*v^2, {u, -5, 5}, {v, -5, 5}]). Submit a report to Wolfram Technical Support. – user64494 Apr 10 at 12:21

(Thanks @DanielLichtblau for his helpful comment)

Here my ideas to make it work:

Mathematica evaluates the first integral to

Integrate[Exp[a u^2 + b v^2 +c u v], {v, -∞,∞}, {u, -∞, ∞},Assumptions -> {Element[{a, b, c}, Reals] ]
(*ConditionalExpression[(2 \[Pi])/(Sqrt[-b]Sqrt[-4 a + c^2/b]),
4 a b^2 < b c^2] *)


result is correct but the condition is wrong!

stepwise integration

Assuming a!=0 the integral

Integrate[Exp[a (u + c/(2 a) v)^2 ]Exp[a (b/a - (c/(2 a))^2) v ^2 ] , {u, -\[Infinity], \[Infinity]}, {v, -\[Infinity], \[Infinity]}] is transformed to

Integrate[Integrate[Exp[a (u + c/(2 a)v)^2], {u, -\[Infinity], \[Infinity]} ] Exp[a (b/a - (c/(2 a))^2) v^2], {v, -\[Infinity], \[Infinity]}]
(* ConditionalExpression[(2 \[Pi])/(Sqrt[-a]Sqrt[-4 b + c^2/a]), Re[a] < 0 && Re[c^2/a] > 4 Re[b]]*)


with correct conditions a<0 && c^2< 4 a b

Take these condition for the general case

int = Function[{x, y},
Evaluate@Integrate[Exp[a u^2 + b v^2 + c u v] u^x v^y, {v, -∞, ∞}, {u, -∞, ∞},
Assumptions -> {Element[{a, b, c}, Reals], a<0,c^2< 4 a b}]]


These evaluate the mentioned cases as expected

Limit[int[x, y], {x -> 0, y -> 0}]
(*ConditionalExpression[(2 \[Pi])/(Sqrt[-a] Sqrt[-b] Sqrt[4 - c^2/(a b)]), c <0]*)

int[0,2]
(*ConditionalExpression[(a \[Pi])/(2 (-a)^(3/2) Sqrt[-b] b (1 - c^2/(4 ab))^(3/2)), c < 0]*)

• -1. Your statement "First integral only converges if 4 a^2 b < a c^2" is ungrounded and does not correspond to reality: put a=1;b=1;c=3, then NIntegrate[Exp[1*u^2 + 1*v^2 + 3*u*v], {u, -10, 10}, {v, -10, 10}] results in 5.63016*10^213..Also see Plot3D[Exp[u^2 + v^2 + 3*u*v]*v^2, {u, -5, 5}, {v, -5, 5}]. Your mistake consists in the following. In the case a=1;b=1;c=3 the integrand takes big valuea in the first and third quadrants and approaches zero in the second and fourth quadrants. In any case, the integrand is positive. Don't hesitate to ask for further explanation in need. – user64494 Apr 10 at 13:56
• @user64494 The condition is well grounded it we trust Mathematicas Integrate function. Integrate[ Exp[a u^2 + b v^2 + c u v], {v, -\[Infinity], \[Infinity]}, {u, -\[Infinity], \ \[Infinity]}, Assumptions -> {Element[{a, b, c}, Reals]}] . If not there is nothing left from this question to discuss about. By the way your "scoring" is dispensable... – Ulrich Neumann Apr 10 at 14:09
• A correct set of conditions would be {a<0,b<0,c^2<4*a*b}. This implies the condition provided by Integrate, but not the other way around. This mishap notwithstanding, the method is otherwise sound. Which is to my surprise, since I did not expect a result that would be amenable to Limit. But I'd add assumptions such as x,y>-1 to simplify things. – Daniel Lichtblau Apr 10 at 15:10
• I wonder the upvotes for the wrong answer dropbox.com/s/10sed1oaee273ac/…. – user64494 Apr 10 at 15:26
• @DanielLichtblau Thank you for your helpful comment. The condition 4 a^2 b < a c^2  Mathematica provides after Integrate[ Exp[a u^2 + b v^2 + c u v], {v, -\[Infinity], \[Infinity]}, {u, -\[Infinity], \ \[Infinity]}, Assumptions -> {Element[{a, b, c}, Reals] }] is wrong! If I integrate step by step Mathematica creates two conditions a<=0&&c^2 < 4 a^2 b` – Ulrich Neumann Apr 11 at 8:02