MAT 272 Computer Lab 4: Multivariable FunctionsIn this lab you will study functions of two variables. You will find their cross sections with planes and their contourplots using the command plot3d and contourplot. <Text-field layout="_pstyle3" style="_cstyle5">Examples</Text-field><Text-field layout="_pstyle4" style="_cstyle6">I. Graphs of Functions with two variables</Text-field>The plot3d command plots the graph of a function of two variables. For instance, the graph of the function NiMvLSUiZkc2JCUieEclInlHLCYqJEYnIiIjIiIiRihGLA== is plotted as follows:restart: with(plots):setoptions3d(style=patchcontour, shading=zhue, axes=frame, scaling=constrained):plot3d(x^2+y, x=-2..2, y=-2..2);Notice that the first argument of the plot3d command is the formula for NiMtJSJmRzYkJSJ4RyUieUc= , not an equation. In the example above, you should see the level curves NiMvLCYqJCUieEciIiMiIiIlInlHRiglImtH corresponding to different choices of NiMvJSJ6RyUia0c= . Another way to plot two variable finctions is to define the function f first and then plot f :f :=(x,y) -> x^2 + y^2;plot3d(f(x,y), x=-2..2, y=-2..2);Or a third way is to define the expression g and plot g:g:= x^2 - y^2;plot3d(g, x=-2..2, y=-2..2);To plot cross sections in the xz or yz planes, input: plot ( f(1,y) , y=-3..3, z=-3..3); and try others such as f(x,2). Be sure to use limits which will enable you to see the graph. Notice that you can do this if you defined a function, not an expression! plot ( f(1,y) , y=-3..3, z=-3..3);
To plot horizontal planes intersecting the surface, input:
plot3d ( { f(x,y), 2, 4, 6}, x=-3..3 , y=-3..3 , view=0..9);
To plot vertical planes in intersecting the surface, input the following statements.
a:=plot3d(f(x,y),x=-3..3,y=-3..3,view=0..9):
b:=implicitplot3d(y=1,x=-3..3,y=-3..3,z=0..9):
display3d({a,b});Note: the view= 0..9 command lets you set the z values on the graph.<Text-field layout="_pstyle4" style="_cstyle6">II. Contourplots</Text-field>First plot a 3 dimensional surface with boxed axes again to see what it looks like. plot3d(g,x=-3..3,y=-3..3,view=-3..9);One way to get a two-dimensional contour plot:
contourplot(g,x=-4..4,y=-4..4,contours=15);Note that we set the number of contours to 15. The default number is 10. Here we don't know the constant values corresponding to the level curves.In the following example we specify the values of the level curves.contourplot(g,x=-4..4,y=-4..4,contours=[-6,-4,-2,0,2,4,6],filled = true);This plots the contours -6, -4, -2, 0, 2, 4, 6. Note that we used the option "filled = true". This gives a color version of the contour.The color goes from yellow to red with yellow corresponding to larger values of the level curves.We can also generate a 3D view of the contours raised to their appropriate levelscontourplot3d(g,x=-4..4,y=-4..4,contours=[-6,-4,-2,0,2,4,6],filled=true,axes=framed);You can also plot together the surface with its contour plot.with(plottools): p := plot3d(g,x=-4..4,y=-4..4,style=patchcontour,contours=8,view=-4..4):
q := contourplot(g,x=-4..4,y=-4..4):
f := transform((x,y) -> [x,y,0]):
display({p,f(q)});p := plot3d(g,x=-4..4,y=-4..4,style=contour,contours=8,view=-4..4):
q := contourplot(g,x=-4..4,y=-4..4,filled= true):
f := transform((x,y) -> [x,y,0]):
display({p,f(q)});
To plot all the levels and the surface together use the following statement: This will show the surface being sliced. Rotate the plot and observe.)plot3d({g,2,4,6,8},x=-4..4,y=-4..4,view=0..10);<Text-field layout="_pstyle3" style="_cstyle5">Exercises to turn in</Text-field>1. Plot the surface and plot the contour diagram and observe the relation between them for NiMvLSUiZkc2JCUieEclInlHLCoqJEYnIiIkIiIiRichIiIqJEYoRitGLCokRigiIiNGLA== , -2.5 < x < 2.5, -2.5 < y < 2.52. (a) Plot NiMvLSUiZkc2JCUieEclInlHLSUkZXhwRzYjLCYqJEYnIiIjISIiKiRGKEYuRi8= using a suitable grid.(b) Plot the contour and observe the relation between the two plots(c) Find equations for the contour values 0.1, 0.4, and 0.7 using paper and pencil below . Graph these contour levels.