Prof. Vladimir Dobrushkin
Department of Mathematics
TO SYLLABUS
TO GRADING
TO SOFT
TO BOOKS
TO QUIZZES
 

MTH243 (Calculus for Functions of Several Variables)
MAPLE. Chapter 12:
Functions of Several Variables

Vladimir A. Dobrushkin,Lippitt Hall 202C, 874-5095,dobrush@uri.edu

In this course we will use computer algebra system (CAS) Maple, which is not available in computer labs at URI---it should be purchased separately. The Maple projects are created to help you learn new concepts. It is an essential part of WileyPlus, Matlab, and Mathcad. Maple is very useful in visualizing graphs and surfaces in three dimensions. Matlab (commercial software) is also available at engineeering labs. Its free version is called Octave. A student can also use free CASs: SymPy (based on Python), Maxima, or Sage. We follow the standard textbook "Multivariable Calculus" (6th edition) by McCallum, Hughes-Hallett, Gleason et al.

 

Section 12.1. Functions of two Variables

Vectors in the Wolfram Language are simply represented by lists:
v = { a, b, c }
where a, b, and c could be any expressions, numerical or algebraic. Therefore, Mathematica does pay attention whether a vector is a column vecor or a row vector. To specify the column (or row) vector, one should define it as a matrix

 

Section 12.2. Graphs of Functions of two Variables

Example 1. We start plotting the graph of a paraboloid, which is defined by the function \( f (x, y) = x^2+y^2 . \)

f:= piecewise(x<=-2,-x^2,-2<=2, 2*x,x>2,x^2+4);
plot(f(x), x=-4..4, discont=true);

We can also make it not symmetrical:
a=2; b=3; Plot3D[x^2 /a^2 + y^2 /b^2, {x, -3, 3}, {y, -4, 4}]

ContourPlot3D[z == x^2 + y^2, {x, -3, 3}, {y, -3, 3}, {z, 0, 5}]

ContourPlot3D[x^2 + y^2 == z, {x, -1, 1}, {y, -1, 1}, {z, 0, 1}, Contours -> {4, Dashed}]

Plot3D[x^2 + y^2, {x, -1.5, 1.5}, {y, -1.5, 1.5}, PlotRange -> All, BoxRatios -> Automatic, ColorFunction -> Hue]

