21
> > > > > > > > > > Contour Diagrams restart:with(plots): setoptions3d(axes=NORMAL,labels=["x","y","z"],orientation=[20,70]); We start with the graph of z = fx, y = x 2 y 2 and we plot its graph. z:=sqrt(x^2+y^2); z x 2 y 2 plot3d(z,x=-9..9,y=-9..9,view=[-9..9,-9..9,0..9],style=patchnogrid) ; The graph appears to be that of an inverted cone of height 9. To find a contour line or level set for the surface, we first look at the intersection of the surface with a horizontal plane, say the plane z = 6. p1:=plot3d(z,x=-9..9,y=-9..9,view=[-9..9,-9..9,0..9],style= patchnogrid): p2:=plot3d(6,x=-9..9,y=-9..9,view=[-9..9,-9..9,0..9],style= patchnogrid): p3:=plot3d([6*cos(t),6*sin(t),6],t=0..2*Pi,u=0..5): display(p1,p2,p3);

Contour Diagrams - facstaff.cbu.edu

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Contour Diagrams - facstaff.cbu.edu

> >

> >

> >

> >

> >

Contour Diagrams

restart:with(plots):setoptions3d(axes=NORMAL,labels=["x","y","z"],orientation=[20,70]);

We start with the graph of z = f x, y = x2 y2 and we plot its graph.z:=sqrt(x^2+y^2);

z x2 y2

plot3d(z,x=-9..9,y=-9..9,view=[-9..9,-9..9,0..9],style=patchnogrid);

The graph appears to be that of an inverted cone of height 9. To find a contour line or level set for the surface, we first look at the intersection of the surface with a horizontal plane, say the plane z = 6.p1:=plot3d(z,x=-9..9,y=-9..9,view=[-9..9,-9..9,0..9],style=patchnogrid):p2:=plot3d(6,x=-9..9,y=-9..9,view=[-9..9,-9..9,0..9],style=patchnogrid):p3:=plot3d([6*cos(t),6*sin(t),6],t=0..2*Pi,u=0..5):display(p1,p2,p3);

Page 2: Contour Diagrams - facstaff.cbu.edu

> > Then we project the curve(s) of intersection onto the xy-plane to get the contour line(s) or level set.p1:=plot3d(z,x=-9..9,y=-9..9,view=[-9..9,-9..9,0..9],style=wireframe):p2:=plot3d(6,x=-9..9,y=-9..9,view=[-9..9,-9..9,0..9],style=wireframe):p3:=plot3d([6*cos(t),6*sin(t),6],t=0..2*Pi,u=0..5):p4:=plot3d([6*cos(t),6*sin(t),0],t=0..2*Pi,u=0..5):p5:=plot3d([-6,0,t],t=0..6,u=0..5):p6:=plot3d([6,0,t],t=0..6,u=0..5):p7:=plot3d([0,-6,t],t=0..6,u=0..5):p8:=plot3d([0,6,t],t=0..6,u=0..5):display(p1,p2,p3,p4,p5,p6,p7,p8);

Page 3: Contour Diagrams - facstaff.cbu.edu

> >

> >

Using the plottools package and the transform command, we can get another view at how the contour diagram is developed by the intersections of planes with the surface being projected onto the xy-plane.

with(plottools);annulus, arc, arrow, circle, cone, cuboid, curve, cutin, cutout, cylinder, disk, dodecahedron, ellipse,ellipticArc, exportplot, extrude, getdata, hemisphere, hexahedron, homothety, hyperbola,icosahedron, importplot, line, octahedron, parallelepiped, pieslice, point, polygon, polygonbyname,prism, project, rectangle, reflect, rotate, scale, sector, semitorus, sphere, stellate, tetrahedron,torus, transform, translate, triangulate

p := plot3d(z,x=-9..9,y=-9..9,view=[-9..9,-9..9,0..9],style=contour,contours=8):q := contourplot(z,x=-9..9,y=-9..9):f := transform((x,y) -> [x,y,0]):display({p,f(q)});

Page 4: Contour Diagrams - facstaff.cbu.edu

