Graphics accompanying my lecture notes on graphs associated to functions of several variables

Some review of pictures representing functions ℝ → ℝ

Plot[x^2, {x, -3, 3}, PlotRange -> {-1,5}, AspectRatio -> Automatic]

Show[
Plot[x^2, {x, -3, 3}, PlotRange -> {-1,5}, AspectRatio -> Automatic],
Graphics[{Red, Disk[{1.5, 2.25}, .1]}],
Graphics[{Red, Dashed, Line[{{1.5,0},{1.5,2.25}}]}],
Graphics[{Red, Dotted, Line[{{0,2.25},{1.5,2.25}}]}],
Graphics[{Red, Text[Style[ "(1.5, 2.25)", Larger], {2.15, 2.25}]}],
Graphics[{Red, Text[Style[ "1.5", Larger], {1.5, -.15}]}],
Graphics[{Red, Text[Style[ "2.25", Larger], {-.35, 2.25}]}],
Graphics[{Red, Text[Style[ "f(1.5) = 2.25", Larger], {2.3, 1.95}]}]
]

Manipulate[
Show[Plot[20, {t, -10, 10}, PlotRange -> {-.65, .65}, AspectRatio -> Automatic, Ticks -> {Range[-20,20]}],
Graphics[{Red,Disk[{x^2,0},.25]}],
Graphics[{Red, Text[x, {x^2, .4}]}]],
{x, -5, 5}]

Show[
Plot[20, {t, -10, 10}, PlotRange -> {-.75, .75}, AspectRatio -> Automatic,
Ticks -> {Range[-20,20]}],
ParametricPlot[{t^2,0}, {t, -5,5}, PlotStyle -> {Red, Thick}],
Graphics[{Red,Disk[{4,0},.25]}],
Graphics[{Red,Disk[{1,0},.25]}],
Graphics[{Red,Disk[{0,0},.25]}],
Graphics[{Red,Disk[{9,0},.25]}],
Graphics[{Red, Text["t = ±3", {9,.45}]}],
Graphics[{Red, Text["t = ±2", {4,.45}]}],
Graphics[{Red, Text["t = ±1", {1.25,.45}]}],
Graphics[{Red, Text["t = 0", {-.5,.45}]}]
]

Sketching the graph of a function f : ℝ → (ℝ^2)

The graph of such a function is a curve in the plane (which shows only the output values of the function), where the inputs to the function are indicated by labelling points on the graph with the corresponding input.

Here’s how to define such a function:

f[t_] = {t^2 - 2, 2t - t^2}

And here’s how to get a table of values, if you need one:

Table[{t, f[t]}, {t, -2, 2}] // TableForm

Now for the graph:

ParametricPlot[f[t], {t, -20, 20}, PlotRange -> {{-5,10}, {-10,5}}]

The picture below shows what I’d like to see for such a graph (a lot of the labelling has to be done by hand):

Show[
Plot[20, {x, -5,10}, PlotRange -> {-10,5}, AspectRatio ->Automatic],
ParametricPlot[f[t], {t, -20, 20},PlotStyle -> Black],
Graphics[Disk[{2,-8},.25]],
Graphics[Disk[{-1,-3},.25]],
Graphics[Disk[{-2,0},.25]],
Graphics[Disk[{-1,1},.25]],
Graphics[Disk[{2,0},.25]],
Graphics[Arrow[{{9,-4.45},{10.25,-5.25}}]],
Graphics[{ Text["t = -2", {3.25,-8}]}],
Graphics[{ Text["t = -1", {-2.25,-3}]}],
Graphics[{ Text["t = 0", {-3,-.5}]}],
Graphics[{ Text["t = 1", {-1,1.5}]}],
Graphics[Text["t = 2", {2.5,0.5}]]
]

Another example from the notes

f[t_] = {t Cos[t] + t/2, Sin[3t] - t};
ParametricPlot[f[t], {t, -20, 20}, 
PlotRange ->{{-20,20}, {-18,18}},
PlotStyle -> Black]

Sketching the graph of a function f : ℝ → (ℝ^3)

The graph of such a function is a curve in xyz-space (which shows only the output values of the function), where the inputs to the function are indicated by labelling points on the graph with the corresponding input.  The Mathematica commands are similar to those above:

f[t_] = {2 Cos[t], 2 Sin[t], t/2}

Table[{t,f[t]}, {t, 0, 2Pi, Pi/2}] // TableForm

ParametricPlot3D[f[t], {t, -20, 20}]

Sketching the graph of a function (ℝ^2) → ℝ

The graph of such a function is a surface in xyz-space above/below the (x,y)-plane.  The corresponding point (x,y) in the (x,y)-plane is the input to the function, and the height z is the output.

