Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

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?

share|improve this question

marked as duplicate by Sjoerd C. de Vries, Daniel Lichtblau, rcollyer, whuber, rm -rf Feb 11 '13 at 19:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Welcome to Mathematica.SE!. Please, post the Mathematica code you tried. –  belisarius Feb 10 '13 at 21:52
Check the > Scope > Integrals over Regions part of the Integrate documentation for some examples –  ssch Feb 10 '13 at 21:56
@ssch Oh, I didn't realize there is a tutorial on this topic. I only searched the examples in vain. Thanks. –  KevinSayHi Feb 10 '13 at 22:30
I think this question puts the issue more clearly and concisely than the referenced question that it allegedly duplicates. –  m_goldberg Feb 11 '13 at 0:51

1 Answer 1

up vote 7 down vote accepted


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.

share|improve this answer
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

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