Department of Mathematics

 MTH243 (Calculus for Functions of Several Variables) MATLAB. 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]

Example 3. We start with plotting rectangle:

figure
x1=3;
x2=1;
y1=2;
y2=-1;
x = [x1, x2, x2, x1, x1];
y = [y1, y1, y2, y2, y1];
plot(x, y, 'b-', 'LineWidth', 3);
hold on;
xlim([-3, 5]);
ylim([-3, 5]);
title('16.35 part a')

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, PlotStyle -> Orange], ListLinePlot[{{1, -1}, {1, 2}}], PlotRange -> {{0, 3}, {-1, 2}}]
Then we plot the circle:
figure
r = 3;
k = 0;
for theta = 0:pi/100:2*pi
k = k+1;
x(k) = r*cos(theta);
y(k) = r*sin(theta);
end
plot(x,y);
title('16.35 Part b')
RegionPlot[x^2 + y^2 <= 9, {x, -5, 5}, {y, -5, 5}, PlotTheme -> "Scientific"]
Then we shpw 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"]]
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
figure
plot([1,2,3.7,4,1],[6,3,5,9,6])
title('16.35 part c')

Show[Graphics[{RGBColor[3.3, 0.1, 0.5], Rectangle[{0, 0}, {2, 3}], Triangle[{{0, -1}, {0, 0}, {2, 0}}]}], Axes -> True]
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}]