Surfaces, Level Curves & Level Surfaces.mw

restart; 1 

Let's use the plots package 

with(plots); 1 

[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
 

We'll begin by investigating the following function f 

f := 1/8*exp(`-`(x^2+y^2))*(cos(x)^2+sin(y)^2); 1 

1/8*exp(-x^2-y^2)*(cos(x)^2+sin(y)^2) 

Now plot this 

 

plot3d(f(x, y), x = -3 .. 3, y = -Pi .. Pi, numpoints = 1000, labels = (['x', 'y', 'z']), axes = normal); 1
plot3d(f(x, y), x = -3 .. 3, y = -Pi .. Pi, numpoints = 1000, labels = (['x', 'y', 'z']), axes = normal); 1
 

 

Plot 

 

Now use a countourplot(..) command to plot contours 

 

contourplot(f, x = -3 .. 3, y = -Pi .. Pi, numpoints = 1000, axes = FRAME, labels = (['x', 'y']), filled = true, coloring = ([blue, red])); 1
contourplot(f, x = -3 .. 3, y = -Pi .. Pi, numpoints = 1000, axes = FRAME, labels = (['x', 'y']), filled = true, coloring = ([blue, red])); 1
 

 

Plot 

 

The above uses a default number of contour levels (8). We can also set contour levels to values we select. Here we are selecting contour levels corresponding to f(x,y) = c where c is one of the list of points. 

 

c := [0.1e-1, 0.2e-1, 0.3e-1, 0.4e-1, 0.5e-1, 0.6e-1, 0.7e-1, 0.8e-1, 0.9e-1, .1, .11, .12, .13]; 1 

[0.1e-1, 0.2e-1, 0.3e-1, 0.4e-1, 0.5e-1, 0.6e-1, 0.7e-1, 0.8e-1, 0.9e-1, .1, .11, .12, .13] 

contourplot(f, x = -3 .. 3, y = -Pi .. Pi, numpoints = 1000, axes = FRAME, labels = (['x', 'y']), filled = true, coloring = ([blue, red]), contours = c); 1
contourplot(f, x = -3 .. 3, y = -Pi .. Pi, numpoints = 1000, axes = FRAME, labels = (['x', 'y']), filled = true, coloring = ([blue, red]), contours = c); 1
 

 

Plot 

 

Now to get level surfaces in 3 dimensions, we use the implicitplot3d(..) command (contourplot3d does not do level surfaces). Recall that the implicitplot3d will plot a function defined as - f(x,y,z) = c - which is simply a level surface. 

 

f := 'f'; 1 

f 

f := z^3+2*x^2-3*y^2; 1 

z^3+2*x^2-3*y^2 

implicitplot3d(f = 0, x = -3 .. 3, y = -2 .. 2, z = -4 .. 4, numpoints = 10000, axes = FRAME, labels = (['x', 'y', 'z'])); 1
implicitplot3d(f = 0, x = -3 .. 3, y = -2 .. 2, z = -4 .. 4, numpoints = 10000, axes = FRAME, labels = (['x', 'y', 'z'])); 1
 

 

Plot 

 

 

 

Here we plot 3 level surfaces corresponding to f(x,y) = 0, f(x,y) = 10 and f(x,y) = 20 

implicitplot3d([f = 0, f = 10, f = 20], x = -3 .. 3, y = -2 .. 2, z = -4 .. 4, numpoints = 10000, axes = FRAME, labels = (['x', 'y', 'z'])); 1
implicitplot3d([f = 0, f = 10, f = 20], x = -3 .. 3, y = -2 .. 2, z = -4 .. 4, numpoints = 10000, axes = FRAME, labels = (['x', 'y', 'z'])); 1
implicitplot3d([f = 0, f = 10, f = 20], x = -3 .. 3, y = -2 .. 2, z = -4 .. 4, numpoints = 10000, axes = FRAME, labels = (['x', 'y', 'z'])); 1
 

 

Plot