Laboratory 4 
Limits and Continuity of Multivariable Functions

Introduction

In this lab, we shall develop some techniques to help us visualize functions of two and three variables. In particular, we shall examine the relationship between such functions and their corresponding contour graphs. This will help us to understand the notion of a limit of a function of more than one variable, as well as to understand what it means for a function of more than one variable to be continuous.

4.1 Limits and Continuity

The limit of a function of two variables is defined in the same fashion as the limit of a function of one variable. Indeed, we say that	

	(Underscript[(lim_
), (x,y)->(a,b)]) f(x,y)=L 
provided that for each ϵ>0, there exists a δ>0 such that if 0<(Sqrt[(((x-a))^2)+(((y-b))^2)])<δ, then |f(x,y)-L|<ϵ. Similarly, we say that 

	(Underscript[(lim_
), (x,y,z)->(a,b,c)]) f(x,y,z)=L, 
provided that for each ϵ>0, there exists a δ>0 such that if 0<(Sqrt[(((x-a))^2)+(((y-b))^2)+(((z-c))^2)])<δ, then |f(x,y,z)-L|<ϵ. 

Intuitively, this definition says that (lim_((x,y)->(a,b)))f(x,y)=L if we can make the function values f(x,y) close to the number L for all points (x,y) that are sufficiently near the point (a,b). This suggests that we could approximate that value of the limit of a function of two variables at a given point by drawing the graph of the function in smaller and smaller regions containing that point. Indeed, suppose that we wanted to estimate the value of
	(Underscript[(lim_
), (x,y)->(0,0)])(((x^2) y+x (y^2))/((x^2)+(y^2))).
Let us plot the function f(x,y)=(((x^2)y+x (y^2))/((x^2)+(y^2))) on small regions containing the origin, and examine the resulting graphs. The command below plots the graph of f on rectangles [-h,h]×[-k,k], where the values of h and k can be controlled independently between (10^(-8)) and 1.

Clear[f]
f[x_,y_]:=(x^2*y+x*y^2)/(x^2+y^2)
Manipulate[
Plot3D[f[x,y],{x,-h,h},{y,-k,k}],
{h,1,10^(-8)},{k,1,10^(-8)}]

Some experimentation with the values of h and k should reveal that as we shrink the rectangle [-h,h]×[-k,k], the visible part of the graph changes little in shape, yet the z-coordinates of the points get closer and closer to 0. Based on this evidence, we conclude that the above limit is probably zero.

We say that the function f(x,y) is continuous at the point (a,b) if 
	(Underscript[(lim_
), (x,y)->(a,b)]) f(x,y)=f(a,b), 
meaning that the limit of the function as it approaches the point (a,b) is the same as the value of the function at that point. Despite the appearance of the graph however, the function f(x,y) above is not continuous at the point (0,0), because the function is not defined there. On the other hand, we can consider the following function
	g(x,y)=(Piecewise[{{(((x^2) y+x (y^2))/((x^2)+(y^2))),  if (x,y)≠(0,0),}, {0, if (x,y)=(0,0).}}])
Then, thanks to the limit we calculated above, we conclude that the function g(x,y) is continuous at (0,0).

Note regarding Plot3D and other 3D plotting commands

The output of 3D plotting commands like Plot3D, ContourPlot3D, etc. contains huge amounts of data and calculations. That is not a problem when the output is printed directly to a printer but can cause a great deal of aggravation when one wants to use Mathematica-generated plots in other software—e.g., if one wants to save the content of a Mathematica notebook as a PDF file to be printed later using Acrobat Reader. For example, when the output of the above Manipulate[Plot3D[]] combination is saved, the resulting PDF file has size of 5.65 MB and is virtually impossible to print. To avoid such problems, one can use the command Rasterize to simplify the output of 3D plotting commands. Its basic syntax takes the forms

	Rasterize[Plot3D[...]]
	Rasterize[ParametricPlot3D[...]]
	Rasterize[ContourPlot3D[...]]

etcetera. Note that the proper way to use this command is immediately around the plotting command. For example, to rasterize the output of the above Manipulate[Plot3D[]] combination, one should use Rasterize as follows

Manipulate[
Rasterize[Plot3D[f[x,y],{x,-h,h},{y,-k,k}]],
{h,1,10^(-8)},{k,1,10^(-8)}]

This code produces a dynamic plot that appears nearly identical to the one we saw earlier. Unlike the earlier plot, this plot cannot be rotated or scaled with the mouse—the only way to change it by moving the sliders in the output of Manipulate. However, when saved, this plot generates a PDF file that measures only 540 KB—less than 10% the size of the earlier one!

4.2 Surfaces and Contour Plots, I