> > A modification of the above shows the contours on the surface itself.p := contourplot3d(z,x=-9..9,y=-9..9,view=[-9..9,-9..9,0..9],filled=true):q := contourplot(z,x=-9..9,y=-9..9,filled=true):f := transform((x,y) -> [x,y,0]):display({p,f(q)});

Page 5: Contour Diagrams - facstaff.cbu.edu

> >

Now let's focus on just the contourplot for this surface. The option"scaling=constrained" is used to get the same scale on both the x- and the y-axis.

contourplot(z,x=-9..9,y=-9..9,scaling=constrained);

x8 6 4 2 0 2 4 6 8

y

8

6

4

2

2

4

6

8

Maple chooses 8 equally spaced levels by default, with the contours colored in shades from red to blue asthey increase in size. You can also choose to fill in the contours

Page 6: Contour Diagrams - facstaff.cbu.edu

> >

> >

> >

contourplot(z,x=-9..9,y=-9..9,scaling=constrained,filled=true);

You can choose how many contours you wish.contourplot(z,x=-9..9,y=-9..9,contours=20,scaling=constrained);

x8 6 4 2 0 2 4 6 8

y

8

6

4

2

2

4

6

8

You can also choose the levels for your contours.contourplot(z,x=-9..9,y=-9..9,contours=[1,2,3,4,5,6,7,8,9],scaling=constrained);

Page 7: Contour Diagrams - facstaff.cbu.edu

> >

> >

> >

x8 6 4 2 0 2 4 6 8

y

8

6

4

2

2

4

6

8

The equal spacing of the contours for this function is due to the fact that the "sides" of the cone increase at a constant rate. Let's compare our original function to z=g x, y = x2 y2 .

z:=x^2+y^2;z x2 y2

plot3d(z,x=-9..9,y=-9..9,view=[-9..9,-9..9,0..60],style=patchnogrid);

Page 8: Contour Diagrams - facstaff.cbu.edu

> >

> >

We see that the sides here do not increase at a constant rate. We consider 20 equally spaced contours, the multiples of 3 from 3 to 60.contourplot(z,x=-9..9,y=-9..9,contours=[seq(3*i,i=1..20)],scaling=constrained);

x6 4 2 0 2 4 6

y

6

4

2

2

4

6

We see that the contours become closer as the height of the level increases, indicating a greater rate of

Page 9: Contour Diagrams - facstaff.cbu.edu

> >

> >

> >

> >

change in the positive direction as the height of the level increases. Now let's flip this surface upside down.

z:=60-(x^2+y^2);z x2 y2 60

plot3d(z,x=-9..9,y=-9..9,view=[-9..9,-9..9,0..60],style=patchnogrid);

We compare the contour plot here with the previous one.contourplot(z,x=-9..9,y=-9..9,contours=[seq(3*i,i=1..20)],scaling=constrained,filled=true);

Page 10: Contour Diagrams - facstaff.cbu.edu

> >

> >

> >

We see that the contours become closer as the height of the level decreases, indicating a greater rate of change in the negative direction as the height of the level decreases. We next look at a more interesting surface, the saddle, with this one given by the function z = f x, y = x2 y2 .

z:=x^2-y^2;z x2 y2

plot3d(z,x=-4..4,y=-4..4,style=patchnogrid);

Page 11: Contour Diagrams - facstaff.cbu.edu

> >

> >

We look first at the level z = 0.p1:=plot3d(z,x=-4..4,y=-4..4,style=patchnogrid):p2:=plot3d(0,x=-4..4,y=-4..4,style=patchnogrid,color=blue):p3:=plot3d([x,x,0],x=-4..4,y=-4..4,thickness=5):p4:=plot3d([-x,x,0],x=-4..4,y=-4..4,thickness=5):display(p1,p2,p3,p4);

Page 12: Contour Diagrams - facstaff.cbu.edu

> >

> >

