Check homework integration in Mathematica

Given in my homework I have to compute (by hand) $$\iint\limits_{x^2+y^2\leq 1}(x^2+y^2)\,\mathrm dx\,\,\mathrm dy.$$ My solution so far: Let $f(x,y)=x^2+y^2$ and $K=\{(x,y)\in\mathbb{R}^2:x^2+y^2\leq 1\}$. With the transformation of polar coordinates $\varphi:(r,\phi)\mapsto(r\cdot\cos\phi,r\cdot\sin\phi)=(x,y)$ and the determinant of the Jacobian matrix $|\det D_\varphi|=r$ we can rewrite the set as $K=\{(r\cdot\cos\phi,r\cdot\sin\phi):r\in[0,1],\phi\in[0,2\pi]\}$ and our integrand too as $f(x,y)=x^2+y^2=r^2$. $$\iint\limits_K f(x,y)\,\mathrm dx\,\mathrm dy=\int\limits_0^1\int\limits_0^{2\pi}r^2\cdot |\det D_\varphi|\,\mathrm d\phi\,\mathrm dr=2\pi\int\limits_0^1r^3\,\mathrm dr=\left.2\pi\cdot\frac{1}{4}r^4\right|_0^1=\frac{\pi}{2}.$$

I now want to check the result with a CAS. I am pretty new to Mathematica so I just didn't found any clue on how to enter such an integral for computation. Any help out there?

-

1 Answer

In Mathematica:

`Integrate[Integrate[x^2 + y^2, {x, -Sqrt[1 - y^2], Sqrt[1 - y^2]}], {y, -1, 1}]`

Or, shorter:

`Integrate[x^2 + y^2, {y, -1, 1}, {x, -Sqrt[1 - y^2], Sqrt[1 - y^2]}]`

The main trick is to calculate the bound on $x$ based on the current value of $y$, which is what you need to make the integration bounds explicit. Indeed, $x_{max}=\sqrt{1-y^2}$. This is something you can do in most integral-calculating math software.

You can also define the region implicitly, see this.

For this specific problem, that would give:

`Integrate[(x^2 + y^2) Boole[x^2 + y^2 <= 1], {y, -100, 100}, {x, -100, 100}]`

Where the "100" bounds are just to limit the computation. However, Mathematica is even smart enough to calculate:

```Integrate[(x^2 + y^2) Boole[x^2 + y^2 <= 1], {y, -Infinity, 
  Infinity}, {x, -Infinity, Infinity}]```
-

Rather than writing this particular problem as an iterated integral, I wonder if it could be written as a "pure" double integral. Not all double integrals can be simply written as iterated integrals. – Ragib Zaman Jun 7 '12 at 12:27
The last version with `Integrate[(x^2 + y^2) Boole[x^2 + y^2 <= 1], {y, -Infinity, Infinity}, {x, -Infinity, Infinity}]` is awesome. I will stick to the Boole function. – Christian Ivicevic Jun 7 '12 at 12:34
You're indeed supposed to be using infinite limits when using the `Boole[]` form of the integral; the assumption is that the integrand is zero outside the boundary described within the `Boole[]` function, so it all works out. – J. M.♦ Jun 10 '12 at 11:48
For checking a paper-and-pencil evaluation, definitely the method using `Boole` is the way to go: that way, if you incorrectly described the limits on `x` in terms of `y` (or vice versa) by hand, you wouldn't repeat the same error when doing the Mathematica evaluation. – murray Jun 10 '12 at 20:26
lang-mma
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 9, "mathjax_display_tex": 2, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": false, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9184131622314453, "perplexity_flag": "middle"}