Department of Mathematics

 MTH243 (Calculus for Functions of Several Variables) MATHEMATICA. Chapter 16: Integrating Functions of Several Variables Vladimir A. Dobrushkin,Lippitt Hall 202C, 874-5095,dobrush@uri.edu In this course we will use Mathematica computer algebra system (CAS), which is available in computer labs at URI. The Mathematica projects are created to help you learn new concepts. Mathematica is very useful in visualizing graphs and surfaces in three dimensions. Matlab (commercial software) is also available at engineeering labs. Its free version is called Octave. A student can also use free CASs: SymPy (based on Python), Maxima, or Sage.

## Section 16.4. Polar Coordinates

Example 1.

Example 2. Compute the integral of $$f (x, y) = 1 \left( x^2+y^2 \right)^{3/2}$$ over the wedge region

h[r_, \[Theta]_] := 2 < r <= 5 && 0 \[Pi] < \[Theta] < \[Pi]/4
RegionPlot[ h[Sqrt[x^2 + y^2], Mod[ArcTan[x, y], 2 \[Pi]]], {x, -6, 6}, {y, -6, 6}, AspectRatio -> 1]
or we can change the region to obtain the wedge region close to the horizontal axis:
h[r_, \[Theta]_] := 2 < r <= 5 && 0 \[Pi] < \[Theta] < \[Pi]/4
RegionPlot[ h[Sqrt[x^2 + y^2], Mod[ArcTan[x, y], 2 \[Pi]]], {x, 0, 6}, {y, 0, 6}, AspectRatio -> 1, PlotStyle -> Yellow]

RegionPlot[1 <= x <= 3 && -1 <= y <= 2, {x, 2, 4}, {y, -2, 3}, PlotStyle -> LightGreen]
or
Show[Graphics[{RGBColor[0.1, 33, 0], Rectangle[{1, -1}, {3, 2}]}], Axes -> True]
or with different green colors:
Show[Graphics[{RGBColor[0.1, 0.33, 0.2], Rectangle[{1, -1}, {3, 2}]}], Axes -> True]
Show[Graphics[{RGBColor[0.2, 21, 4], Rectangle[{1, -1}, {3, 2}]}], Axes -> True]
Show[ListLinePlot[{{1, 2}, {3, 2}}, Filling -> Bottom], ListLinePlot[{{3, 2}, {3, -1}}], ListLinePlot[{{3, -1}, {1, -1}}, Filling -> Top], ListLinePlot[{{1, -1}, {1, 2}}], PlotRange -> {{0, 3}, {-1, 2}}]
or with two colors
Show[ListLinePlot[{{1, 2}, {3, 2}}, Filling -> Bottom], ListLinePlot[{{3, 2}, {3, -1}}], ListLinePlot[{{3, -1}, {1, -1}}, Filling -> Top, PlotStyle -> Orange], ListLinePlot[{{1, -1}, {1, 2}}], PlotRange -> {{0, 3}, {-1, 2}}]
With pure red color:
Graphics[{RGBColor[1, 0, 0], Rectangle[{1, -1}, {3, 2}], Frame -> True, PlotRange -> {{0, 3}, {-1, 2}}}]
Then we plot the circle:
RegionPlot[x^2 + y^2 <= 9, {x, -5, 5}, {y, -5, 5}]
or
RegionPlot[x^2 + y^2 <= 9, {x, -4, 4}, {y, -4, 4}, PlotStyle -> LightYellow]
RegionPlot[x^2 + y^2 <= 9, {x, -5, 5}, {y, -5, 5}, PlotTheme -> "Scientific"]
Then we show how to put background:
Show[ContourPlot[y == (-x^2 + 9)^.5, {x, -3, 3}, {y, -3, 3}, PlotTheme -> "Marketing"], ContourPlot[y == -(-x^2 + 9)^.5, {x, -3, 3}, {y, -3, 3}, PlotTheme -> "Marketing"]]
or with different background
Show[RegionPlot[y < (-x^2 + 9)^.5, {x, -3, 3}, {y, -3, 3}, PlotTheme -> "Marketing"], RegionPlot[y > -(-x^2 + 9)^.5, {x, -3, 3}, {y, -3, 3}, PlotTheme -> "Marketing"]]
Show[Graphics[{RGBColor[1, 0.5, 0.5], Disk[{0, 0}, 3]}, Frame -> True, FrameTicks -> True, Background -> RGBColor[0.87, 0.94, 1]], Axes -> True]
Our next figure is a slanted rectangle:
RegionPlot[ x > 1 && y < 2 && x < 4 && 1/3 x - y < 1/3, {x, 0, 4}, {y, 0, 2}]
or
RegionPlot[ 0 <= x <= 2 && ((x/2) - 1) <= y <= 3, {x, -1, 3}, {y, -2, 3}]
or
Show[ListLinePlot[{{0, 3}, {2, 3}}, Filling -> Axis], ListLinePlot[{{2, 3}, {2, 0}}], ListLinePlot[{{2, 0}, {0, -1}}, Filling -> Top], ListLinePlot[{{0, -1}, {0, 3}}], PlotRange -> {{0, 2}, {-1, 3}}]
We can also change the color:
Show[Graphics[{RGBColor[0.2, 21, 4], Rectangle[{0, 0}, {2, 3}], Triangle[{{0, -1}, {0, 0}, {2, 0}}]}], Axes -> True]
Show[Graphics[{RGBColor[3.3, 0.1, 0.5], Rectangle[{0, 0}, {2, 3}], Triangle[{{0, -1}, {0, 0}, {2, 0}}]}], Axes -> True]
If one wants a black slanted figure, there is a simplier way:
Graphics[Polygon[{{0, 3}, {0, -1}, {2, 0}, {2, 3}}]]
We can even change colors within the figure:
Show[ListLinePlot[{{0, 3}, {2, 3}}, Filling -> Axis, PlotStyle -> Orange], ListLinePlot[{{2, 3}, {2, 0}}], ListLinePlot[{{2, 0}, {0, -1}}, Filling -> Top], ListLinePlot[{{0, -1}, {0, 3}}], PlotRange -> {{0, 2}, {-1, 3}}]
p1 = Rectangle[{0, 2}, {2, 3}];
p2 = Triangle[{{0, 0}, {0, 2}, {2, 2}}];
Show[Graphics[{Pink, p1}], Graphics[{Pink, p2}]]
Finally, we plot a quarter of circular pipe:
RegionPlot[x^2 + y^2 <= 4 && x^2 + y^2 > 1, {x, -2, 0}, {y, 0, 2}]
or
Show[RegionPlot[{x^2 + y^2 < 4 && x^2 + y^2 > 1}, {x, -2, 0}, {y, 0, 2}], ContourPlot[{x^2 + y^2 == 4, x^2 + y^2 == 1}, {x, -2, 0}, {y, 0, 2}]]
or
RegionPlot[ x^2 + y^2 <= 4 && x^2 + y^2 >= 1 && x <= 0 && y >= 0, {x, -2, 0}, {y, 0, 2}]
Now we put another color:
Graphics[{Blue, Disk[{0, 0}, 2], White, Disk[{0, 0}, 1]}, Frame -> True, FrameTicks -> True, PlotRange -> {{-2, 0}, {0, 2}}]

Graphics[{Orange, Disk[{0, 0}, 1, {Pi/2, -Pi/2}]}]
or quarter
RegionPlot[x^2 + y^2 < 1 && x > 0 && y > 0, {x, 0, 1.1}, {y, 0, 1.1}]