A contour plot of a surface z=f(x,y) is a collection of the two-dimensional level curves f(x,y)=c for various values of c. For example, a contour plot of the paraboloid z=(x^2)+(y^2) would consist of a sequence of circles in the plane with center at the origin; this is because the two-dimensional curves (x^2)+(y^2)=c, with c>0, are all circles. 

Although in this case we were able to find the contour graphs algebraically, in general this is a difficult process. The following module, called basicContourPlot can be used to obtain the contour plot of a function together with its corresponding three dimensional graph. As input, it takes the name of a function, then the x, y, and z ranges that will be used for the graphs.

basicContourPlot[f_,{x,x0_,x1_},{y,y0_,y1_},{z,z0_,z1_}]:=Module[{a,b,c,dz},dz=(z1-z0)/20;
a=Plot3D[f[x,y],{x,x0,x1},{y,y0,y1},
PlotRange->{z0,z1},MeshFunctions->{#3&},AxesLabel->{"x","y","z"}];
Do[c[i]=ContourPlot[f[x,y]==z0+i dz,{x,x0,x1},{y,y0,y1},
ColorFunction->Function[{x,y},RGBColor[i/20,0,1-i/20]],Frame->True];,{i,0,20}];
b=Show[Table[c[j],{j,0,20}],PlotRange->{{x0,x1},{y0,y1}}];
Rasterize[Show[GraphicsRow[{a,b}],ImageSize->550]]]

Let us examine the paraboloid f(x,y)=(x^2)-(y^2).

Clear[f]
f[x_,y_]:=x^2-y^2
basicContourPlot[f,{x,-4,4},{y,-4,4},{z,-16,16}]

On the left we see the three-dimensional graph of the surface, while on the right, we see the corresponding contour graph. The colors of the contours in the contour graph correspond to the height of the surface; red contours are for values of z near the maximum height shown in the three dimensional graph, while blue contours are for values of z near the minimum values. (You may think of this as a termal map: red indicates hot areas, blue indicates cold areas.) Notice also that when you hover over a contour with the mouse, Mathematica informs you what is the exact equation of that contour.

4.3 Contour Plots and Limits of Multivariable Functions, I

We saw in Section 3.1 how zooming can be used to study limits of functions of two variables. In this example, we consider an alternative method that makes use of level plots. Consider the function 
		f(x,y)=((x +1)/((x^2)+(y^2)+1)), 
and suppose that we want to investigate (lim_((x,y)->(0,0)))f(x,y). Let us look at the graph and level curves of f(x,y) at points near the origin.

Clear[f]
f[x_,y_]:=(x+1)/(x^2+y^2+1)
basicContourPlot[f,{x,-1,1},{y,-1,1},{z,0,1.25}]

From the three-dimensional graph, we can see that the function appears to be continuous near the origin, so we expect that 
	(Underscript[(lim_
), (x,y)->(0,0)]) f(x,y)=f(0,0)=1.
On the other hand, looking at the contour plot, we see that only a single level curve passes through (or very near) the origin; all the other level curves stay away from the origin. (By positioning the cursor on the curves near the center of the square we find that it is most likely the 1-level curve that passes through the origin.) Thus, that all the values of f(x,y) at points near the origin are close to the value of f on that special level curve. That is, f seems to have a limit as (x,y)->(0,0) and that limit has value equal to the level of the curve (i.e., 1).

Now, let us look at the limit (Underscript[(lim_
), (x,y)->(0,0)]) (xy/((x^2)+(y^2))).

Clear[f,x,y] 
f[x_,y_]:=(x*y)/(x^2+y^2)
basicContourPlot[f,{x,-1,1},{y,-1,1},{z,-.5,.5}]

From the graph z=f(x,y), we see that the function does not appear to have a limit at the origin, and the contour plot confirms that. Indeed, we notice that all of the contours seem to intersect at the origin. Suppose that we approach the origin along two distinct level curves (say, along f(x,y)=-0.5 and f(x,y)=0.5), then the values of f(x,y) along those curves will approach different limits (-0.5 and 0.5, respectively). However, if f had a limit at the origin, say L, the values f(x,y) would have to approach L independent of the path we approach (0,0) along.

4.4 Surfaces and Contour Plots, II

In the lectures, we defined also the level surfaces f(x,y, z)=c of a function of three variables. For example, the level surfaces of the function w=(x^2)+(y^2)+(z^2) would be spheres with center at the origin; this is because the equation (x^2)+(y^2)+(z^2)=c, where c>0, represents a sphere. 

We want to use plots of level surfaces to study limits of functions of three variables similarly to how we used level curves above. For that, we want to look at several level surfaces of the same function simultaneously. The following module, called basicContourPlot3D can be used to view the level surfaces of the function f(x,y,z) of levels in a specified range. As input, it takes the name of a function, the x-, y- and z-ranges of the window that will be used for the graphs, and a w-range for the levels. If the ranges are (Subscript[x, 0])≤x≤(Subscript[x, 1]),(Subscript[y, 0])≤y≤(Subscript[y, 1]),(Subscript[z, 0])≤z≤(Subscript[z, 1]),a≤w≤b, then the module will plot the part of the m-level surface of f that lies within the box (Subscript[x, 0])≤x≤(Subscript[x, 1]),(Subscript[y, 0])≤y≤(Subscript[y, 1]),(Subscript[z, 0])≤z≤(Subscript[z, 1]), where m=(a+b)/2 is the midpoint of the w-range. The user can then use the slider to change the level of the surface from m to any other level in the range a≤w≤b.

basicContourPlot3D[f_,g_:1,{x,x0_,x1_},{y,y0_,y1_},{z,z0_,z1_},{w,w0_,w1_},pt_:0]:=
Module[{c,u,v,p,p1,p2},
u[x_,y_,z_]=f[x,y,z];
v[x_,y_,z_]=If[g==1,1,{},g[x,y,z]];
p=If[pt==0,{x0-1,y0-1,z0-1},pt];
p2=Graphics3D[{PointSize[0.02],Point[p]}];
Manipulate[
p1=ContourPlot3D[u[x,y,z]==c*v[x,y,z],{x,x0,x1},{y,y0,y1},{z,z0,z1},
Axes->True,Mesh->None,BoxRatios->Automatic,ContourStyle->Opacity[0.9],PlotLabel->u[x,y,z]/v[x,y,z]==c,
PlotRange->{{x0,x1},{y0,y1},{z0,z1}}];
Rasterize[Show[p1,p2]],
{{c,(w0+w1)/2,"level"},w0,w1}]
]

Let us examine the function f(x,y,z)=(x^2)+(y^2)+(z^2).

Clear[f]
  f[x_,y_,z_]:=x^2+y^2+z^2
  basicContourPlot3D[f,{x,0,1},{y,-1,1},{z,-1,1},{w,0,1}]

After some experimentation, we see that all the level surfaces of w=(x^2)+(y^2)+(z^2) that lie in the box 0≤x≤1,-1≤y≤1,-1≤z≤1 are hemispheres, the only exception being the 0-level surface. That surface degenerates into a point, and hence, becomes invisible. 

Unfortunately, level surfaces are quite tricky to plot and often we need to give Mathematica a helping hand in order to see the proper level surfaces. Denominators are one common source of such problems. For example, let us take a look at the level surfaces of f(x,y,z)=((x+z)/((x^2)+(y^2)+(z^2)-1)). We take a look at the level surfaces of levels 0≤w≤10 inside the box 0≤x≤2,-1≤y≤2,0≤z≤2.

Clear[f] 
f[x_,y_,z_]:=(x+z)/(x^2+y^2+z^2-1)
basicContourPlot3D[f,{x,0,2},{y,0,2},{z,0,2},{w,0,10}]

It appears that the level surfaces consist of two pieces of spheres, one that changes and one—and this is the bizarre part—that stays fixed.  However, this is impossible—two level surfaces of different levels cannot have common points! For example, if the point (1,0,0) lied both on the 1-level surface and the 2-level surface, that would mean that at the same time f(1,0,0)=1 and f(1,0,0)=2. The explanation is that the “static” piece of the level surfaces is an undesired side effect of our finction having a denominator. To get rid of it, we must tell Mathematica to plot the level surfaces

	x+z=c((x^2)+(y^2)+(z^2)-1)

instead of f(x,y,z)=c. For that purpose,  basicContourPlot3D accepts an optional second function as an input. When such an optional input is supplied, the syntax takes the form

	basicContourPlot3D[f,g,{x,...]

and instead the level surfaces f(x,y,z)=c, the command will display the surfaces f(x,y,z)=c g(x,y,z). For example, to see the level surfaces ((x+z)/((x^2)+(y^2)+(z^2)-1))=c, we can use this optional argument as follows. (Notice that the raggedy “static” surface is gone.)

Clear[f,g] 
f[x_,y_,z_]:=x+z
g[x_,y_,z_]:=x^2+y^2+z^2-1
basicContourPlot3D[f,g,{x,0,2},{y,0,2},{z,0,2},{w,0,10}]

4.5 Contour Plots and Limits of Multivariable Functions, II

We saw in Section 3.1 how zooming can be used to study limits of functions of two variables. Then, we saw in Section 3.3 that contour plots can be used for the same purpose. In dealings with limits of functions of three variables, the first method is useless, because the graph  w=f(x,y,z) is four-dimensional and thus impossible to plot. On the other hand, the method of Section 3.3 can be adapted to functions of three variables. 

Let us consider the function 
		f(x,y,z)=((x +1)/((x^2)+(y^2)+(z^2)+1)) 
near the origin. To take a look at the level surfaces of f(x,y,z) at points near the origin, we select a three-dimensional box that contains the origin near one of its corners—namely, -0.1≤x,y,z≤0.5. The module basicContourPlot3D has an additional optional argument, which if given must be the coordinate vector of a point in space: e.g., {0,0,0} for the origin. When that optional argument is present, the corresponding point in space is shown also on the plot. Thus, the following command will allow us to examine the level surfaces of levels between 0.5 and 1.5 in relation to the origin.

Clear[f]
f[x_,y_,z_]:=(x+1)/(x^2+y^2+z^2+1)
basicContourPlot3D[f,{x,-0.1,1.5},{y,-0.1,1.5},{z,-0.1,1.5},{w,-.5,1.5},{0,0,0}]

We see the pieces of the level surfaces of f(x,y,z) within the selected box. Among them only the 1-level surface passes through the origin (the big black point near the lower left corner of the box frame). The remaining level surfaces avoid the origin and, unless their levels are very close to 1, the level surfaces stay away from the origin. This suggests that perhaps f(x,y,z)->1 as (x,y,z)->(0,0,0) (which, of course, follows from the continuity of f(x,y,z) at the origin).

Now, let us look at the limit of f(x,y,z)=((x+z)/((x^2)+(y^2)+(z^2)-4)) at the point (0,2,0). To avoid side effects caused by the denomiantor, we use the two-function version of basicContourPlot3D. We start by looking at the level surfaces of levels 0≤w≤10

Clear[f,g] 
f[x_,y_,z_]:=x+z
g[x_,y_,z_]:=x^2+y^2+z^2-4
basicContourPlot3D[f,g,{x,-0.1,1.5},{y,1.9,3.5},{z,-0.1,1.5},{w,-1,2},{0,2,0}]

We notice that all level surfaces see to pass through the point (0,2,0) (or very near it). Thus, the function does not appear to have a limit at that point.

Exercises

Exercise 1

For each of the following functions, use graphical methods to estimate the value of (lim_((x,y)->(a,b)))f(x,y), if possible. If f(a,b) is undefined, is it possible to assign a value to f(a,b) to make f continuous at (a,b)?	
(a) f(x,y)=((x+y-4(x^2)(y^2))/((x^2)+(y^2)-5)); a=1,b=1		(b) f(x,y)=((x+y-4(x^2)(y^2))/((x^2)+(y^2)-5)); a=2,b=1
(c) f(x,y)=((x y)/(Sqrt[(x^2)+(y^2)])); a=0,b=0			(d) f(x,y)=arctan (y/x); a=0,b=0
(e) f(x,y)=(((cos(xy)))^(sec(x/y))); a=π,b=2		(f) f(x,y)=(((1+xy))^(1/xy)); a=0, b=0

Exercise 2

For each of the following functions plot three dimensional graphs and contour graphs (use basicContourPlot to generate them) to determine if the limit (lim_((x,y)->(0,0)))f(x,y) exists. 
(a) f(x,y)=((x y)/(Sqrt[(x^2)+(y^2)]))		(b) f(x,y)=(((y -x))/(Sqrt[(x^2)+(y^2)]))
(c) f(x,y)=((((x -y))^3)/((x^2)+(y^4)))			(d) f(x,y)=((x (y^3))/((x^4)+(y^4)))
(e) f(x,y)=(((x^3)+(y^3))/((x^2)+(y^2)))			(f)  f(x,y)=(((x^2)y)/((x^4)+(y^2)))

Exercise 3

For each of the following functions use level surfaces (use basicContourPlot3D to generate them) to determine if the limit (lim_((x,y,z)->(0,0,0)))f(x,y,z) exists.
(a) f(x,y,z)=(xyz/((x^2)+(y^2)+(z^2)))		(b) f(x,y,z)=((z^2)/(x y+(z^3)))	(c) f(x,y,z)=arctan((1/((x^2)+ (y^2)+(z^2))))

Exercise 4

Use level surfaces to determine if (lim_((x,y,z)->(0,0,0)))((cos(2x+y))/(x y+(z^3))) exists. How would you describe the change in the behavior of the level surfaces f(x,y,z)=c as c gets large? What does that say about the limit of f(x,y,z) as (x,y,z)->(0,0,0)?

Credits

This lab is based on the laboratories created by Raouf Boules, Geoffrey Goodson, Ohoe Kim, Alexei Kolesnikov and Michael O'Leary for use in the Calculus courses of Towson University. Commercial use is prohibited without permission of those authors. Non-commercial use is permitted, provided this credit section is retained.