Introduction to Mathematica for High School Math (for Students and Teachers) #10
Author
Ruth Dover
Title
Introduction to Mathematica for High School Math (for Students and Teachers) #10
Description
Introduction to Mathematica for High School Math
Category
Educational Materials
Keywords
Mathematics, education
URL
http://www.notebookarchive.org/2021-09-6h2cbgm/
DOI
https://notebookarchive.org/2021-09-6h2cbgm
Date Added
2021-09-14
Date Last Modified
2021-09-14
File Size
51.12 kilobytes
Supplements
Rights
Redistribution rights reserved



Tutorial 10: 3D Graphs
Tutorial 10: 3D Graphs
R. Dover, IMSA
Basic Graphing
Basic Graphing
The command to plot a three-dimensional function uses familiar coding, but there are now two independent variables, so it is necessary to give domain values for both and . Try the following examples:
x
y
Plot3D[Sin[xy],{x,-3,3},{y,-3,3}]
Plot3D[Exp[1-+],{x,-7,7},{y,-3,3}]
2
x
2
y
As with 2D graphs, the Wolfram Language™ chooses a range automatically, but this can be controlled. But when the range goes off to infinity…
Plot3D[Cos[+],{x,-3,3},{y,-3,3}]
2
x
2
y
Move your cursor over the preceding graph. Note that the cursor itself has a new form. Drag the cursor around the graph to change the view. Now, hold down the Alt key and move your cursor up and down to zoom. (Pretty neat!)
Check out the options available for . Lots of options.
Plot3D
Now we will look at , an option that is useful for a function that is very bumpy. Look at both of the following to see the effect:
PlotPoints
Plot3D[Sin[],{x,0,3},{y,0,3}]
2
x
2
y
Plot3D[Sin[],{x,0,3},{y,0,3},PlotPoints50]
2
x
2
y
This helps a great deal to make the graph clearer, but it does slow down. Tradeoffs.
As before, you can graph two functions at once. There are some nice options to help see the graphs more clearly:
Plot3D[{Sin[xy],4-(+)},{x,-3,3},{y,-3,3},PlotRange{-8,4}]
2
x
2
y
Plot3D[{Sin[xy],4-(+)},{x,-3,3},{y,-3,3},PlotRange{-8,4},PlotStyle{Opacity[.3],Opacity[.8]}]
2
x
2
y
Plot3D[{Sin[xy],4-(+)},{x,-3,3},{y,-3,3},PlotRange{-8,4},PlotStyle{Opacity[.3],Opacity[.8]},ColorFunction"BlueGreenYellow"]
2
x
2
y
Plot3D[{Sin[xy],4-(+)},{x,-3,3},{y,-3,3},PlotRange{-8,4},PlotStyle{Opacity[.3],Opacity[.8]},ColorFunction"RustTones"]
2
x
2
y
Related Graphs
Related Graphs
We will go back to for a moment. First, look at the basic graph again:
z=sin(xy)
Plot3D[Sin[xy],{x,-3,3},{y,-3,3}]
ContourPlot
ContourPlot
To see the related contour graph, execute the following. Make sure you see what the dark and light sections represent. Move your cursor over the graph to see the values of the contours:
ContourPlot[Sin[xy],{x,-3,3},{y,-3,3}]
Here are a couple of options:
ContourPlot[Sin[xy],{x,-3,3},{y,-3,3},ColorFunction"Rainbow"]
ContourPlot[Sin[xy],{x,-3,3},{y,-3,3},ContourLabelsAutomatic]
If you would like to see the level curves or the contour map without the shading, simply "turn off" the shading:
ContourPlot[Sin[xy],{x,-3,3},{y,-3,3},ContourShadingFalse]
Mathematica® will also be happy to graph specific contours for you. Again, move the cursor over the graph:
ContourPlot[{Sin[xy]0,Sin[xy]3/4},{x,-3,3},{y,-3,3}]
DensityPlot
DensityPlot
This plot will give you similar information, but in a different form:
DensityPlot[Sin[xy],{x,-3,3},{y,-3,3}]
DensityPlot[Sin[xy],{x,-3,3},{y,-3,3},ColorFunction"SolarColors"]
RegionPlot
RegionPlot
We have seen this earlier, but with functions of the form . This command will plot the function only under given conditions on and :
y=f(x)
x
y
RegionPlot[Sin[xy]>0,{x,-3,3},{y,-3,3}]
In the following example, the two vertical bars represent the logical "OR." Also PlotPoints helps this graph a bit ("AND" is shown by ):
||
&&
RegionPlot[Sin[xy]>0||Sin[xy]<-2/3,{x,-3,3},{y,-3,3},PlotPoints40]
Useful Options
Useful Options
Mesh
Mesh
We saw this briefly in 2D graphics, and it can be quite useful in 3D graphics. First of all, we will see how Mathematica graphs in 3D. Note the triangular regions, and note too that they are more plentiful where the graph changes more rapidly:
Plot3D[Sin[xy],{x,-3,3},{y,-3,3},MeshAll]
Here, you can also control the mesh for different variables. This is only an introduction.
We will change the domain a little bit here so that it is easier to see. This puts five lines evenly spaced within the domain in both the and directions:
x
y
Plot3D[Sin[xy],{x,0,3},{y,0,3},Mesh5]
The pure function following, with the 3 referring to , shows the contour lines, or lines that represent equal height. That is, lines where takes on constant values within the range. You can also control the number of level curves:
z
z
Plot3D[Sin[xy],{x,0,3},{y,0,3},Mesh3,MeshFunctions{#3&}]
You can use any function to define the mesh to be drawn. Following is one example. The and refer to and , respectively.
1
2
x
y
Plot3D[Sin[xy],{x,0,3},{y,0,3},Mesh5,MeshFunctions{Sqrt[+]&}]
2
#1
2
#2
RegionFunction
RegionFunction
The command allowed you to specify the conditions of the function that must hold in order to plot the function. leaves the function alone, but allows you to specify a domain that is not simply an - rectangular box. Any sort of inequality can be used:
RegionPlot
RegionFunction
x
y
Plot3D[Sin[xy],{x,-3,3},{y,-3,3},RegionFunctionFunction[{x,y,z},2<+<6]]
2
x
2
y
Plot3D[Sin[xy],{x,-3,3},{y,-3,3},RegionFunctionFunction[{x,y,z},1<+<3||5<+<7]]
2
x
2
y
2
x
2
y
More (Plain) Graphs
More (Plain) Graphs
Check out the following examples. Many are interesting, particularly around the origin. You should also try some related graphs or other options with them:
Plot3D+,{x,-1,1},{y,-1,1}
xy
2
x
2
y
Plot3D,{x,-1,1},{y,-1,1}
y
3
x
We can throw in other variations on that one!
Plot3D,{x,-1,1},{y,-1,1},ClippingStyleNone
y
3
x
Plot3D,{x,-1,1},{y,-1,1},ClippingStyle{{Red,Opacity[.6]},{Yellow,Opacity[.6]}}
y
3
x
Plot3DSin,{x,-1,1},{y,-1,1}
1
xy
Plot3D[Log[xy],{x,-1,1},{y,-1,1}]
Plot3D,{x,-2,2},{y,-2,2}
2x-
2
y
2+y
2
x
ParametricPlot3D
ParametricPlot3D
As you may have guessed, Mathematica can also graph 3D parametric curves. You must give expressions for , and in terms of (or another parameter):
x
y
z
t
ParametricPlot3D[{Cos[2t],Cos[t],Sin[3t]},{t,0,2π}]
Exercises
Exercises
Plot the graph of . Choose a reasonable domain. Add a green clipping style (even if it is not very pretty).
z=
x+y
x-y
Plot the graph of . Make the graph partially transparent. Then add a function and a clipping style. (Your choice!)
z=-
2
x
2
x
2
y
Color
Plot the graph of on the region with +<9. Then look at a contour plot of the same region.
z=arctanx
2
y
2
x
2
y


Cite this as: Ruth Dover, "Introduction to Mathematica for High School Math (for Students and Teachers) #10" from the Notebook Archive (2021), https://notebookarchive.org/2021-09-6h2cbgm

Download

