12
Mathematica Project 6 Help Consider the following examples: I: Example with double integrals in Mathematica, computing the volume under z=3-x-y over the the triangle bounded by the x-axis, the line y=x and the line x=1. The first two are the dydx integral entered in nestedand non-nestedforms. The third is the dxdy integral (i.e. the order of integration has been reversed). Integrate[Integrate[3 - x - y, {y, 0, x}], {x, 0, 1}] 1 Integrate[3 - x - y, {x, 0, 1}, {y, 0, x}] 1 Integrate[3 - x - y, {y, 0, 1}, {x, y, 1}] 1 II: Two examples of graphing the surfaces surrounding a region in space with ContouPlot3D and graph- ing the region itself with RegionPlot3D. First example: the region is bounded by y+z=1, y=x 2 , z=0.

Mathematica Project 6 Help - Wilkes University · 2019-11-26 · Mathematica Project 6 Help Consider the following examples: I: Example with double integrals in Mathematica, computing

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Mathematica Project 6 Help - Wilkes University · 2019-11-26 · Mathematica Project 6 Help Consider the following examples: I: Example with double integrals in Mathematica, computing

Mathematica Project 6 Help

Consider the following examples:

I: Example with double integrals in Mathematica, computing the volume under z=3-x-y over the the triangle bounded by the x-axis, the line y=x and the line x=1. The first two are the dydx integral entered in “nested” and “non-nested” forms. The third is the dxdy integral (i.e. the order of integration has been reversed).

Integrate[Integrate[3 - x - y, {y, 0, x}], {x, 0, 1}]

1

Integrate[3 - x - y, {x, 0, 1}, {y, 0, x}]

1

Integrate[3 - x - y, {y, 0, 1}, {x, y, 1}]

1

II: Two examples of graphing the surfaces surrounding a region in space with ContouPlot3D and graph-ing the region itself with RegionPlot3D.

First example: the region is bounded by y+z=1, y=x2, z=0.

Page 2: Mathematica Project 6 Help - Wilkes University · 2019-11-26 · Mathematica Project 6 Help Consider the following examples: I: Example with double integrals in Mathematica, computing

ContourPlot3D{y + z ⩵ 1, y == x^2, z ⩵ 0}, {x, -2, 2},

{y, -2, 2}, {z, -2, 2}, Mesh → None, ContourStyle → Opacity[0.8]

Now plot the region bounded by the surfaces (see equations above) using RegionPlot3D:

2 MTH212_Project6_Help.nb

Page 3: Mathematica Project 6 Help - Wilkes University · 2019-11-26 · Mathematica Project 6 Help Consider the following examples: I: Example with double integrals in Mathematica, computing

RegionPlot3Dy + z ≤ 1 && y ≥ x^2 && z ≥ 0, {x, -1, 1},

{y, -1, 1}, {z, -1, 1}, Mesh → None, PlotPoints → 100

Another example: the region is bounded by z = 4-4x2 +y2), z =x2 +y2)^2-1.

MTH212_Project6_Help.nb 3

Page 4: Mathematica Project 6 Help - Wilkes University · 2019-11-26 · Mathematica Project 6 Help Consider the following examples: I: Example with double integrals in Mathematica, computing

ContourPlot3D{z ⩵ 4 - 4 (x^2 + y^2), z ⩵ (x^2 + y^2)^2 - 1}, {x, -2, 2},

{y, -2, 2}, {z, -2, 5}, Mesh → None, ContourStyle → Opacity[0.8]

4 MTH212_Project6_Help.nb

Page 5: Mathematica Project 6 Help - Wilkes University · 2019-11-26 · Mathematica Project 6 Help Consider the following examples: I: Example with double integrals in Mathematica, computing

RegionPlot3D(z ⩽ 4 - 4 (x^2 + y^2)) && (z ⩾ (x^2 + y^2)^2 - 1),

{x, -2, 2}, {y, -2, 2}, {z, -2, 5}, Mesh → None, PlotPoints → 100

Let u s find the volume of the second region using triple integrals i n rectangular and

cylindrical coordinates.Note that the names of the variables are not important.

(*rectangular *)

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

{z, (x^2 + y^2)^2 - 1, 4 - 4 (x^2 + y^2)}]

8 π

3

(*cylindrical*)

Integrater, theta, 0, 2 Pi, {r, 0, 1}, {z, r^4 - 1, 4 - 4 r^2}

8 π

3

III: Multiple examples of using SphericalPlot3D to try and understand the meaning of the coordinates. Examples related to the sphere (using our textbook notation) ρ = 2cos(ϕ). Note that the names of the variables are not important. In the SphericalPlot3D documentation you see Mathematica using the variables as listed in the first of the commands below. They use the variable name θ in the way that we use ϕ and vice versa. To use SphericalPlot3D just keep in mind that the variable you list first (whatever name you use) is the one measuring the angle down from the positive z-axis and the one listed second (again no matter the name) is the one measuring rotation from the positive x-axis.

MTH212_Project6_Help.nb 5

Page 6: Mathematica Project 6 Help - Wilkes University · 2019-11-26 · Mathematica Project 6 Help Consider the following examples: I: Example with double integrals in Mathematica, computing

SphericalPlot3D2 Cos[θ], θ, 0, Pi, ϕ, 0, 2 Pi

SphericalPlot3D2 Cos[ϕ], θ, 0, 2 Pi, ϕ, 0, Pi

