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.2. Iterated Integrals

Example 1.

Example 2.

Example 3. The density at the point $$(x, y)$$ of a trianglar metal plate, as shown in Figure, is $$\delta (x, y) .$$ Explress its mass as an iterated integral.

First, we plot triangles using Mathematica:

Plot[{0., Max[0, Min[2 x, 6 - x]]}, {x, -1, 7}, AspectRatio -> 1/2, Ticks -> {{0, 2, 4, 6}, {0, 2, 4}}, Filling -> Axis, FillingStyle -> Blue]
Graphics[Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}]]
RegionPlot[2 x - y > 0 && -3 x - y > -15, {x, 0, 5}, {y, 0, 6}, PlotStyle -> LightBlue]
Plot[{0, Max[0, Min[2 x, 15 - 3 x]]}, {x, 0, 7}, AxesLabel -> {x, y}, Filling -> Bottom]
RegionPlot[ 2 x - y > -1 && -2 x - y > -5 && y > 1, {x, 0, 3}, {y, 0, 3}, PlotStyle -> Purple]
RegionPlot[-1 < x < 3 && -2 < y < 1 && -3/4 x - y > -.25, {x, -2, 5}, {y, -3, 3}, GridLines -> Automatic]
RegionPlot[x < 4 && y > 2 && 2 x - y > 0, {x, 0, 6}, {y, 0, 8}]
Show[Graphics[{PlotStyle -> {Thickness[1.5]}, Hue[0.8], Line[{{0, 0}, {1, 1}, {4, 1/2}, {0, 0}}]}], AspectRatio -> 1, Axes -> True, AxesStyle -> Thick, AxesOrigin -> {-0.5, -0.5}]
RegionPlot[x < 1 && 2 x - y > 0, {x, 0, 1}, {y, 0, 2}, PlotStyle -> Hue[0.2]]
RegionPlot[x > 0 && 3 x - y < 0 && x < 12, {x, 0, 6}, {y, 0, 12}]
R = Triangle[{{1, 1}, {1, 12}, {4, 12}}] Graphics[{EdgeForm[Dashed], Pink, R}, AspectRatio -> 0.4, Axes -> True, AxesStyle -> Thick, AxesOrigin -> {0, 0}]
If the boundary needs to be emphasized, then
ln = Show[ Graphics[{Thickness[.02], Hue[.6], Line[{{0, 0}, {1, 1}, {0, 1}, {0, 0}}]}]]
pol = Show[Graphics[{Hue[0.5], Polygon[{{0, 0}, {1, 1}, {0, 1}}]}]]
Show[pol, ln]
An arbitrary triangle could be plotted as follows
triangle[a_?NumericQ, b_?NumericQ, c_?NumericQ] :=
Block[{x, y, pt, sqr}, sqr = #.# &; pt[a1_, b1_, c1_] := Reduce[sqr[{x, y}] == b1^2 && sqr[{x, y} - {a1, 0}] == c1^2 && y > 0, {x, y}]; {(Polygon[{{0, 0}, {a, 0}, {x, y}}]), Text[Style[Framed[a, Background -> LightYellow], 11], {a/2, 0}], Text[Style[Framed[b, Background -> LightYellow], 11], {x/2, y/2}], Text[Style[Framed[c, Background -> LightYellow], 11], {(a + x)/2, y/2}]} /. ToRules[pt[a, b, c]]]

g[{s1_, s2_, s3_}] := Graphics[{EdgeForm[Thick], FaceForm[None], triangle[s1, s2, s3]}, ImagePadding -> 20, ImageSize -> {200, 200}]

GraphicsGrid[{{g[{Sqrt[5], 1, 2}]}}]
or
Graphics[{EdgeForm[Thick], FaceForm[None], triangle[Sqrt[5], 1, 2]}]

Example 4. Find the mass M of a metal plate R bounded by $$y=x \quad\mbox{and} \quad y= x^2 ,$$ with density given by $$\delta (x,y) = 1 + xy$$ kg/meter2 .

Plot[{x, x^2 }, {x, 0, 1.0}, Filling -> {1 ->{2}}, AspectRatio ->1]

Therefore, we need tools to plot a domain below or above a graph:
q[p_] = 10.2 p^2.0;
lowerBound = p /. Solve[q[p] == 100, p][[1]] // Quiet;
Show[Plot[q[p], {p, 0, 22}, PlotRange -> {0, Automatic}], Plot[q[p], {p, lowerBound, 20}, Filling -> 100], Graphics[{Line[{{0, 100}, {30, 100}}], Line[{{20, 0}, {20, 4000}}]}]]
boundleft = 2;
boundright = 8;
f[x_] = 25 - 15*x^2 + x^3;
g1 = Plot[f[x], {x, -2, 10}];
g2 = Plot[f[x], {x, boundleft, boundright}, Filling -> 0];
Show[g1, g2]
or
Plot[{25 - 15*x^2 + x^3, If[2 <= x <= 8, 0]}, {x, 0, 10}, PlotStyle -> {Automatic, None}, Filling -> {1 -> {2}}]
or we can fill bellow and above some horizontal line:
guess = -100;
Plot[{25 - 15*x^2 + x^3, If[2 <= x <= 8, 0]}, {x, 0, 10}, PlotStyle -> {Automatic, None}, Filling -> {1 -> {guess, Yellow}}]
Plot[{25 - 15*x^2 + x^3, If[2 <= x <= 8, 0]}, {x, 0, 10}, PlotStyle -> {Automatic, None}, Filling -> {1 -> Top}]
Plot[{25 - 15*x^2 + x^3, If[2 <= x <= 8, 0]}, {x, 0, 10}, PlotStyle -> {Automatic, None}, Filling -> {1 -> {Bottom, LightGreen}}]

Example 5.