Prof. Vladimir Dobrushkin
Department of Mathematics
TO SYLLABUS
TO GRADING
TO SOFT
TO BOOKS
TO QUIZZES
 

MTH243 (Calculus for Functions of Several Variables)
MATHEMATICA. Chapter 12:
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 12.1. Functions of two Variables

Vectors in the Wolfram Language are simply represented by lists:
v = { a, b, c }
where a, b, and c could be any expressions, numerical or algebraic. Therefore, Mathematica does not pay attention whether a vector is a column vecor or a row vector. To specify the column (or row) vector, one should define it as a matrix

 

Section 12.2. Graphs of Functions of two Variables

Example 1. We start plotting the graph of a paraboloid, which is defined by the function \( f (x, y) = x^2+y^2 . \)
Plot3D[(x^2 + y^2), {x, -3, 3}, {y, -3, 3}, Axes -> True, PlotStyle -> Green]
Plot3D[(x^2 + y^2), {x, -3, 3}, {y, -3, 3}, Axes->False]
Plot3D[(x^2 + y^2), {x, -3, 3}, {y, -3, 3}, Filling->Bottom]
Plot3D[(x^2 + y^2), {x, -3, 3}, {y, -3, 3}, Mesh->None]
We can also make it not symmetrical:
a=2; b=3; Plot3D[x^2 /a^2 + y^2 /b^2, {x, -3, 3}, {y, -4, 4}]
ContourPlot3D[z == x^2 + y^2, {x, -3, 3}, {y, -3, 3}, {z, 0, 5}]
ContourPlot3D[x^2 + y^2 == z, {x, -1, 1}, {y, -1, 1}, {z, 0, 1}, Contours -> {4, Dashed}]
Plot3D[x^2 + y^2, {x, -1.5, 1.5}, {y, -1.5, 1.5}, PlotRange -> All, BoxRatios -> Automatic, ColorFunction -> Hue]
ContourPlot3D[ z == ((x^2)/(1^2)) + ((y^2)/(1^2)), {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, AxesOrigin -> {0, 0, 0}, PlotRange -> {-1, 1}, AxesLabel -> {x, y, z}]
ContourPlot3D[ x^2 + y^2 - z == 0, {x, -1., 1.}, {y, -1., 1.}, {z, -1., 1.}, Axes -> True, BoxRatios -> {1., 1., 1.}, ViewPoint -> {-2.43972, -1.63989, 0.598757}, PlotRange -> All, AxesLabel -> {"x", "y", "z"}, ContourStyle -> Directive[RGBColor[1, 0.8, 0.3], Specularity[RGBColor[0.2, 0.2, 0.7], 20]], Lighting -> "Neutral", ColorFunction -> None, BoxStyle -> GrayLevel[0, 0.35]]
ContourPlot3D[x^2 + y^2 == z, {x, -1, 1}, {y, -1, 1}, {z, 0, 1}, Mesh -> None, Lighting -> "Neutral", TextureCoordinateFunction -> ({#1, #3} &), ContourStyle -> Texture[ExampleData[{"ColorTexture", "WavesPattern"}]]]
or using polar coordinates
ParametricPlot3D[{s Cos[t], 2 s Sin[t], s^2}, {s, 0, 2}, {t, 0, 2 Pi}, PlotStyle -> Thick]
Now we create a new graph by shifting the previous one up by 3 units: \( g (x, y) = x^2 + y^2 + 3 \)
Plot3D[(x^2 + y^2 + 3), {x, -3, 3}, {y, -3, 3}, Axes -> True]
Another graph of \( h(x, y) = 5 - x^2 - y^2 \)
Plot3D[(5 - x^2 - y^2), {x, -3, 3}, {y, -3, 3}, Axes -> True, PlotStyle -> Orange]
One more: \( k (x, y) = x^2 + (y - 1)^2 \)
Plot3D[(x^2 + (y - 1)^2), {x, -3, 3}, {y, -3, 3}, PlotStyle -> None]
Example 2. Plotting the graph of the function \( G(x,y)=e^{-(x^2+y^2)} \)
Plot3D[(E^-(x^2 + y^2)), {x, -5, 5}, {y, -5, 5}, PlotStyle -> Opacity[.8]]
Cross Sections and the Graph of a Function where x=2
Plot3D[{(x^2 + y^2), (4 + y^2)}, {x, -3, 3}, {y, -3, 3}]
Example 2. Now we consider the hyperbolic parabaloid
ContourPlot3D[z == -x^2 + y^2, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}]
or
Plot3D[-x^2 + y^2, {x, -1.5, 1.5}, {y, -1.5, 1.5}, PlotRange -> All, BoxRatios -> Automatic]
or
ContourPlot3D[ z == ((-x^2)/(1^2) + (y^2)/(1^2)), {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, AxesOrigin -> {0, 0, 0}, PlotRange -> {-1, 1}, AxesLabel -> {x, y, z}]
Plot3D[-x^2 + y^2, {x, -1.5, 1.5}, {y, -1.5, 1.5}, PlotRange -> All, BoxRatios -> Automatic , ColorFunction -> Hue]
or
ContourPlot3D[-x^2/10 + y^2/10 == z, {x, -10, 10}, {y, -10, 10}, {z, -10, 10}, ColorFunction -> Function[{x, y, z}, Hue[z]]]
ContourPlot3D[-x^2 + y^2 - z == 0, {x, -4., 4.}, {y, -4., 4.}, {z, -4., 4.}, Axes -> True, BoxRatios -> {1., 1., 1.}, ViewPoint -> {-2.35989, -1.80482, -0.416584}, PlotRange -> All, AxesLabel -> {"x", "y", "z"}, ContourStyle -> Directive[RGBColor[0.5, 0.8, 0.3], Specularity[RGBColor[0.2, 0.2, 0.7], 20]], Lighting -> "Neutral", ColorFunction -> None, BoxStyle -> GrayLevel[0.7, 0.5]]
ParametricPlot3D[{s, t, s^2 - t^2}, {s, -1, 1}, {t, -1, 1}, PlotStyle -> Magenta]
ContourPlot3D[-x^2 + y^2 == z, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Mesh -> 5, MeshFunctions -> {#1 &, #2 &}, MeshStyle -> {Dashed, Blue}]

Example 5. Graph the equation \( x^2 + y^2 =1 \) in 3-space.

ContourPlot3D[1 == x^2 + y^2, {x, -2, 2}, {y, -2, 2}, {z, -3, 3}, AspectRatio -> 1]
ContourPlot3D[(x^2 + y^2)^.5 == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]
ContourPlot3D[(x^2 + y^2)^.5 == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, MeshShading -> {White, Black, Blue}, MeshFunctions -> {#3 &}]
ContourPlot3D[x^2 + y^2 == 6, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, ColorFunction -> Function[{x, y, z}, Hue[z]]]
ContourPlot3D[(x^2 + y^2)^.5 == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, MeshShading -> Table[RGBColor[r, g, b], {r, 0, 1, 1/5}, {g, 0, 1, 1/5}, {b, 0, 1, 1/5}], Mesh -> 5, Lighting -> "Neutral"]

Example 6 . Consider the equation of parabolic cylinder \( y= x^2 \) in 3-space when one variable is missing.

ContourPlot3D[y == x^2, {x, -3, 3}, {y, 0, 3}, {z, -3, 3}, AspectRatio -> 1]
or
ContourPlot3D[3 == x^2 - y, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}]
ContourPlot3D[y == x^2, {x, -3, 3}, {y, 0, 3}, {z, -3, 3}, MeshShading -> {Blue, Orange}, MeshFunctions -> {#3 &}]
ContourPlot3D[y == .5*x^2, {x, -3, 3}, {y, 0, 3}, {z, -2, 2}, ColorFunction -> Hue]
Plot3D[y = 3 x^2, {x, -5, 5}, {y, -5, 5}, AspectRatio -> 1]
ContourPlot3D[y == x^2, {x, -3, 3}, {y, 0, 3}, {z, -3, 3}, MeshFunctions -> {#1 &}, MeshStyle -> Dashed, Mesh -> 5] Show[%, Background -> RGBColor[0.84, 0.92, 1.]]

Now we plot some surfaces involving trigonometric functions:

Plot3D[Cos[((x^2 + y^2)^0.5)], {x, -5, 5}, {y, -5, 5}, Background -> Cyan]
Plot3D[(Cos[x])^2*(Cos[y])^2, {x, -5, 5}, {y, -5, 5}, BoxRatios -> Automatic]
Plot3D[Cos[x*y], {x, -5, 5}, {y, -5, 5}, ColorFunction -> "Rainbow"]
Plot3D[Sin[x^2 + y^2]/(x^2 + y^2), {x, -3, 3}, {y, -11, 11}, PlotStyle -> Texture[Texture]]
Plot3D[Sin[y], {x, -5, 5}, {y, -5, 5}, PlotStyle -> Directive[Opacity[0.7]], ColorFunction -> "RustTones"]
Next, we plot another kind of surfaces:
Plot3D[-1/(x^2 + y^2), {x, -5, 5}, {y, -5, 5}, PlotStyle -> Directive[Opacity[0.8], Cyan, Specularity[White, 50]]]
Plot3D[Abs[x]*Abs[y], {x, -5, 5}, {y, -5, 5}, MeshShading -> {{Automatic, None}, {None, Automatic}}]
Plot3D[(2*x^2 + y^2)*E^(1 - x^2 - y^2), {x, -5, 5}, {y, -5, 5}, PlotStyle -> Directive[Opacity[0.5], Red]]
The same plane \( 5 x - 4 y - 9 z = 0 \) can be plotted in many ways:
a1 = ContourPlot3D[ 5 x - 4 y - 9 z == 0, {x, -10, 10}, {y, -10, 10}, {z, -10, 10}, AxesLabel -> {x, y, z}, Mesh -> None, ContourStyle -> Directive[Red]]
f[x_, y_] := 1/9 (5 x - 4 y); a2 = ParametricPlot3D[{x, y, f[x, y]}, {x, -10, 10}, {y, -10, 10}, AxesLabel -> {x, y, z}, Mesh -> None, PlotStyle -> Directive[Red]]
a3 = Graphics3D[{Red, Polygon[Flatten[#, 1] &@{#[[1]], #[[2]], f[#[[1]], #[[2]]]} & /@ {{-10, -10}, {-10, 10}, {10, 10}, {10, -10}}]}]
There are many ways to plot lines
g[t_] := {t, t/2, t/3} b1 = ParametricPlot3D[g[t], {t, -10, 10}, PlotStyle -> RGBColor[1, 0, 1]] b2 = Graphics3D[{RGBColor[1, 0, 1], Line[{g[-10], g[10]}]}]
   
There are many ways to plot points
c1 = Graphics3D[{PointSize[Large], Blue, Point[{0, 0, 0}], Green, Point[{1, -1, 1}]}] c2 = Graphics3D[{Blue, Sphere[{0, 0, 0}, 1], Green, Sphere[{1, -1, 1}, .4]}] c3 = ListPointPlot3D[{{0, 0, 0}, {1, -1, 1}}, PlotStyle -> PointSize[0.05]] c4 = BubbleChart3D[{{0, 0, 0, 1}, {1, -1, 1, 1}}]