ContourPlot3D[ z == ((x^2)/(1^2)) + ((y^2)/(1^2)), {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, AxesOrigin -> {0, 0, 0}, PlotRange -> {-1, 1}, AxesLabel -> {x, y, z}]

ContourPlot3D[ x^2 + y^2 - z == 0, {x, -1., 1.}, {y, -1., 1.}, {z, -1., 1.}, Axes -> True, BoxRatios -> {1., 1., 1.}, ViewPoint -> {-2.43972, -1.63989, 0.598757}, PlotRange -> All, AxesLabel -> {"x", "y", "z"}, ContourStyle -> Directive[RGBColor[1, 0.8, 0.3], Specularity[RGBColor[0.2, 0.2, 0.7], 20]], Lighting -> "Neutral", ColorFunction -> None, BoxStyle -> GrayLevel[0, 0.35]]

ContourPlot3D[x^2 + y^2 == z, {x, -1, 1}, {y, -1, 1}, {z, 0, 1}, Mesh -> None, Lighting -> "Neutral", TextureCoordinateFunction -> ({#1, #3} &), ContourStyle -> Texture[ExampleData[{"ColorTexture", "WavesPattern"}]]]

or using polar coordinates
ParametricPlot3D[{s Cos[t], 2 s Sin[t], s^2}, {s, 0, 2}, {t, 0, 2 Pi}, PlotStyle -> Thick]

Now we create a new graph by shifting the previous one up by 3 units: \( g (x, y) = x^2 + y^2 + 3 \)
Plot3D[(x^2 + y^2 + 3), {x, -3, 3}, {y, -3, 3}, Axes -> True]
Another graph of \( h(x, y) = 5 - x^2 - y^2 \)
Plot3D[(5 - x^2 - y^2), {x, -3, 3}, {y, -3, 3}, Axes -> True, PlotStyle -> Orange]
One more: \( k (x, y) = x^2 + (y - 1)^2 \)
Plot3D[(x^2 + (y - 1)^2), {x, -3, 3}, {y, -3, 3}, PlotStyle -> None]
Example 2. Plotting the graph of the function \( G(x,y)=e^{-(x^2+y^2)} \)
Plot3D[(E^-(x^2 + y^2)), {x, -5, 5}, {y, -5, 5}, PlotStyle -> Opacity[.8]]
Cross Sections and the Graph of a Function where x=2
Plot3D[{(x^2 + y^2), (4 + y^2)}, {x, -3, 3}, {y, -3, 3}]
Example 2. Now we consider the hyperbolic parabaloid
figure;
x = [-10:.5:10];
y=[-10:.5:10];
[X, Y] = meshgrid(x,y);
Z = X.^2-Y.^2;
surf(X,Y,Z)
title('12.73 Hyperbolic Paraboloid')
xlabel y
ylabel x
zlabel z
Plot3D[-x^2 + y^2, {x, -1.5, 1.5}, {y, -1.5, 1.5}, PlotRange -> All, BoxRatios -> Automatic , ColorFunction -> Hue]
or
ContourPlot3D[-x^2/10 + y^2/10 == z, {x, -10, 10}, {y, -10, 10}, {z, -10, 10}, ColorFunction -> Function[{x, y, z}, Hue[z]]]
ContourPlot3D[-x^2 + y^2 - z == 0, {x, -4., 4.}, {y, -4., 4.}, {z, -4., 4.}, Axes -> True, BoxRatios -> {1., 1., 1.}, ViewPoint -> {-2.35989, -1.80482, -0.416584}, PlotRange -> All, AxesLabel -> {"x", "y", "z"}, ContourStyle -> Directive[RGBColor[0.5, 0.8, 0.3], Specularity[RGBColor[0.2, 0.2, 0.7], 20]], Lighting -> "Neutral", ColorFunction -> None, BoxStyle -> GrayLevel[0.7, 0.5]]
ParametricPlot3D[{s, t, s^2 - t^2}, {s, -1, 1}, {t, -1, 1}, PlotStyle -> Magenta]
ContourPlot3D[-x^2 + y^2 == z, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Mesh -> 5, MeshFunctions -> {#1 &, #2 &}, MeshStyle -> {Dashed, Blue}]

Example 5. Graph the equation \( x^2 + y^2 =1 \) in 3-space.

figure
[x,y,z] = cylinder(10);
z(2, :) = 10;
surf(x,y,z, 'FaceColor', [1,0,0]);
title('12.79 Cylindrical Surface')
ContourPlot3D[(x^2 + y^2)^.5 == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, MeshShading -> {White, Black, Blue}, MeshFunctions -> {#3 &}]
ContourPlot3D[x^2 + y^2 == 6, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, ColorFunction -> Function[{x, y, z}, Hue[z]]]
ContourPlot3D[(x^2 + y^2)^.5 == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, MeshShading -> Table[RGBColor[r, g, b], {r, 0, 1, 1/5}, {g, 0, 1, 1/5}, {b, 0, 1, 1/5}], Mesh -> 5, Lighting -> "Neutral"]

Example 6 . Consider the equation of parabolic cylinder \( y= x^2 \) in 3-space when one variable is missing.

figure;
x = [-10:.5:10];
y=[5:.5:10];
[X, Y] = meshgrid(x,y);
Z = X.^2+Y.^2
surf(X,Y,Z)
xlabel x
ylabel y
zlabel z
title('12.80 Parabolic Cylinder')
ContourPlot3D[y == x^2, {x, -3, 3}, {y, 0, 3}, {z, -3, 3}, MeshShading -> {Blue, Orange}, MeshFunctions -> {#3 &}]
ContourPlot3D[y == .5*x^2, {x, -3, 3}, {y, 0, 3}, {z, -2, 2}, ColorFunction -> Hue]
Plot3D[y = 3 x^2, {x, -5, 5}, {y, -5, 5}, AspectRatio -> 1]
ContourPlot3D[y == x^2, {x, -3, 3}, {y, 0, 3}, {z, -3, 3}, MeshFunctions -> {#1 &}, MeshStyle -> Dashed, Mesh -> 5] Show[%, Background -> RGBColor[0.84, 0.92, 1.]]

 

Section 12.3. Contour Diagrams

Example 1.

Example 2.

Example 3.

Example 4. Draw a contour diagram for \( f(x,y) = \sqrt{x^2 + y^2} \) and relate it to the graph of f.

First, we plot cones:

figure
[X,Y,Z] = meshgrid(-10:0.5:10,-10:0.5:10,-10:0.5:10);
a=1;
b=1;
c=1;
V = X.^2/a^2 + Y.^2/b^2 - Z.^2/c^2;
p=patch(isosurface(X,Y,Z,V,0)); 
set(p,'FaceColor','GREEN','EdgeColor','none');
daspect([1 1 1])
view(3);
camlight
title('12.77 Cone')
a = 1.5; b = 1.5; c = 1;
ContourPlot3D[ x^2/a^2 + y^2/b^2 - z^2/c^2 == 0, {x, -3, 3}, {y, -3, 3}, {z, -2, 2}, ColorFunction -> Hue]
ContourPlot3D[ x^2 + y^2 - z^2 == 0, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, ContourStyle -> LightGray]
ContourPlot3D[ x^2 + y^2 - z^2 == 0, {x, -4., 4.}, {y, -4., 4.}, {z, -4., 4.}, Axes -> True, BoxRatios -> {1., 1., 1.}, ViewPoint -> {-1.5, -2.5, -0.5}, PlotRange -> All, AxesLabel -> {"x", "y", "z"}, ContourStyle -> Directive[RGBColor[1, 0.8, 0.3], Specularity[RGBColor[0.2, 0.4, 0.9], 20]], Lighting -> "Neutral", ColorFunction -> None, BoxStyle -> GrayLevel[0.4, 0.35]]
ContourPlot3D[ x^2 + y^2 - z^2 == -0, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, Mesh -> 4, MeshFunctions -> {#1 &, #2 &, #3 &}]
ContourPlot3D[ x^2 + y^2 - z^2 == -0, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, MeshShading -> {Blue, Orange}, MeshFunctions -> {#3 &}]
Plot3D[-Sqrt[x^2 + y^2], {x, -5, 5}, {y, -5, 5}, BoxRatios -> {1, 1, 1}]

Example 5.

Example 6.

Example 7.

Example 8.

 

Section 12.4. Linear Functions

We start with plotting linear functions.
figure
pointA = [0,0,0];
pointB = [-10,-20,10];
pointC = [10,20,10];
plane1 = cross(pointA-pointB, pointA-pointC);
points=[pointA' pointB' pointC']; 
fill3(points(1,:),points(2,:),points(3,:),'r')
grid on
alpha(0.4)
title('12.78 PLANE') 
ContourPlot3D[x + y + z == 0, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, ContourStyle -> Green]
ContourPlot3D[x + y + z == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]
a = .5; b = .5; c = .5; d = 2;
ContourPlot3D[ a*x + b*y + c*z == d, {x, -3, 3}, {y, -3, 3}, {z, -2, 2}, ColorFunction -> Hue]
ContourPlot3D[x + y + z == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, MeshShading -> {Red, Blue, White}, MeshFunctions -> {Norm[{#1, #2}] & }]
a = .5; b = .5; c = .5; d = 2; ContourPlot3D[ a*x + b*y + c*z == d, {x, -3, 3}, {y, -3, 3}, {z, -2, 2}, ColorFunction -> Hue]
a = .5; b = .5; c = .5; d = 2; ContourPlot3D[ a*x + b*y + c*z == d, {x, -3, 3}, {y, -3, 3}, {z, -2, 2}, ContourStyle -> Blue]
Now we plot three planes:
ContourPlot3D[x + y + z, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}]

 

Section 12.5. Functions of three Variables

Example 1. A particular case of ellipsoid is a ball:
ContourPlot3D[ 1 == x^2 + y^2 + z^2, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]
or
clc
clear
figure
fi0=0;
fi1=360;
R=1;
R0=0;
R1=1;
M=30;
dfi=(fi1-fi0)/M;
dR=(R1-R0)/M;
fi=[fi0:dfi:fi1];
aa=pi/180;
theta0=0;
theta1=360;
dtheta=(theta1-theta0)/M;
theta=[theta0:dtheta:theta1];
t=0;
tt=-1;
for j=1:M/2+1
    tt=tt+1;
    t=tt;
for i=1:M+1
    t=t+1;
    b(t)=t;
    x(i)=R*sin(aa*fi(i))*cos(aa*theta(j));
    y(i)=R*sin(aa*fi(i))*sin(aa*theta(j));
    z(i)=R*cos(aa*fi(i));
    %pause
    v(1:6,b(t))=[ x(i) y(i) z(i) fi(i) theta(j) b(t)];
end
plot3(x,y,z)
axis equal
grid on
hold on

end
title('BONUS 12.69')
t=0;
tt=-1;
for j=1:M/2+1
    tt=tt+1;
    t=tt;
end
for i=1:M+1
    t=t+1;
    bb(t)=t;
    xx(i)=R*sin(aa*fi(j))*cos(aa*theta(i));
    yy(i)=R*sin(aa*fi(j))*sin(aa*theta(i));
    zz(i)=R*cos(aa*fi(j));
    %pause
    ang=45;
    RR = rotx(ang);
    vv = [xx(i);yy(i);zz(i)];
    %pause
    yyy = RR*vv;
    vvv(1:6,bb(t))=[ yyy(1) yyy(2) yyy(3) fi(j) theta(i) bb(t)];
    plot3(xx,yy,zz)
    plot3(vvv(1,bb(t)),vvv(2,bb(t)),vvv(3,bb(t)),'r*')
    axis equal
    grid on
    hold on
    
end
ContourPlot3D[ x^2 + y^2 + z^2 == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Contours -> 3, MeshFunctions -> {#1 &}]
a = 3; b = 3; c = 3;
ContourPlot3D[ x^2/a^2 + y^2/b^2 + z^2/c^2 == 1, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, ContourStyle -> Green]
[x, y, z] = ellipsoid(0,0,0,5.9,3.25,3.25,30);
figure;
surf(x, y, z);
axis equal;
title('12.74 ELLIPSOID')
xlabel x
ylabel y
zlabel z
ContourPlot3D[-1 + x^2 + y^2 + z^2 == 0, {x, -4., 4.}, {y, -4., 4.}, {z, -4., 4.}, Axes -> True, BoxRatios -> {1., 1., 1.}, ViewPoint -> {-1.64646, -2.30505, -0.987878}, PlotRange -> All, AxesLabel -> {"x", "y", "z"}, ContourStyle -> Directive[RGBColor[1, 0.8, 0.3], Specularity[RGBColor[0.2, 0.2, 0.7], 20]], Lighting -> "Neutral", ColorFunction -> None, BoxStyle -> GrayLevel[0, 0.35]]
ContourPlot3D[ x^2 + y^2 + z^2 == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Mesh -> None]
ParametricPlot3D[{Cos[t] Cos[s], 2 Sin[t] Cos[s], 3 Sin[s]}, {s, 0, 2 Pi}, {t, 0, 2 Pi}, PlotStyle -> Opacity[0.2]]

Example 2.

Example 3. Hyperboloid of one sheet

figure
[X,Y,Z] = meshgrid(-10:0.5:10,-10:0.5:10,-10:0.5:10);
a=1;
b=1;
c=1;
V = X.^2/a^2 + Y.^2/b^2 - Z.^2/c^2;
p=patch(isosurface(X,Y,Z,V,10)); 
set(p,'FaceColor','blue','EdgeColor','none');
daspect([1 1 1])
view(3);
camlight
title('12.75 Hyperboloid of one sheet')
ContourPlot3D[ x^2 + y^2 - z^2 == 1, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, MeshShading -> {LightBlue, Orange}, MeshFunctions -> {#2 &}]
a = 1.5; b = 2.0; c = 2.5;
ContourPlot3D[ x^2/a^2 + y^2/b^2 - z^2/c^2 == 1, {x, -3, 3}, {y, -3, 3}, {z, -2, 2}, ColorFunction -> Hue]
ContourPlot3D[ x^2 + y^2 - z^2 == 1, {x, -2, 2}, {y, -2, 2}, {z, -1, 1}, ContourStyle -> Purple]
ContourPlot3D[-1 + x^2 + y^2 - z^2 == 0, {x, -4., 4.}, {y, -4., 4.}, {z, -4., 4.}, Axes -> True, BoxRatios -> {1., 1., 1.}, ViewPoint -> {-1.64195, -2.50908, -0.092319}, PlotRange -> All, AxesLabel -> {"x", "y", "z"}, ContourStyle -> Directive[RGBColor[0.9, 0.8, 0.3], Specularity[RGBColor[0.2, 0.2, 0.7], 20]], Lighting -> "Neutral", ColorFunction -> None, BoxStyle -> GrayLevel[0.5, 0.7]]
ParametricPlot3D[{Cos[t] Cosh[s], Sin[t] Cosh[s], Sinh[s]}, {t, 0, 2 Pi}, {s, -1, 1}, PlotStyle -> Directive[Purple, Opacity[0.3]]]
ContourPlot3D[ x^2 + y^2 - z^2 == 1, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, MeshShading -> {Green, Red}, MeshFunctions -> {#3 &}]

Example 4.

Example 5.

Example. Now we plot a hyperboloid of two sheets:

figure
[X,Y,Z] = meshgrid(-10:0.5:10,-10:0.5:10,-10:0.5:10);
a=1;
b=1;
c=1;
V = X.^2/a^2 + Y.^2/b^2 - Z.^2/c^2;
p=patch(isosurface(X,Y,Z,V,-5)); 
set(p,'FaceColor','RED','EdgeColor','none');
daspect([1 1 1])
view(3);
camlight
title('12.76 Hyperboloid of two sheets')
/code>
a = 1.5; b = 1.5; c = 1;
ContourPlot3D[ x^2/a^2 + y^2/b^2 - z^2/c^2 == -1, {x, -3, 3}, {y, -3, 3}, {z, -2, 2}, ColorFunction -> Hue]
ContourPlot3D[ x^2 + y^2 - z^2 == -1, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, ContourStyle -> LightBlue]
ContourPlot3D[(4 + x^2 + y^2 - 4*z^2)/4 == 0, {x, -3., 3.}, {y, -3., 3.}, {z, -5., 5.}, Axes -> True, BoxRatios -> {2., 2., 1.}, ViewPoint -> {-2.5, -3.5, -0.5}, PlotRange -> All, AxesLabel -> {"x", "y", "z"}, ContourStyle -> Directive[RGBColor[0.5, 0.8, 0.3], Specularity[RGBColor[0.2, 0.2, 0.7], 20]], Lighting -> "Neutral", ColorFunction -> None, BoxStyle -> GrayLevel[0.5, 0.3], AspectRatio -> 1]
We can also plot half of such hyperboloid:
ParametricPlot3D[{Cos[t] Sinh[s], Sin[t] Sinh[s], Cosh[s]}, {t, 0, 2 Pi}, {s, -1, 1}, PlotRange -> 2, Mesh -> None]
ContourPlot3D[ x^2 + y^2 - z^2 == -1, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, MeshShading -> {Blue, LightBlue}, MeshFunctions -> {#2 &}]

Example.