2

How can I evaluate a double integral over a region in Mathematica?

For example

$\qquad \iint(x^4+y^2)\,dx\,dy$

for the bounded region $y=x^2$ and $y=x^3$

Jason B.
  • 68,381
  • 3
  • 139
  • 286
3SAT
  • 143
  • 1
  • 5

1 Answers1

3

In this case, we can look at the region in question and figure it out. The only closed region to integrate would be between x=0 and x=1,

Plot[{x^2, x^3}, {x, 0, 1}, Filling -> {1 -> {2}}]

enter image description here

So you can restrict the x range of the integral to {0,1}, and then the limits for the y integral are the lower and upper curve,

$$ \int_0^1 dx \int_{x^3}^{x^2} dy \,\, x^4+y^2 $$

Integrate[x^4 + y^2, {x, 0, 1}, {y, x^3, x^2}]
(* 9/280 *)

As pointed out by Artes, the order of integration can be reversed, by writing it as such:

$$ \int_0^1 dy \int_{y^{1/2}}^{y^{1/3}} dx \,\, x^4+y^2 $$

Integrate[x^4 + y^2, {y, 0, 1}, {x, y^(1/2), y^(1/3)}]
(* 9/280 *)
Jason B.
  • 68,381
  • 3
  • 139
  • 286
  • Change the order of integration with respect to x and y and you'll get different values. So I don't find your answer sufficiently rigorous. I'd rather mention somtheing like here Integrate not restricting variable with Assumptions option?. By the way, isn't it a duplicate? – Artes Dec 10 '15 at 16:11
  • What do you mean get different values, Integrate[x^4 + y^2, {x, 0, 1}, {y, x^3, x^2}] == Integrate[Integrate[x^4 + y^2, {y, x^3, x^2}], {x, 0, 1}] evaluates to True. Edit: um, forget I said that, since Mma actually evaluates the limits in reverse order – Jason B. Dec 10 '15 at 16:15
  • Something like this Integrate[x^4 + y^2, {y, x^3, x^2}, {x, 0, 1}]. – Artes Dec 10 '15 at 16:16
  • @Artes, I see your point, modified the answer. The question linked to in the comments above uses Boole in the answer, which is overkill in this situation, in my opinion. – Jason B. Dec 10 '15 at 16:27
  • 5
    Integrate[x^4 + y^2, {x, y} ∈ ImplicitRegion[x^3 < y < x^2 && x > 0, {x, y}]] is an alternative. – J. M.'s missing motivation Dec 10 '15 at 16:48