A close inspection suggests the plane intersects the saddle in two intersecting lines. Changing the view gives a better perspective on this.p1:=plot3d(z,x=-4..4,y=-4..4,style=patchnogrid):p2:=plot3d(0,x=-4..4,y=-4..4,style=patchnogrid,color=blue):p3:=plot3d([x,x,0],x=-4..4,y=-4..4,thickness=5):p4:=plot3d([-x,x,0],x=-4..4,y=-4..4,thickness=5):display(p1,p2,p3,p4,orientation=[27,32]);

Page 13: Contour Diagrams - facstaff.cbu.edu

> >

> >

In fact, the lines we see are the lines x y = 0 and x y = 0. What will we get from the intersections ofother horizontal planes? We look at the contour diagram for 19 equally spaced contours.contourplot(z,x=-9..9,y=-9..9,contours=[seq(3*i,i=-9..9)],scaling=constrained);

x8 6 4 2 0 2 4 6 8

y

8

6

4

2

2

4

6

8

We first notice the two intersecting lines at the origin resulting from the plane z = 0 viewed above. The

Page 14: Contour Diagrams - facstaff.cbu.edu

> >

> >

> >

> >

nine horizontal planes for negative levels intersect the saddle in hyperbolas, with the two branches shown above and below the x-axis in shades of red. The nine horizontal planes for positive levels also intersect the saddle in hyperbolas, but with the two branches shown left and right of the y-axis in shades of blue. We view another contourplot for the same function.

contourplot(z,x=-9..9,y=-9..9,contours=20,scaling=constrained);

x8 6 4 2 0 2 4 6 8

y

8

6

4

2

2

4

6

8

Next we look at the contour diagram for a plane.z:=-4*x-3*y+24;

z 4 x 3 y 24

plot3d(z,x=-8..8,y=-10..10,view=[0..8,-0..10,0..26],style=patchnogrid);

Page 15: Contour Diagrams - facstaff.cbu.edu

> >

> >

> >

The contour diagram.contourplot(z,x=-10..10,y=-10..10,contours=20,scaling=constrained);

x10 5 0 5 10

y

10

5

5

10

Notice that the contours are parallel lines. Our final surface has many interesting aspects.z:=cos(x)*cos(y)*exp(-sqrt(x^2+y^2)/4);

Page 16: Contour Diagrams - facstaff.cbu.edu

> >

> >

> > z cos x cos y e

x2 y2

4

plot3d(z,x=-10..10,y=-10..10,style=patchnogrid,numpoints=5000);

We view a contour diagram with 20 equally spaced contours.contourplot(z,x=-10..10,y=-10..10,contours=20,scaling=constrained,numpoints=5000);

Page 17: Contour Diagrams - facstaff.cbu.edu

> >

> >

x10 5 0 5 10

y

10

5

5

10

This contour diagram shows that the most radical behavior for this function lies near the origin of the xy-plane (deep reds and blues) with the surface staying pretty close to the xy-plane away from the origin (violets away from the origin). Last, we look at the 3d and 2d contour diagrams together.p := contourplot3d(z,x=-9..9,y=-9..9,filled=true):q := contourplot(z,x=-9..9,y=-9..9,filled=true):f := transform((x,y) -> [x,y,-1]):display({p,f(q)});

Page 18: Contour Diagrams - facstaff.cbu.edu

> >

> >

> >

Density PlotsWe use the densityplot command to form density plots. We will use the saddle function as an example.z:=x^2-y^2;

z x2 y2

densityplot(z,x=-9..9,y=-9..9);

Page 19: Contour Diagrams - facstaff.cbu.edu

> >

> >

> > We can remove the gridlines.densityplot(z,x=-9..9,y=-9..9,style=patchnogrid);

We can choose a color.densityplot(z,x=-9..9,y=-9..9,style=patchnogrid,color=green);

Page 20: Contour Diagrams - facstaff.cbu.edu

> >

> >

> >

We can use a variety of colors.densityplot(z,x=-9..9,y=-9..9,style=patchnogrid,colorstyle=HUE);

Finally, we can change the brightness and contrast.densityplot(z,x=-9..9,y=-9..9,style=patchnogrid,colorstyle=HUE,brightness=0.7,contrast=0.7);

Page 21: Contour Diagrams - facstaff.cbu.edu

> >