f[x_,y_] = y + x^2

Table[{x, y, f[x,y]}, {x,-2,2}, {y,-2,2}]

Plot3D[f[x,y], {x, -3,3}, {y, -3,3},
 PlotRange -> {-6,14}]

Some bells and whistles:

Plot3D[f[x,y], {x, -3,3}, {y, -3,3},
 PlotRange -> {-6,14},
 AxesLabel -> {"x","y","z"},
 BoxRatios -> Automatic, 
Mesh -> False, 
ColorFunction ->Hue,
Boxed -> False, 
PlotStyle -> Opacity[.8],
Lighting -> {{"Point",White,{20,0,0}},
{"Point",White,{0,-20,0}},
{"Point",White,{0,0,-20}}}]

Show[
Plot3D[f[x,y], {x, -4,4}, {y, -4,4},
 PlotRange -> {0,11},
 AxesLabel -> {"x","y","z"},
ClippingStyle -> None,
Mesh ->{4,4},
BoxRatios -> {1,1,2},
PlotStyle -> Opacity[.8],
Boxed -> False,
ColorFunction -> Hue,
Lighting -> {{"Point",White,{20,0,0}},
{"Point",White,{0,-20,0}},
{"Point",White,{0,0,-20}}}],
Graphics3D[{Gray, Arrow[{{0,0,0},{4,0,0}}]}],
Graphics3D[{Gray, Arrow[{{0,0,0},{0,4,0}}]}],Graphics3D[{Gray, Arrow[{{0,0,0},{0,0,10}}]}],
Graphics3D[{Blue,Sphere[{1,2,f[1,2]},.25]}],
Graphics3D[{Blue, Text[Style["(1,2,3)", Larger], {2,2,4}]}],
Graphics3D[{Blue, Text[Style["f(1,2) = 3", Larger], {-1,4,2}]}],
Graphics3D[{Blue, Dashed, Line[{{1,2,0},{1,2,4}}]}],
Graphics3D[{Blue, Dashed, Line[{{1,2,0},{1,0,0},{0,0,0},{0,2,0},{1,2,0}}]}],
Graphics3D[{Blue, Dotted, Line[{{1,2,3},{0,0,3}}]}]
]

Traces parallel to the x-axis (set y = constant)

f[x_,y_] = y + x^2;
Plot[f[x,0], {x,-3,3}, PlotStyle -> Green]
Plot[f[x,2],{x,-3,3}, PlotStyle -> Red]
Plot[f[x,1],{x,-3,3}, PlotStyle -> Blue]

ParametricPlot3D[{{x, 0, f[x,0]}, {x,1,f[x,1]}, {x, 2, f[x,2]}},{x, -4, 4},
PlotRange -> {{-2,2},{-2,2},{-2,8}},
PlotStyle -> {Green, Blue, Red}, 
BoxRatios -> {1,1,1}]

Show[
ParametricPlot3D[{{x, 0, f[x,0]}, {x,1,f[x,1]}, {x, 2, f[x,2]}},{x, -4, 4},
PlotRange -> {{-2,2},{-2,2},{-2,8}},
PlotStyle -> {Green, Blue, Red}, 
BoxRatios -> {1,1,1},
AxesLabel -> {"x","y","z"}],
ContourPlot3D[y == 0,{x, -4,4},{y,-4,4},{z,-2,8}, ContourStyle -> {Green, Opacity[.05]}, Mesh -> False],
ContourPlot3D[y == 1,{x, -4,4},{y,-4,4},{z,-2,8}, ContourStyle -> {Blue, Opacity[.05]}, Mesh -> False],
ContourPlot3D[y == 2,{x, -4,4},{y,-4,4},{z,-2,8}, ContourStyle -> {Red, Opacity[.05]}, Mesh -> False]
]

Traces parallel to the y-axis (set x = constant)

f[x_,y_] = y + x^2;
Plot[f[0,y], {y,-3,3}, PlotStyle -> Purple]
Plot[f[2,y],{y,-3,3}, PlotStyle -> Orange]
Plot[f[1,y],{y,-3,3}, PlotStyle -> Black]

Show[
ParametricPlot3D[{{0,x, f[0,x]}, {1,x,f[1,x]}, {2,x, f[2,x]}},{x, -4, 4},
PlotRange -> {{-2,2},{-2,2},{-2,8}},
PlotStyle -> {Purple, Black, Orange}, 
BoxRatios -> {1,1,1},
AxesLabel -> {"x","y","z"}],
ContourPlot3D[x == 0,{x, -4,4},{y,-4,4},{z,-2,8}, ContourStyle -> {Purple, Opacity[.05]}, Mesh -> False],
ContourPlot3D[x == 1,{x, -4,4},{y,-4,4},{z,-2,8}, ContourStyle -> {Black, Opacity[.05]}, Mesh -> False],
ContourPlot3D[x == 2,{x, -4,4},{y,-4,4},{z,-2,8}, ContourStyle -> {Orange, Opacity[.05]}, Mesh -> False]
]

