0
$\begingroup$

I want to use mathematica to visualise some plots, this would help me understand my calculus course. My problem is this:

Given that

x^2 + y^2 <= a^2

Find enter image description here

\[Integral]\!\(
\*SubscriptBox[\(\[Integral]\), \(D\)]\(\*
TemplateBox[{"x"},
"Abs"] \[DifferentialD]y \[DifferentialD]x\)\)

Now I know how to solve it through polar coordinates, but I am simply interested in how to plot the problem such that I could use it when I get to more difficult integration problems.

$\endgroup$
  • 1
    $\begingroup$ (23563). Plus it contains a beautiful plot $\endgroup$ – Sektor Jun 5 '15 at 8:16
  • $\begingroup$ A few lines: reg=ImplicitRegion[x^2 + y^2 <= a^2, {x,y}]; Integrate[Abs[x],Element[{x,y},reg]](*linebreak here*) Plot3D[Abs[x],{x,-3,3},{y,-3,3},RegionFunction->(Element[{#1,#2},reg/.a->3]&)] $\endgroup$ – LLlAMnYP Jun 5 '15 at 10:55
  • $\begingroup$ @LLlAMnYP I wonder, why don't you post an answer instead of trying to stuff multiple lines of code into a comment? That way you could show the results as well. $\endgroup$ – MarcoB Jun 5 '15 at 15:04
  • $\begingroup$ I feel guilty about dubbing one-liners like this as proper answers, but since there's demand for that, sure, I'll post. $\endgroup$ – LLlAMnYP Jun 5 '15 at 17:18
3
$\begingroup$

Now that the nature of integral has been clarified: $\iint_{D} |x| \mathrm dx\mathrm dy$ where $D$ is region $x^2+y^2<a^2$:

There are a number of ways to evaluate integral:

Integrate[Abs[x], {x, y} \[Element] Disk[{0, 0}, a], 
 Assumptions -> a > 0]
(*Jacobian to conversion to polar coordinates*)
j = Simplify[Det[Outer[D[#1, #2] &, {r Cos[t], r Sin[t]}, {r, t}]]];
Integrate[Abs[r Cos[t]] j, {r, 0, a}, {t, 0, 2 Pi}, 
 Assumptions -> a > 0]
(*using implicitly defined region*)
reg = ImplicitRegion[
   0 < z < Abs[x] && 
    x^2 + y^2 < a^2, {{x, -a, a}, {y, -a, a}, {z, 0, a}}];
Assuming[a > 0, Volume[reg]]

All yield (4 a^3)/3

Visualization:

p1 = Plot3D[Abs[x], {x, -1, 1}, {y, -1, 1}, 
   RegionFunction -> Function[{x, y}, x^2 + y^2 < 1], Mesh -> False];
p2 = ParametricPlot3D[{r Cos[t], r Sin[t], Abs[r Cos[t]]}, {r, 0, 
    1}, {t, 0, 2 Pi}, Mesh -> False];
p3 = RegionPlot3D[reg /. a -> 1, PlotPoints -> 100, Axes -> False, 
   Boxed -> False, Background -> Black];
Column[{p1, p2, p3}]

visualization

$\endgroup$
2
$\begingroup$

The region x^2 + y^2 <= a^2 can of course be parametrized as -Sqrt[a^2-x^2] <= y <= Sqrt[a^2-x^2] with -a <= x <= a:

Integrate[Abs[x], {x, -a, a}, {y, -Sqrt[a^2 - x^2], Sqrt[a^2 - x^2]}]
(* ConditionalExpression[(4 a^3)/3, Re[a] > 0 && Im[a] == 0] *)

Or we can do it in polar coordinates (x = r Cos[f], y = r Sin[f], r <= a)

Integrate[r Abs[r Cos[f]], {r, 0, a}, {f, 0, 2 Pi}, Assumptions -> a > 0]
(* (4 a^3)/3 *)

Or we can leave the thinking to Mathematica, making use of the capability of the ImplicitRegion function as well as the capability of Integrate to do integration over regions, rather than integration limits:

reg = ImplicitRegion[x^2 + y^2 <= a^2, {x,y}];

Integrate[Abs[x], Element[{x, y}, reg]]

Plot3D[Abs[x], {x, -3, 3}, {y, -3, 3},
         RegionFunction -> (Element[{#1, #2}, reg /. a -> 3] &),
         Filling -> Axis]

Piecewise[{{(-4*a^3)/3, a < 0}, {0, a == 0}}, (4*a^3)/3]

Plot

And the shaded gray volume under the plot is equal to the result of integration (plotted for a = 3).

$\endgroup$
  • $\begingroup$ It looks like you are calculating different integral. You are calculating Abs[x]*dx*dy and the topic starter wants to integrate Abs[x]*dr*dtheta which is equal to Abs[x]/(Sqrt[x*x+y*y])*dx*dy… Or maybe he forgot the jacobian $\endgroup$ – BlacKow Jun 5 '15 at 18:04
  • $\begingroup$ Hmm. Good point. We'll need input from OP. $\endgroup$ – LLlAMnYP Jun 5 '15 at 18:13
  • $\begingroup$ Initially it just said to use polar coordinates and it was writen dA where I wrote dr*dtheta now I guess that makes quite a big difference. But I thought the figure made sense, since that's what I visualized! $\endgroup$ – ALEXANDER Jun 5 '15 at 22:06
  • $\begingroup$ Yup, dA == r dr dtheta. Thanks for clearing that up. $\endgroup$ – LLlAMnYP Jun 5 '15 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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