5
$\begingroup$

Sometimes we need to integrate over some bounded region given by inequality/inequalities. Consider the following simplest example of area of an ellipse (LaTeX code):

$\int_S dx dy$, where $S = \{ x^2/a^2 + y^2/b^2 \leq 1\}$.

Is it possible to do this directly in Mathematica? If possible, how to do it?

$\endgroup$
  • 1
    $\begingroup$ Welcome to Mathematica.SE!. Please, post the Mathematica code you tried. $\endgroup$ – Dr. belisarius Feb 10 '13 at 21:52
  • 1
    $\begingroup$ Check the > Scope > Integrals over Regions part of the Integrate documentation for some examples $\endgroup$ – ssch Feb 10 '13 at 21:56
  • $\begingroup$ related: NIntegrating within an Ellipsoid and Check homework integration in Mathematica $\endgroup$ – Sjoerd C. de Vries Feb 10 '13 at 22:18
  • $\begingroup$ @ssch Oh, I didn't realize there is a tutorial on this topic. I only searched the examples in vain. Thanks. $\endgroup$ – 4ae1e1 Feb 10 '13 at 22:30
  • 2
    $\begingroup$ I think this question puts the issue more clearly and concisely than the referenced question that it allegedly duplicates. $\endgroup$ – m_goldberg Feb 11 '13 at 0:51
8
$\begingroup$

Explicitly:

Integrate[Boole[x^2/a^2 + y^2/b^2 <= 1], {x, -a, a}, {y, -b, b}, 
          Assumptions -> {a > 0, b > 0}]

Function Boole delineates the region; the Assumptions option is needed for symbolic a and b in order to allow Mathematica actually to evaluate the integral; if a and b are numeric, that option is superfluous.

$\endgroup$
  • $\begingroup$ If you integrate over the entire plane Integrate[ Boole[x^2/a^2 + y^2/b^2 <= 1],{x,-Infinity,Infinity}, {y, -Infinity, Infinity}] it will still get evaluated but return a Piecewise with conditions on a and b $\endgroup$ – ssch Feb 10 '13 at 22:19
  • $\begingroup$ @ssch: Yes, but I was trying to avoid any problems (which don't arise in this particular example) with behavior at infinity. I don't know whether that's a concern in a more general situation: I'd expect the Boole expression to prevent problems, but will it always -- what does Mathematica actually do here? $\endgroup$ – murray Feb 11 '13 at 14:14

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