Putting the traces together

Show[ParametricPlot3D[{{x, 0, f[x,0]}, {x,1,f[x,1]}, {x, 2, f[x,2]}},{x, -4, 4},
PlotRange -> {{-2,2},{-2,2},{-2,8}},
PlotStyle -> {Green, Blue, Red}, 
BoxRatios -> {1,1,1},
AxesLabel -> {"x","y","z"}, Boxed -> False],
ParametricPlot3D[{{0,x, f[0,x]}, {1,x,f[1,x]}, {2,x, f[2,x]}},{x, -4, 4},
PlotRange -> {{-2,2},{-2,2},{-2,8}},
PlotStyle -> {Purple, Black, Orange}, 
BoxRatios -> {1,1,1},
AxesLabel -> {"x","y","z"}]
]

Show[Plot3D[f[x,y], {x, -3,3}, {y, -3,3},
 PlotRange -> {-6,14},
 AxesLabel -> {"x","y","z"},
 BoxRatios -> Automatic, 
Mesh -> False,  
PlotStyle -> Opacity[.8],
Lighting -> {
{"Point",White,{-0,-20,0}},
{"Point",White,{0,0,-20}}}],
ParametricPlot3D[{{x, 0, f[x,0]}, {x,1,f[x,1]}, {x, 2, f[x,2]}},{x, -4, 4},
PlotRange -> {{-2,2},{-2,2},{-2,8}},
PlotStyle -> {Green, Blue, Red}, 
BoxRatios -> {1,1,1},
AxesLabel -> {"x","y","z"}, Boxed -> False],
ParametricPlot3D[{{0,x, f[0,x]}, {1,x,f[1,x]}, {2,x, f[2,x]}},{x, -4, 4},
PlotRange -> {{-2,2},{-2,2},{-2,8}},
PlotStyle -> {Purple, Black, Orange}, 
BoxRatios -> {1,1,1},
AxesLabel -> {"x","y","z"}]
]

Another example from the notes

Plot3D[y^2 Sin[x], {x, -4 Pi, 4 Pi}, 
{y, -12,12},
AxesLabel -> {"x","y","z"},
Boxed -> False]

Cylinders

The graph of a function z = f(x,y) where f has no y in the formula will be parallel to the y-axis:

Plot3D[3 -x^2, {x,-4,4}, 
{y, -5,5},
AxesLabel -> {"x","y","z"},
Boxed -> False]

The graph of a function z = f(x,y) where f has no x in the formula will be parallel to the x-axis:

Plot3D[4 Cos[y], {x,-4,4}, 
{y, -5,5},
AxesLabel -> {"x","y","z"},
Boxed -> False]

Contour plots of functions (ℝ^2) → ℝ

A level curve to a function z = f(x,y) is a curve in the (x,y) plane which gives the set of (x,y) satisfying f(x,y) = c for some constant c:

f[x_,y_] = y^2 - x

Here is the appropriate command to sketch a single level curve of a function (be sure to use two equals signs):

ContourPlot[f[x,y] == 0, {x, -4, 4}, {y,-4,4}, Axes -> True]

ContourPlot[f[x,y] == 2, {x, -4, 4}, {y,-4,4}, Axes -> True]

A collection of level curves to the same function z = f(x,y) is called a contour plot of the function.

ContourPlot[f[x,y] == Range[-2,2], {x,-4,4}, {y,-4,4}, Axes -> True]

Show[
ContourPlot[f[x,y] == -2, {x,-4,4}, {y,-4,4}, Axes -> True, ContourStyle -> Red],
ContourPlot[f[x,y] == -1, {x,-4,4}, {y,-4,4}, Axes -> True, ContourStyle -> Green],
ContourPlot[f[x,y] == 0, {x,-4,4}, {y,-4,4}, Axes -> True, ContourStyle ->Blue],
ContourPlot[f[x,y] == 1, {x,-4,4}, {y,-4,4}, Axes -> True, ContourStyle -> Orange],
ContourPlot[f[x,y] == 2, {x,-4,4}, {y,-4,4}, Axes -> True, ContourStyle ->Purple],
Graphics[{Purple,Text[Style["z = 2", Larger], {-1.75,1}]}],
Graphics[{Orange,Text[Style["z = 1", Larger], {-.25,.5}]}],
Graphics[{Blue,Text[Style["z = 0", Larger], {.5,-.1}]}],
Graphics[{Green,Text[Style["z = -1", Larger], {1.65,.4}]}],
Graphics[{Red,Text[Style["z = -2", Larger], {2.5,0}]}]
]

