# double integral on non-rectangular area

**URL:** <https://community.wolfram.com/t/double-integral-on-non-rectangular-area/4120>\
**Category:** Questions\
**Tags:** mathematica\
**Created:** [November 25, 2014, 2:53pm UTC](https://community.wolfram.com/t/double-integral-on-non-rectangular-area/4120 "2014-11-25T14:53:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreavc02](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@andreavc02](https://community.wolfram.com/u/andreavc02)\
**Post date:** [November 25, 2014, 2:53pm UTC](https://community.wolfram.com/t/double-integral-on-non-rectangular-area/4120/1 "2014-11-25T14:53:21Z")

</div>

How can I do it on Mathematica 9?

Ex: integral of sqrt(4-x^2-y^2) dy dx where x^2+y^2-2\*x\<=0.

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [November 25, 2014, 3:50pm UTC](https://community.wolfram.com/t/double-integral-on-non-rectangular-area/4120/2 "2014-11-25T15:50:53Z")

</div>

In[1]:= Integrate[  
Sqrt[4 - x^2 - y^2]\*  
Boole[x^2 + y^2 - 2 x \<=  
0], {x, -[Infinity], [Infinity]}, {y, -[Infinity], [Infinity]}]

```
Out[1]= 8/9 (-4 + 3 \[Pi])

```

---

<div class="post-metadata">

**Author:** ![andreavc02](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@andreavc02](https://community.wolfram.com/u/andreavc02)\
**Post date:** [November 26, 2014, 2:42am UTC](https://community.wolfram.com/t/double-integral-on-non-rectangular-area/4120/3 "2014-11-26T02:42:23Z")

</div>

Wow! Very good. Thanks!

---

<div class="post-metadata">

**Author:** ![andreavc02](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@andreavc02](https://community.wolfram.com/u/andreavc02)\
**Post date:** [November 26, 2014, 3:00am UTC](https://community.wolfram.com/t/double-integral-on-non-rectangular-area/4120/4 "2014-11-26T03:00:21Z")

</div>

Integrate[(x^2 + y^2)\*Boole[(x - z)^2 + (y - z)^2 \<= 1], {x, -1,  
3}, {y, -1, 3}, {z, 0, 2}]. I left my notebook computing about a half an hour and nothing happened.

---

<div class="post-metadata">

**Author:** ![dlkeith](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dlkeith/32/31494_2.png) [@dlkeith](https://community.wolfram.com/u/dlkeith)\
**Post date:** [November 26, 2014, 3:58am UTC](https://community.wolfram.com/t/double-integral-on-non-rectangular-area/4120/5 "2014-11-26T03:58:56Z")

</div>

Me too, but it’s an interesting 3D problem.

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [November 26, 2014, 1:18pm UTC](https://community.wolfram.com/t/double-integral-on-non-rectangular-area/4120/6 "2014-11-26T13:18:23Z")

</div>

took 11.5 seconds on my computer.

---

<div class="post-metadata">

**Author:** ![dlkeith](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dlkeith/32/31494_2.png) [@dlkeith](https://community.wolfram.com/u/dlkeith)\
**Post date:** [November 26, 2014, 5:01pm UTC](https://community.wolfram.com/t/double-integral-on-non-rectangular-area/4120/7 "2014-11-26T17:01:48Z")

</div>

1722 seconds on my laptop, for a very messy result. I wonder if we’re solving the same integral.

```
Timing[
 Integrate[(x^2 + y^2)*Boole[(x - z)^2 + (y - z)^2 <= 1], {x, -1, 
   3}, {y, -1, 3}, {z, 0, 2}]
 ]

```

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [November 26, 2014, 5:45pm UTC](https://community.wolfram.com/t/double-integral-on-non-rectangular-area/4120/8 "2014-11-26T17:45:16Z")

</div>

Where do you get the z from?

---

<div class="post-metadata">

**Author:** ![ulrichmutze](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/ulrichmutze/32/30285_2.png) [@ulrichmutze](https://community.wolfram.com/u/ulrichmutze)\
**Post date:** [November 26, 2014, 6:56pm UTC](https://community.wolfram.com/t/double-integral-on-non-rectangular-area/4120/9 "2014-11-26T18:56:53Z")

</div>

Doing the same thing numerically (using NIntegrate) gives the result 19.9868 in 0.34 s. (Mathematica 10.0, Windows 8.1). Actually the result has a tiny imaginary part 5.5 \*10^-24 as an artifact of the numerical method (‘numerical noise’).

---

<div class="post-metadata">

**Author:** ![dlkeith](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dlkeith/32/31494_2.png) [@dlkeith](https://community.wolfram.com/u/dlkeith)\
**Post date:** [November 27, 2014, 6:53pm UTC](https://community.wolfram.com/t/double-integral-on-non-rectangular-area/4120/10 "2014-11-27T18:53:13Z")

</div>

Looking at my messy result, it is actually a sum of several integrals which Mathematica returned unevaluated.
