WOLFRAM NOTEBOOK

Template Notebook
Generate

Mathematica Lesson 7: Surfaces

In the menu at the top, click Make Your Own Copy to work in Mathematica Online, or click Download to use it in Mathematica.​
​​
​When asked "Do you want to automatically evaluate all the initialization cells in the notebook...?" I recommend "No" so that you can work through each cell one-at-a-time.

Scalar-valued functions of multiple variables

Question 2

To create the function f(x,y)=x²+y², evaluate
In[]:=
f[x_, y_]:=x^2+y^2
in Mathematica. We have seen this type of syntax (square bracket, underscore, colon) before when we learned about curves. This is how you define functions in Mathematica.​
​​
​After defining your function (and evaluating with Shift-Return), see if you can use it. What is​
​f(37,3)? (Be sure to use square brackets!)

Information:

To create a basic graph of the paraboloid over the domain -4 x 4, -4 y 4, try
In[]:=
Plot3D[f[x,y],{x,-4,4},{y,-4,4}]
You can also experiment with dressing the plot up a bit, e.g. with
In[]:=
Plot3D[f[x,y],{x,-4,4},{y,-4,4},BoxedFalse,AxesLabelAutomatic,AxesOrigin{0,0,0}]
Fun tip: You can grab the image with your mouse and move it around to see the surface from different points of view.​
​​
​Read more about Plot3D here: https://reference.wolfram.com/language/ref/Plot3D.html

Graphing z=f(x,y)

Information:

