Using Mathematica, I am trying to evaluate the integral $$I=\iint_A xy\,\mathrm{d}x\,\mathrm{d}y$$ over the region $A=\{(x,y): ax^2+2hxy+by^2\le r^2\}$ where $a>0, ab-h^2>0$.

While trying to do this by hand, I changed variables $(x,y)\to(u,v)$ to get $$I=\iint_{u^2+v^2\le r^2}\left(\frac{uv}{\sqrt{ab-h^2}}-\frac{hv^2}{ab-h^2}\right)\frac{1}{\sqrt{ab-h^2}}\,\mathrm{d}u\,\mathrm{d}v$$

Now I used this code but it doesn't work:

f[u_, v_] = (u v)/Sqrt[a b - h^2]-(h v^2)/(ab-h^2);
Integrate[f[u, v]*Boole[ u^2 + v^2 <= r^2],
{u, -r, r}, {v, -r, r}, Assumptions -> {a > 0 , ab-h^2 > 0}]

By hand, I got $\displaystyle I=-\frac{\pi r^4h}{4(ab-h^2)^{3/2}}$ and I need to check my answer.

I am aware that several of these questions have been asked here before like this one, to which I reffered. I am a novice as a user of Mathematica and I would like to know how to evaluate the likes of these integrals. I changed variables to $(u,v)$ so that I can apply a polar transformation at the end while doing this by hand. But is there a way to directly evaluate general integrals like this in Mathematica without changing variables in the first place? If you guide me to a link where this has been answered before then that would be helpful too.

Here are some other links I found but I am not sure which code to use here:

Evaluation of $ \iint x^2\ dy \ dz$ with ImplicitRegion, Evaluating a surface integral

I am using Mathematica 7.0.


2 Answers 2


You've inconsistently put in/left out spaces, a b vs. ab. Also you need the assumption r > 0.

Integrate[((u v)/Sqrt[a b - h^2] - (h v^2)/(a b - h^2)) Boole[u^2 + v^2 <= r^2],
 {u, -r, r}, {v, -r, r}, 
 Assumptions -> {a > 0, a b - h^2 > 0, r > 0}]
(*  (h π r^4)/(4 (-a b + h^2))  *)

Using regions, which gives the answer the OP derived by hand:

 x y,
 {x, y} ∈ ImplicitRegion[a x^2 + 2 h x y + b y^2 <= r^2, {x, y}], 
 Assumptions -> {a > 0, a b - h^2 > 0, r > 0}]
(*  -((h π r^4)/(4 (a b - h^2)^(3/2)))  *)

Here's a way that might work in V7, but I cannot check. I relied on the form of cylindrical decomposition that Reduce returned, which in this case (of an ellipse) has a simple logical structure. (There is a way to deal with more complicated cylindrical decompositions that I've used elsewhere, but this was simpler and more easily understood.)

dom = Sequence @@ Cases[
    a > 0 && a b - h^2 > 0 && r > 0 && a x^2 + 2 h x y + b y^2 < r^2,
    {x, y}, Reals],
   _[a_, ___, v : x | y, ___, b_] :> {v, a, b}, (* inequality to iterator *)
   {x, -Sqrt[((b r^2)/(a b - h^2))], Sqrt[(b r^2)/(a b - h^2)]},
   {y, -((h x)/b) - Sqrt[(b r^2 - a b x^2 + h^2 x^2)/b^2],
     -((h x)/b) + Sqrt[(b r^2 - a b x^2 + h^2 x^2)/b^2]}

Integrate[x y, dom, Assumptions -> {a > 0, a b - h^2 > 0, r > 0}]
(*  -((h π r^4)/(4 (a b - h^2)^(3/2)))  *)
  • $\begingroup$ I am sorry to bother. Thank you. $\endgroup$ Commented Apr 8, 2018 at 11:57
  • $\begingroup$ @StubbornAtom It's no bother. :) $\endgroup$
    – Michael E2
    Commented Apr 8, 2018 at 11:58
  • $\begingroup$ So is there no way to evaluate this without changing variables? The difficulty I guess is that I cannot determine the separate ranges of $x$ and $y$. Is that correct? $\endgroup$ Commented Apr 8, 2018 at 12:10
  • $\begingroup$ Both give the same answer. So don't think there is anything wrong with the change of variables. Anyway, you have answered all my queries. $\endgroup$ Commented Apr 8, 2018 at 12:32
  • $\begingroup$ @StubbornAtom OK, I see. A square-root constant is left off the first integral. $\endgroup$
    – Michael E2
    Commented Apr 8, 2018 at 12:47

Another substitution-free method:

Simplify[Integrate[x y, {x, y} ∈ Ellipsoid[{0, 0}, Inverse[{{a, h}, {h, b}}/r^2]]],
         a > 0 && b > 0 && r > 0 && a b > h^2]
   -((h π r^4)/(4 (a b - h^2)^(3/2)))
  • $\begingroup$ Is it possible that I may not get the desired output in an older version of Mathematica using your code? $\endgroup$ Commented Apr 8, 2018 at 12:42
  • $\begingroup$ You didn't indicate what version you were using in your question. Please edit your question to include that information. $\endgroup$ Commented Apr 8, 2018 at 12:49
  • $\begingroup$ I am using version 7.0. I will keep that in mind when I post next time. $\endgroup$ Commented Apr 8, 2018 at 12:59
  • 1
    $\begingroup$ Ah, version 7... I don't think there's a substitution-free route there; Michael's route of rescaling the ellipse to a disk + converting to polar coordinates would be your best bet. $\endgroup$ Commented Apr 8, 2018 at 13:05
  • $\begingroup$ Many thanks.... $\endgroup$ Commented Apr 8, 2018 at 13:06

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.