Lab 3A - Continuity and Differentiability
Math 2374 - University of Minnesota
http://www.math.umn.edu/math2374
 questions to rogness@math.umn.edu, drake@math.umn.edu

Introduction

This week we will investigate the ideas of continuity and differentiability for functions of several variables. The relationships between limits, continuity, partial derivatives, and differentiability are quite subtle and complicated and you might find that your intuition will often lead you astray. Most of the functions with which we'll concern ourselves in this course are very ``nice'', but it's important that you are aware of the sorts of pathological functions which do exist.

Some of the functions and equations in this lab are complicated and difficult to read in a small font. If that bothers you, the magnification can be changed in the Format -> Magnification menu. Another way is Format -> Screen Style Environment -> Presentation, which changes the general look of your notebook and pretties things up a bit.

Also, many of the examples here will use ShowLive or Plot3DLive.  If you're viewing this on a computer where those commands don't work, you can remove the Live from each command and still read the lab, although it will be less interactive.  In the online version we've already done this, but we'd like to stress that you won't get as much out of the "static" version as the live one.

Continuity

From lecture and our textbooks, we know that the idea of continuity—for both single- and multi-variable functions—largely depends upon the idea of a limit. In both cases, a function f is continuous at a point a if

(lim_( x  ->  a)) f (x)

exists and

(lim_( x  ->  a)) f (x) = f (a).

Intuitively, this means that the function has no holes or jumps; in the single-variable case, we often talk about being able to draw a function without lifting your pencil from the paper.

Determining whether a function is continuous or not is therefore mostly a matter of determining the value of the limit (if it even exists, which it may not). For single-variable functions, we talk about right-hand and left-hand limits: one can approach a value on the real line from either the right or the left. But what about a function whose domain is two-dimensional? Not only can you approach from the left and right, but from many other directions as well. Say we have a function g(x) whose domain includes the point (2,2). We could approach the point (2,2) along any one of infinitely many straight lines:

(of course, due to the limitations of Mathematica, we can only draw finitely many arrows...). We can also approach the point (2,2) along other kinds of curves: below, we've drawn a parabola, a sine wave, and a portion of a circle, each of which approaches the point (2,2):

The problem is even worse with 3 or more dimensions! An important observation is that the limit of a function as x goes to a will exist if and only if the limits as you approach a along ANY path agree. As we just saw, there are infinitely many paths that approach a point, and we certainly can't test each one of them individually. This means that, in practice, we usually won't evaluate any "two-dimensional" limits.  We will, however, use the contrapositive of the above statement: if the limits as you approach a along two or more different paths disagree, then the limit as x goes to a does not exist.

Now carefully re-read the above paragraph once or twice. This is a tricky concept!

Example 1 - A continuous function

We mentioned above that in the single variable case, you can intuitively read "f is continuous" as "You can draw the graph of f without lifting your pencil from the paper."  Unfortunately, it's impossible to generalize this sort of statement to multivariable functions.  You're not drawing a line on a piece of paper -- you're trying to draw a surface in three-dimensional space!

In practice, that means we have to work with the slightly less intuitive idea that "a multivariable function f is continuous if its graph has no jumps or holes."   That's actually not a bad way to think about it; the trick is that it's not always easy to tell if a function has a hole (or a jump) or not!

Just for the record, here's a function which is continuous everywhere.  Rotate the picture around and notice that it seems very smooth, without any jumps.

f[x_, y_] = Exp[-(x^2 + y^2)]
Plot3DLive[f[x, y], {x, -1, 1}, {y, -1, 1}]

Example 2 - A function with a hole at (0,0) that can be fixed

In this course we're not going to deal with a lot of pathological functions.  If a function f(x, y) is not continuous for all points (x, y), then usually there will only be one bad point, and usually that bad point will be the origin.  Here's an example where we've only changed the function in the previous example a little bit.

f[x_, y_] = Exp[-1/(x^2 + y^2)]
Plot3DLive[f[x, y], {x, -1, 1}, {y, -1, 1}]

Notice that fhas a hole at (0,0), because it's not even defined there!

f[0, 0]

However, this is not at all evident from the picture, is it?  This is another example of how you need to be very careful when using technology; Mathematica will help you visualize things, but it won't always tell you the whole story.

