5

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?

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
4ae1e1
  • 295
  • 2
  • 8

1 Answers1

8

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.

murray
  • 11,888
  • 2
  • 26
  • 50
  • 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 – ssch Feb 10 '13 at 22:19
  • @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? – murray Feb 11 '13 at 14:14