Show[
ParametricPlot3D[{t^2-2, t, 2}, {t, -20,20}, PlotRange -> {{-4,4},{-4,4},{-4,4}}, 
PlotStyle -> Purple, BoxRatios -> {1,1,1}, Boxed -> False, AxesLabel -> {"x","y","z"}],
ParametricPlot3D[{t^2-1, t, 1}, {t, -20,20}, PlotRange -> {{-4,4},{-4,4},{-4,4}}, 
PlotStyle -> Orange],
ParametricPlot3D[{t^2-0, t, 0}, {t, -20,20}, PlotRange -> {{-4,4},{-4,4},{-4,4}}, 
PlotStyle -> Blue ],
ParametricPlot3D[{t^2+1, t, -1}, {t, -20,20}, PlotRange -> {{-4,4},{-4,4},{-4,4}}, 
PlotStyle -> Green],
ParametricPlot3D[{t^2+2, t, -2}, {t, -20,20}, PlotRange -> {{-4,4},{-4,4},{-4,4}}, 
PlotStyle -> Red]
]

Here’s how the contour plot relates to the 3D graph:

Plot3D[y^2-x, {x,-4,4},{y,-4,4},
AxesLabel -> {"x","y","z"},
Mesh -> False]

Plot3D[y^2-x, {x,-4,4},{y,-4,4},
AxesLabel -> {"x","y","z"},
PlotRange -> {-5,5},
ClippingStyle -> False,
Boxed -> False,
Mesh -> False]

Show[Plot3D[y^2-x, {x,-4,4},{y,-4,4},
AxesLabel -> {"x","y","z"}, PlotRange -> {-3,3}, ClippingStyle -> False,
Mesh -> False, Boxed -> False, PlotStyle -> Opacity[.8]],
ParametricPlot3D[{t^2-2, t, 2}, {t, -20,20}, PlotRange -> {{-4,4},{-4,4},{-4,4}}, 
PlotStyle -> Purple, BoxRatios -> {1,1,1}, Boxed -> False, AxesLabel -> {"x","y","z"}],
ParametricPlot3D[{t^2-1, t, 1}, {t, -20,20}, PlotRange -> {{-4,4},{-4,4},{-4,4}}, 
PlotStyle -> Orange],
ParametricPlot3D[{t^2-0, t, 0}, {t, -20,20}, PlotRange -> {{-4,4},{-4,4},{-4,4}}, 
PlotStyle -> Blue ],
ParametricPlot3D[{t^2+1, t, -1}, {t, -20,20}, PlotRange -> {{-4,4},{-4,4},{-4,4}}, 
PlotStyle -> Green],
ParametricPlot3D[{t^2+2, t, -2}, {t, -20,20}, PlotRange -> {{-4,4},{-4,4},{-4,4}}, 
PlotStyle -> Red]
]

More examples from the notes

ContourPlot[x^2 - y + x y^2, {x,-3,3},{y,-3,3}, ContourLabels -> True]

ContourPlot[Sin[x-y] Cos[x+2y], {x,-3,3},{y,-3,3}, ContourLabels -> True]

Level surfaces to functions (ℝ^3) → ℝ

A level surface to a function w = f(x,y,z) is a surface in (x,y,z) space which gives the set of (x,y,z) satisfying f(x,y,z) = c for some constant c:

ContourPlot3D[x^2 + y^2 - z^2 == -1, {x,-3,3},{y,-3,3},{z,-3,3},
AxesLabel -> {"x","y","z"}]

ContourPlot3D[x^2 + y^2 - z^2 == 0, {x,-3,3},{y,-3,3},{z,-3,3},
AxesLabel -> {"x","y","z"}]

ContourPlot3D[x^2 + y^2 - z^2 == 1, {x,-3,3},{y,-3,3},{z,-3,3},
AxesLabel -> {"x","y","z"}]

Vector fields:  functions from (ℝ^n) → (ℝ^n) (same n)

A picture of a vector field shows a bunch of arrows in n-dimensional space.  If n = 2, this means that at each point in the plane, there is an arrow pointing in some direction.

f[x_,y_] = {x+y,x-y}

Table[{x,y,f[x,y]}, {x,-2,2},{y,-2,2}] // TableForm

VectorPlot[f[x,y], {x,-4,4},{y,-6,6}]

Another example in 3D

VectorPlot3D[{x+y+z,x-y,y+z},{x,-4,4},{y,-4,4},{z,-4,4},
AxesLabel -> {"x","y","z"}]