In WebAssign Homework 3.1, you will have problems asking you to match functions z=f(x,y) to their graphs. Students usually find these challenging because it's hard to determine what the entire graph looks like in ℝ³.​
​​
​In fact, that is not the goal--we want you to use process of elimination by looking for the following major behavioral clues:
  • What is the z-intercept? (Mentally plug in x=0 and y=0.)
  • What does the function look like over the x-axis? (Plug in y=0.)
  • What does the function look like over the y-axis? (Plug in x=0.)
  • Are there any terms that would cause oscillating, periodic behavior? E.g. cos(x), or sin(4y).
  • What does the behavior look like as input pairs (x,y) move away from the origin? E.g. f(x,y) = exp(-x² - y²) goes to 0, so we would expect this graph to flatten out away from the origin.
  • Look for other clues, e.g. recognizable behaviors like |x|, y², ln(x), etc.
  • With just these questions, you can mostly solve the WebAssign problems. If you need more, though, you can graph the equations in Mathematica!

    Question 3

    (1) Without any computational aid, try the above steps on the following functions to match them to their graphs (not all graphs are plotted over the same (x,y) domain): f(x,y) = x²y f(x,y) = sin(3x)sin(5y)/(xy) f(x,y) = sin(x²+y²) (try this one on 3 x 3, 3 y 3) f(x,y) = cos(x)y² (try this one on 15 x 15, 15 y 15)

    ​(2) Then verify your responses by graphing each with Plot3D in Mathematica. ​
    ​Note that you do not need to define the functions first, you can pass directly to Plot3D via
    In[]:=
    Plot3D[Sin[3x]Sin[5y]/(x*y),{x,-6,6},{y,-6,6}]
    One styling add-on you may like is PlotRange. You can try PlotRangle->{-2,10} to specify 2 z 10, or simply PlotRange->All. The above graph would be 
    Plot3D[Sin[3x]Sin[5y]/(x*y),{x,-6,6},{y,-6,6},PlotRangeAll]

    Contour Plots

    Information:

    One way to present information about a function z=f(x,y) is to do a two-dimensional contour plot consisting of the level sets (sometimes called level curves) for the surface. You will see some of these in WebAssign Homework 3.1.​
    ​​
    ​Let's review what this terminology means for z=f(x,y):
  • C-level set: the set of points x,y)in the x,y)plane which all get mapped to the value z=C.Examples:
  • The 1-level curve for f(x,y) = x²+y² is the unit circle. The R-level curve for f(x,y) = x²+y² is the circle of radius Sqrt[R].
  • The 0-level set for f(x,y)=xy is the set of points so that xy=0. This set would look like the union of the x- and y-axes. The 1-level set is the hyperbola 1=xy, i.e. y = 1/x.
  • Contour plot (aka contour map): Plotting a bunch of level sets on the same plot to give an overview of the different elevations (z values) a function takes over different parts of the domain. Understanding what a contour map communicates gives you a feel for the surface. This is similar to topographic maps used by hikers, see https://www.rei.com/learn/expert-advice/topo-maps-how-to-use.html.
  • The contour map for f(x,y) = x²+y² looks like concentric circles.
  • The contour map for f(x,y) = xy looks like "concentric" hyperbola.
  • The contour map for f(x,y,z) = x²+y²+z² looks like concentric spheres.
  • The command to create contour plots in Mathematica is ContourPlot. The program not graphs level curves, but also shades between them to emphasize the elevation levels.​
    ​​
    ​Try the following:
    ContourPlot[x^2+y^2,{x, -5, 5},{y, -5, 5}]
    ContourPlot[x*y,{x, -5, 5},{y, -5, 5}]

    Question 4

    Without graphing the surface or analyzing the function, run
    ContourPlot[x*Exp[(-x^2-y^2)/4],{x,-4,4},{y,-4,4},ContourLabelsTrue]
    in Mathematica. Just based on the image you produce, answer the questions in Moodle.​
    ​​
    ​Predict what the graph of z=x*exp((x²+y²)/4) looks like. Then run
    In[]:=
    Plot3D[x*Exp[(-x^2-y^2)/4],{x,-4,4},{y,-4,4},PlotRangeAll]

    Question 5

    Without graphing the surface or analyzing the function, run
    ContourPlot[x*y*Exp[(-x^2-y^2)/4],{x,-4,4},{y,-4,4},ContourLabelsTrue]
    in Mathematica. Just based on the image you produce, answer the questions in Moodle.​
    ​​
    ​Predict what the graph of z=x*y*exp((x²+y²)/4) looks like. Then run
    In[]:=
    Plot3D[x*y*Exp[(-x^2-y^2)/4],{x,-4,4},{y,-4,4},PlotRangeAll]

    Question 6

    Without graphing the surface or analyzing the function, run
    ContourPlot[y*Cos[y]/(1+x^2),{x,-10,10},{y,-10,10}]
    in Mathematica. It's possible you will have what looks like empty white space. To attempt to fill that in, try
    ContourPlot[y*Cos[y]/(1+x^2),{x,-10,10},{y,-10,10},PlotRangeAll]
    in Mathematica. Just based on the image you produce, answer the questions in Moodle.​
    ​​
    ​Predict what the graph of z=y*cos(y)/(1+x²) looks like. Then run
    Plot3D[y*Cos[y]/(1+x^2),{x,-10,10},{y,-10,10},PlotRangeAll]

    Question 7

    Experiment with Plot3D below!

    Parametric surfaces

    Question 8

    We will define parametric surfaces in Mathematica using the same syntax. Fill in the expected left-hand side to create the function ​
    ​r(u,v) = ⟨u , v , u² + v² ⟩ in Mathematica.
    {u,v,u^2+v^2}
    (hint: square brackets, underscore, colon...)​
    ​​
    ​What does this function r parametrize?

    Question 9

    To plot the parametric surface we just defined, try
    ParametricPlot3D[r[u,v],{u,-3,3},{v,-3,3}]
    Hopefully you can recognize that this plots the surface over 3 u 3, 3 v 3.​
    ​​
    ​Now try to create a parametric plot of r(u,v)=<u, v, cos(u)|v| > over 10 u 10, 5 v 5.
    Wolfram Cloud

    You are using a browser not supported by the Wolfram Cloud

    Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


    I understand and wish to continue anyway »

    You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.