Note that in this case, we could actually "plug" the hole.  Look at the picture again and notice that as (x,y) get close to (0,0), the z-values all go to zero.  In other words,

(lim_( (x, y)  ->  (0, 
                  0))) f (x, y) = 0,

although you should remember that graphical evidence isn't the same as actually calculating this limit! 

What this means is that we can make f(x, y)into a continuous function by simply defining f(0, 0)to be 0.  In other words,

f(x, y) = 
      (e^(-1/((x^2) + (y^2))))

is not a continuous function at (0,0), because it doesn't even exist there, but

f (x, y) = {({{(e^(-1/((x^2) + (y^2)))), if (x, y)≠(0, 0)
}, {     0,      if (x, y)=(0, 0)}})

is a continuous function at (0,0), because we've plugged the hole.  Again, this is a tricky concept, but we won't be asking you to do any of this.  Ask your TA if you've got questions, though.

Example 3 - A function which is not continuous at (0,0)

Here's an example of a function that's not continuous at (0,0), and there's nothing we can do about it:

f (x, y) = {({{(xy/((x^2) +  (y^2))), if (x, y)≠(0, 0)
}, {     0,      if (x, y)=(0, 0)}})

To work with this function in Mathematica, it's probably easiest just to use the following definition. If  Mathematica ever complains that f(0, 0)is undefined, you'll just have to remember on your own that f(0, 0) = 0.

f[x_, y_] = x*y/(x^2 + y^2)

Let's take a look at the graph of f.  The following commands will give you an interactive window with the picture, as well as a static image for later reference.

graph = 
        Plot3D[f[x, y], {x, -1, 1}, {y, -1, 1}, 
          AxesLabel -> {"X", "Y", "Z"}, 
          PlotPoints -> 40];
ShowLive[graph];

Notice that, even after using the PlotPoints option, the graph is still a little jagged in the middle.  This is usually an indication that something is wrong; the graph is jumping around so much that Mathematica can't keep up!

Rotate the picture around until you get a good feel for what the graph looks like.  Along a diagonal on the bottom, the height seems to be -(1/2), while on the opposite diagonal, on the top, the height seems to be +(1/2).  And that, in a nutshell, is why the function is discontinuous at the origin: if you walk along the ridge on the top, the value at (0,0) "should" be +(1/2), because otherwise there'd be a jump!  But if you walk along the valley in the bottom, the value at (0,0) "should" be -(1/2), because otherwise there'd be a jump  there too.  There's no way to satisfy both conditions, so the function has a jump discontinuity at (0,0), even though it's defined there.

What that last paragraph says is really that

(lim_( (x, y)  ->  (0, 
                    0))) f (x, y) ≠f (0, 0); in fact, the limit  does not exist!

How could we prove this?  We definitely don't want to have to compute a limit with two variables.  As we mentioned above, this is too hard.  Instead, we could try to make the difference between the "ridge" and the "valley" a little more mathematical.  Evaluate the following cell -- don't worry about understanding the commands -- and then continue reading.  You should get a LiveGraphics3D window with a wireframe drawing of the surface, along with two lines.

dx = dy = 1.1/10;
ShowLive[
      Graphics3D[
        Table[Line[{{i, j, f[i, j]}, {i + dx, j, f[i + dx, j]}, {i + dx, 
                j + dy, f[i + dx, j + dy]}, {i, j + dy, 
                f[i, j + dy]}}], {i, -1, 1, dx}, {j, -1, 1, dy}]], 
      Graphics3D[{{RGBColor[1, 0, 0], Thickness[0.03], 
            Line[{{-1, -1,  .5}, {1, 1,  .5}}]}, {RGBColor[0, 0, 1], 
            Thickness[0.03], 
            Line[{{-1, 1, - .5}, {1, -1, - .5}}]}}], 
      Axes -> True, AxesLabel -> {"X", "Y", "Z"}, 
      ViewPoint -> {1, -2, 1}]

The red line show you all of the points on the surface which are above the line y = x.  Look at the picture from above until you see this.  Notice that the z-values for these points are always 1/2, with the possible exception of the point above the origin.  We can prove this mathematically.  If we want to know what the function values are equal to when y = x, simply do that substitution :

f (x, x)=\(\(x \((x)\)\)\/\(x\^2 + \ \((x)\)\^2\) = \ \(x\^2\/\(x\^2 + \ x\^2\) = \ \(x\^2\/\(2  x\^2\) = \ 1\/2\)\)\)

Mathematica will do all of this for you.

f[x, x]

Similarly, the blue line shows you all of the points on the graph which have (x,y) values on the line y = -x.  Rotate the picture until you can see this.  The function values for these points [again, with the possible exception of (0,0)] is always -(1/2).

f[x, -x]

You've now shown mathematically -- instead of just pictorially -- that if you approach the origin along these two different lines, you end up with different heights.  Or, a little more mathematically, the limit as you approach the origin on the red line is +(1/2), which the limit as you approach on the blue line is -(1/2).  Since they don't agree, we've shown that

(lim_( (x, y)  ->  (0, 
              0))) f (x, y)   does not exist

without having to actually calculate limits.  Woohoo!

Incidentally, to show a function isn't continuous at the origin, you need to find two ways to approach (0,0) where you get different heights, but those approaches don't necessarily have to be along these lines -- or even on a line at all, as the next two exercises show.  With our particular function in this example, we could have used just about any two lines. 

 Remember that any non-vertical line through the origin has the form y = m x.  If you look at the points on the surface above these lines (or below, as the case may be), their height will be:

f[x, m*x]
Simplify[%]

In our example, we used the slopes m = 1 and m = -1.

Exercise 1

Show that the function

g (x, y) = {({{(( 2  (x^2) 
                                      y)/((x^4) +  (y^2))), if (x, y)≠(0, 0)
}, {     0,      if (x, y)=(0, 0)}})

is not continuous at the origin.  You should use Mathematica to look at pictures of this surface, but the actual calculations might be easier done by hand.  You can copy the following commands and evaluate them to see a picture, but remember that the picture "breaks down" a bit near the origin.

Clear[g, x, y];
g[x_, y_] = (2  x^2 *y)/(x^4 + y^2)
graph  =  
          Plot3D[g[x, y], {x, -1, 1}, {y, -1, 1}, 
            AxesLabel -> {"X", "Y", "Z"}, 
            PlotPoints -> 30];
ShowLive[graph]

Do the following steps:

(a) Show that the limits agree if you approach above/below any line y = m x.  (Do this by figuring out what g(x, m x)is and then letting x->0.)

(b) Calculate the limit as you approach the origin above the parabola y = (x^2).

(c) Calculate the limit as you approach the origin below the parabola y = -(x^2).

You should actually show your calculations here; don't just let Mathematica do them for you.  Now interpret your results!

Exercise 2

Repeat Exercise 1 for the following function.

g (x, y) = {({{\(\(x\^4\ y\^2\)\/\((x\^4 + y\^2)\)\^2\), if (x, y)≠(0, 0)
}, {     0,      if (x, y)=(0, 0)}})


You can use the following commands to see a picture of its graph.

Clear[g, x, y];
g[x_, y_] = (x^4 *y^2)/(x^4 + y^2)^2
graph  =  
          Plot3D[g[x, y], {x, -1, 1}, {y, -1, 1}, 
            AxesLabel -> {"X", "Y", "Z"}, 
            PlotPoints -> 50];
ShowLive[graph]

Differentiability

You've already been told in lecture that the derivative of a multivariable function \(f : ℝ\^n -> \ ℝ\^m\) is a matrix, sometimes called D f (for "Derivative matrix of f), and sometimes called J f (for "Jacobian of f").  Both Df and Jf mean the same thing: the matrix which contains all of the partial derivatives of the function:

(({{∂((Subscript[f, 1])/∂)(Subscript[x, 1]), \(∂f\_1\/∂x\_2\), ⋯, ∂((Subscript[f, 1])/∂)(Subscript[x, n])}, {∂((Subscript[f, 2])/∂)(Subscript[x, 1]), \(∂f\_2\/∂x\_12\), ⋯, ∂((Subscript[f, 2])/∂)(Subscript[x, n])}, {⋮, ⋮, ⋱, ⋮}, {∂((Subscript[f, m])/∂)(Subscript[x, 1]), \(∂f\_m\/∂x\_2\), ⋯, ∂((Subscript[f, m])/∂)(Subscript[x, n])}}))

Once we've found this matrix, we can evaluate it at a point x=a by plugging in numbers for x, y, or whatever other variables we have.  We write this as Df(a).  The technical definition of differentiability says that a function is differentiable at a point a if

(lim_(x -> a))((||f(x) - f(a) - D f(a) (x-a)||)/(||x-a||)) = 0

Yikes!  While this definition is correct, it's hard to work with, and it's not at all clear what it means.  Let's take a step backwards and figure out what it means for a function to be differentiable.

Think back to single variable calculus.  You know the limit definition of a derivative in the single variable case, but intuitively f(x) is differentiable at x = a if the graph has a tangent line there, and the derivative is that slope. Another way of thinking about this is that the graph of f(x) looks linear ("like a line") near x = a.  Evaluate the next cell to see the graph of y = (x^2)along with its tangent line for x = 1.  (You haven't seen this before, but you can give Plot more than one function at a time, as long as you surround them with curly brackets.)

Plot[{x^2, 2  x - 1}, {x, -1, 3}]

Now go back and change the range for x to 0.5 and 1.5.  Then .9 and 1.1, or even .999 and 1.001.  Notice how the more you "zoom in," the harder it gets to distinguish between the two graphs.  In other words, the graph of y = (x^2)looks linear when you zoom in far enough.  This is also why the tangent line is called the linear approximation of the graph at x = 1; it's the line which most closely approximates the graph there.

So, a single variable function f(x) is differentiable at x = a if it has a linear approximation there; f' (a)is the slope of that line.

Here's the quintessential function from single variable calculus which isn't differentiable at x = 0:

Plot[Abs[x], {x, -1, 1}]

The graph of y = |x| does not look like a line at x = 0.  In fact it has a very sharp corner there, and no matter how far you zoom in --- try a range of -0.00001 to 0.00001 for x! --- you can't make the graph straighten out and look linear.

The same idea works for multivariable functions.  If you zoom in far enough on a point on a graph, it should either look linear (which in higher dimensions could be replaced with "planar") or not.  If it's linear when you zoom in, then you can find a linear approximation there.  Make sense?  

So, to draw a direct analog to the single variable case, a multivariable function is differentiable at (Overscript[x, ⇀]) = (Overscript[a, ⇀])if it has a linear approximation -- i.e. a tangent plane -- there.

This can be very tricky to figure out!  Evaluate the following cells and decide if you think they look linear at the origin.  (Remember, you can zoom in/out with LiveGraphics3D by holding down the shift key, clicking on the picture, and dragging the mouse up and down.)

Note that the second function, ((x^3) - (y^3))/((x^2) + (y^2)), isn't defined at (0,0), but you can "plug the hole" by defining the function to be equal to zero there.  This makes it a continuous function, which you can assume without checking.

surf1 = 
        Plot3DLive[
          Exp[-(x^2 + y^2)] - 1, {x, -1, 1}, {y, -1, 1}, 
          AxesLabel -> {"X", "Y", "Z"}, 
          PlotPoints -> 40];

surf2 = 
        Plot3DLive[(x^3 - y^3)/(x^2 + y^2), {x, -1, 
            1}, {y, -1, 1}, 
          AxesLabel -> {"X", "Y", "Z"}, 
          PlotPoints -> 40];

It turns out that the first one is differentiable, and the second one isn't.  That's hard to see from the second picture, but notice that there are "ridges" and "valleys" leaving the origin along the coordinate axes; the particular way that some of them go up, while some go down, make it impossible to approximate the graph with a tangent plane.  The only real possibility is the plane

z = x - y

(You're asked to show this in the exercises.)  But look at the following picture of the graph and the plane together.  Rotate and zoom in/out as needed.  See if you can believe that the plane isn't actually tangent to the surface at (0,0).  Basically, the surface has a few "kinks" at (0,0) which prevent the plane from being tangent.

plane2 = 
      Plot3D[x - y, {x, -1, 1}, {y, -1, 1}, 
        PlotPoints -> 40]
ShowLive[surf2, plane2, BoxRatios -> {1, 1, 2}, 
        ViewPoint -> {-2, 1, 2}];

Just for comparison, here's the first surface, along with its tangent plane.

plane1 = 
      Plot3D[0, {x, -1, 1}, {y, -1, 1}, 
        PlotPoints -> 40]
ShowLive[surf1, plane1];

You can see that the linear approximation isn't very good once you move away from the origin, but the surface certainly doesn't have any kinks in it, or "jab through" the plane near the origin.

So, back to the $64,000 question: why does the big, ugly derivative matrix (or "Jacobian" matrix, which is the same thing) matter?  As you hopefully recall, you use it to find the linear approximation --- or "tangent plane" --- for your function.

If you'd like to understand the technical definition a bit more, expand the next subsection; otherwise go on to the summary of what differentiable functions are.

(Expand this Subsection to read an explanation of the technical definition)

Here again, for your reading pleasure, is the  technical definition of differentiability: a function is differentiable at a point a if there's a linear transformation T such that

(lim_(x -> a))((||f(x) - f(a) - T(x-a)||)/(||x-a||)) = 0

(The double bars in that equation mean ``length of a vector'.')  Let's think about what that equation means: the limit is zero, so as x approaches a, the numerator becomes much smaller than the denominator. The denominator is just the distance from x to a. Since T is linear, T(x-a) = T(x) - T(a), and the part of the numerator inside the bars can be written in a somewhat more illuminating way:

f(x) - f(a) - (T(x) - T(a)) = f(x) - f(a) - T(x) + T(a).

But wait...T is a tangent plane (or ``tangent 3-space'', etc) so f(a) must equal T(a), and in the above equation they'll cancel. So the numerator becomes even simpler—

f(x) - T(x)

—and we can rewrite the above limit as

(lim_(x -> a))((|f(x)  - T(x)|)/(|x-a|)) = 0.

If that limit is zero, then as x approaches a (along any path, of course) the numerator is much smaller than the denominator, which means that the linear transformation approximates f(x) very well near a. You might say that in a very small neighborhood of a, f(x) is ``just about'' linear. This is what we were trying to visualize earlier in this section.

This definition of differentiability is, unfortunately, not very practical. If we're interested in deciding whether a function is differentiable or not (and also in finding the particular linear transformation that approximates it), we have to use a test which will be described below.

Summary of what "differentiable" means

To recap what we've gone over (and add a few more details from lecture that you can look up in your notes):

Single Variable Calculus

A function \(f : ℝ\^1 -> \ ℝ\^1\)is differentiable at x = a if has linear approximation (that is, a tangent line) at that point.  Moreover, the derivative f' (a) is the slope of the tangent line.  A little less intuitively, the derivative f' (a) is the number which makes the following equation be the linear approximation to f at x = a.

L (x) = f (a) + f' (a) (x - a)

We know that some things, such as polynomials and trig functions, are differentiable.  If you're ever in doubt about a given function, you can always check it using the limit definition you learned in Calc I.

Multivariable Calculus

A function f:(ℝ^n)-> (ℝ^m)is differentiable at (Overscript[x, ⇀]) = (Overscript[a, ⇀]) if has linear approximation (that is, a tangent (hyper-) plane) at that point.  Moreover, the derivative Df((Overscript[a, ⇀]))  is a matrix which, in some sense, tells you the "slope" of the tangent plane.  More accurately, if a little less intuitively, the derivative Df((Overscript[a, ⇀])) is the matrix which makes the following equation be the linear approximation to f at x = a.

L((Overscript[x, ⇀]))=f((Overscript[a, ⇀]))+D f ((Overscript[a, ⇀])) ((Overscript[x, ⇀]) - 
              (Overscript[a, ⇀]))

How can you tell if a multivariable function is differentiable?  We have the following handy-dandy (if somewhat complicated) theorem.

Differentiability Theorem: f:(ℝ^n)-> (ℝ^m) is differentiable at a point x=a if each of the entries of the matrix D f(a) exists at a and is continuous at a; in other words, all of the partial derivatives which make up D f(a) exist and are continuous functions at a.

The important feature of this theorem is that it requires the partial derivatives to be continuous, and not to merely be defined at some point.  That doesn't sound too bad, but you know from the first section of this lab that it can be tricky just to tell if a given function (i.e. one of the partial derivatives) is continuous or not!

Exercise 3

Consider the following function, which we examined above.  You may wish to go back and look at the graph and the "alleged" tangent plane at (0,0), which we've already told you isn't really a tangent plane.  In this exercise you're going to prove that.

f (x, y) = {({{(((x^3)  -  (y^3))/((x^2)  +  (y^2))),  if (x, 
                        y)  ≠  (0, 0);}, {0,             if (x, y)  =  (0, 
                      0).}})

You may assume that f(x, y) is a continuous function without proving it.
   
(a) Find the partial derivatives of f at the origin.  Don't use Mathematica to do this; do it by hand.  Remember that f(0, 0) = 0.

Now let's see why f is not differentiable at the origin.

(b) Earlier you were told that if there were a tangent plane at the origin, it would have to be the plane z = x - y.  Prove this.  Remember that the equation for the tangent plane -- that is, the linear approximation -- looks like this:

						L((Overscript[x, ⇀]))=f((Overscript[a, ⇀]))+D f(
                (Overscript[a, ⇀])) ((Overscript[x, ⇀]) - 
                  (Overscript[a, ⇀]))

In particular, if we have a function of two variables, the equation for the linear approximation at a point (a,b) becomes

						L(x, y)=f(a, b)+D f(a, b)·(x - a, y - b)

(c) Is the plane tangent to the graph when restricted to the line x = 0? y = 0? y = -x? Check this by making two-dimensional plots of L and f when restricted to those lines. Note that tangency is somewhat like continuity: if there's some line along which L fails to be tangent to f, then L (in all of 3-space) is not tangent to f.

(d) Now you've shown that L is not tangent to f.  But L is the only possible linear approximation for f at the origin; hence there is no linear approximation for f there.  In other words, f is not differentiable at the origin.  Explain why this does not contradict the "Differentiability Theorem" above.

Note that we've split this problem up into pieces to help you work through it, but your written solution should not be split up in this way; it should be a seamless essay which investigates this function and hits the important points mentioned here.

Exercise 4

Consider the following function:

f (x, y) = {({{(1/2) y Log[
                    (x^2) + (y^2)],       if (x, 
                        y)  ≠  (0, 0);}, {0,              if (x, y)  =  (0, 
                      0).}})

You may assume that this is a continuous function (although that's not easy to show!)  Prove that f does not satisfy the conditions of the "Differentiability Theorem" above at the point (0,0).

Credits

This lab has a long history.  Originally we had a lab written in LATEX by Cindy Kaus which described all of the pathological examples of things that can go wrong -- everything from discontinuous functions to differentiable functions whose mixed partials are not equal.  Students were asked to prove these facts about the functions and were given some guidance about how to do it in Mathematica.  In Spring 2002 Dan Drake completely rewrote the entire thing as a Mathematica notebook, which had two advantages for us: (1) consistency, because now all of the labs were in notebook form, and (2) he could include graphing commands and other pictures to help make his point.  Dan wrote pages and pages of terrific explanations which helped a lot; the only overlap with Cindy's original lab were the four exercises, although he restated and split those into steps to help students along.

It was still a very hard assignment.  People weren't learning the subtle details in the labs, and we weren't using the really pathological examples later on in the course anyway.  In January 2004 I revamped the lab to be more interactive and example-driven.  The exercises have been scaled back and are based on the examples.  Hopefully this version will go over well.

Everything up to example 1 was written by Dan, as well as the excellent explanation of the "technical definition" of differentiability.  Example 3 is an expansion of an example he added to the lab, and exercise 3 is a slight reworking of his version of one of Cindy's exercises.  There's not much else left of Cindy's original lab, I guess.  Example 3 is based on her "Example (i)."

This version is copyright 2004 by Jonathan Rogness (rogness@math.umn.edu), with the exception of those parts described above, which are copying 2002 by Dan Drake and 2000 by Cindy Kaus.  All of us have agreed to use the same license, so this lab is protected by the Creative Commons Attribution-NonCommercial-ShareAlike License.  You can find more information on this license at http://creativecommons.org/licenses/by-nc-sa/1.0/

Although it's not specifically required by the license, I'd appreciate it if you let me know if you use parts of our labs, just so I can keep track of it.  Please send me any questions or comments!