6 MTH212_Project6_Help.nb

Page 7: Mathematica Project 6 Help - Wilkes University · 2019-11-26 · Mathematica Project 6 Help Consider the following examples: I: Example with double integrals in Mathematica, computing

SphericalPlot3D2 Cos[ϕ], ϕ, 0, Pi, θ, 0, 2 Pi

SphericalPlot3D2 Cos[p], t, 0, 2 Pi, p, 0, Pi

MTH212_Project6_Help.nb 7

Page 8: Mathematica Project 6 Help - Wilkes University · 2019-11-26 · Mathematica Project 6 Help Consider the following examples: I: Example with double integrals in Mathematica, computing

IV: Graphing the same sphere ρ = 2cos(ϕ) using ParametricPlot3D. (Refer to Section 15.5 of the text-book about parameterization of surfaces.)Here (using book notation) we have x=ρsinϕcosθ, y=ρsinϕsinθ, and z=ρcosϕ and we replace ρ with 2cos(ϕ) in x, y and z.

ParametricPlot3D

2 CosMyPhi SinMyPhi CosMyTheta, 2 CosMyPhi SinMyPhi SinMyTheta,

2 CosMyPhi CosMyPhi, MyTheta, 0, 2 Pi, MyPhi, 0, Pi

V: Here is another example using ParametricPlot3D to graph (book notation) ρ=1+cosϕ. Notice again we can use any variable names and here we can also specify their ranges in any order.

8 MTH212_Project6_Help.nb

Page 9: Mathematica Project 6 Help - Wilkes University · 2019-11-26 · Mathematica Project 6 Help Consider the following examples: I: Example with double integrals in Mathematica, computing

ParametricPlot3D

1 + CosMyPhi SinMyPhi CosMyTheta, SinMyPhi SinMyTheta, CosMyPhi,

MyTheta, 0, 2 Pi, MyPhi, 0, Pi

VI: Here is another example using ParametricPlot3D to graph the cone ϕ=π/4. Recall that the cone has

the following equation in Cartesian coordinates: z = x2 + y2 .

This is equivalent to z = r in cylindrical coordinates, together with equations x = r cos t and y = r sin t. So, we use the following parameterization:

MTH212_Project6_Help.nb 9

Page 10: Mathematica Project 6 Help - Wilkes University · 2019-11-26 · Mathematica Project 6 Help Consider the following examples: I: Example with double integrals in Mathematica, computing

ParametricPlot3Dr * Cos[t], r * Sin[t], r, {r, 0, 2},

t, 0, 2 * Pi, Mesh → None, PlotStyle → Opacity[0.8]

VII : Example from class : triple integral in spherical coordinates for the volume of the “ice cream cone”

bounded by z= x2 + y2 and x2 +y2 + z2 = z.

Integraterho^2 * Sinphi, theta, 0, 2 Pi, phi, 0, Pi 4, rho, 0, Cosphi

(* note the order! *)

π

8

VIII: Some examples on vector fields, circulation and flux integrals:

Defining a vector field f and a parametrized curve r in the plane:

(* field *)

M1[x_, y_] := 2 x

N1[x_, y_] := -3 y

f1[x_, y_] := {M1[x, y], N1[x, y]}

(* curve *)

g[t_] := 2 Cos[t]

h[t_] := 2 Sin[t]

r[t_] := g[t], h[t]

v[t_] := r'[t]

Plotting the vector field and the curve in the plane:

10 MTH212_Project6_Help.nb

Page 11: Mathematica Project 6 Help - Wilkes University · 2019-11-26 · Mathematica Project 6 Help Consider the following examples: I: Example with double integrals in Mathematica, computing

ShowVectorPlotf1[x, y], {x, -4, 4}, {y, -4, 4},

ParametricPlotr[t], t, 0, 2 Pi

-4 -2 0 2 4

-4

-2

0

2

4

Computing circulation:

circulationintegrand1 = f1g[t], h[t].v[t] // FullSimplify

Integratecirculationintegrand1, t, 0, 2 Pi

-20 Cos[t] Sin[t]

0

Computing flux:

fluxintegrand1 = M1g[t], h[t] * h'[t] - N1g[t], h[t] * g'[t] // FullSimplify

Integratefluxintegrand1, t, 0, 2 Pi

-2 + 10 Cos[2 t]

-4 π

Another example: different field (shear filed), same curve:

M2[x_, y_] := y

N2[x_, y_] := 0

f2[x_, y_] := {M2[x, y], N2[x, y]}

MTH212_Project6_Help.nb 11

Page 12: Mathematica Project 6 Help - Wilkes University · 2019-11-26 · Mathematica Project 6 Help Consider the following examples: I: Example with double integrals in Mathematica, computing

ShowVectorPlotf2[x, y], {x, -4, 4}, {y, -4, 4},

ParametricPlotr[t], t, 0, 2 Pi

-4 -2 0 2 4

-4

-2

0

2

4

circulationintegrand = f2g[t], h[t].v[t] // FullSimplify

-4 Sin[t]2

Integratecirculationintegrand, t, 0, 2 Pi

-4 π

fluxintegrand = M2g[t], h[t] h'[t] - N2g[t], h[t] g'[t] // FullSimplify

4 Cos[t] Sin[t]

Integratefluxintegrand, t, 0, 2 Pi

0

12 MTH212_Project6_Help.nb