Sec13.10CheckDiffability.mws

Checking differentiability,

Worksheet By Mike May, S.J . - maymk@slu.edu

(Section 13.10)

> restart;

We say a function in 2 variables is differentiable at a point if the graph near that point can be approximated by the tangent plane. A harder question is how to tell when a function given by a formula is differentiable. This worksheet looks at how to check if a function is differentiable at a point.

Taking care of the easy points - nice function

A standard theorem states that a function is differentible at a point if both partial derivatives are defined and continuous at that point. Recall that polynomials are continuous functions. Similarly we get a continuous function if we take the sum, difference, product, or composition of two continuous functions. We can also take quotients if the denominator is not 0 and roots if the the function is not negative. We also recall that the derivative is not defined when we take a root of 0 or a negative. Thus with a nice function that is defined in a single algebraic case, we easily note that the function is differentiable at all points, except perhaps at the points where we divide by 0 or take a root of 0.

Exercise 1:

The following functions are from the exercises for section on differentiability in McCallum's Multivariable Calculus book. For each function, the reasoning above lets us say the function is "nice" everywhere, except perhaps at a small set of points. For each function (1-7 and 10), identify the "difficult" points.

(a) f(x, y) = x/y + y/x if x*y 0 and f(x, y) = 0 if x*y = 0.

>

(b) f(x, y) = 2*x*y/(x^2 + y^2)^2 if (x, y) 0 and f(0, 0) = 0.

>

(c) f(x, y) = x*y/sqrt(x^2 + y^2) if (x, y) 0 and f(0, 0) = 0.

>

(d) f(x, y) = x^2*y/(x^4 + y^2) if (x, y) 0 and f(0, 0) = 0.

>

(e) f(x, y) = x*y^2/(x^2 + y^2) if (x, y) 0 and f(0, 0) = 0.

>

(f) f(x, y) = x*y^2/(x^2 + y^4) if (x, y) 0 and f(0, 0) = 0.

>

(g) f(x, y) = sqrt(abs(x*y)).

>

(h) f(x, y) = x*y*(x^2 - y^2)/(x^2 + y^2) if (x, y) 0 and f(0, 0) = 0.

>

Really bad points - Where the function is not continuous.

A function can only be differentiable where it is continuous. You may need to review the section on continuity. Recall that a function is continuous at a point if the limit at that point equals the value of the function at that point. Since we are only worried about difficult points, the function will be defined by a special rule at the point, and by a formula nearby.

Consider the function defined in example 4 , f(x,y) = x*y/(x^2+y^2) , unless ( x, y ) is the origin, in which case we use the special rule f(0,0) = 0 . The problem is at the origin. The first way to check continuity is always to look at a graph to see if the function jumps.

> plot3d(x*y/(x^2+y^2),x=-1..1, y=-1..1,view=-1..1,
axes=boxed, style=patchcontour, shading=z, grid=[40,40]);

[Maple Plot]

It is clear from looking at the picture that this function is not continuous at the origin. If we look down the z-axis it is clear that all the different contours extend in to the origin.

(Technical tip - When looking at functions that might be discontinuous, it is often good to specify the view, or z-range. Otherwise the graph of a function going to infinity can eliminate the other details of the graph. It is also useful to use the shading=z option the that the color scheme is determined by z-value. At discontinuous points lots of colors try to come together.)

We would also like an algebraic way to look at continuity. To do that we pick two paths to the trouble spot that seem to follow different contours. We can then take old fashioned limits on the paths and see that they have different limits. (We may find a path that has no limit at all.) For our example we pick the line y=x and y=-x to approach the origin. Maple lets us evaluate the limits either symbolically or graphically.

> func:= (x, y) -> x*y/(x^2+y^2);
path1 := func(x,-x);
path2 := func(x,x);
LimitOnPath1 := limit(path1, x=0);
LimitOnPath2 := limit(path2, x=0);
plot({path1,path2},x=-1..1, y=-1..1);

func := proc (x, y) options operator, arrow; x*y/(x...

path1 := -1/2

path2 := 1/2

LimitOnPath1 := -1/2

LimitOnPath2 := 1/2

[Maple Plot]

Since the limits as we approach the origin of the 2 paths are different, the function cannot be continuous at the origin.

Exercise:

2) Use a computer plot to show that the function defined by

f(x, y) = x^2*y/(x^4 + y^2) when (x, y) (0, 0) and f(0, 0) = 0

is not continuous at the origin. Find 2 paths to the origin so that the limits on the paths are different from each other.

>

Difficult points that are differentiable - continuous partials

Having dealt with the nice points and the really bad points, we are ready to start working in from the ends. Typically, we are looking at points where the main formula would have division by 0, so the function is defined by a second rule at those points. If the function is continuous at that point, the correct value was chosen to bridge the gap.

We will use the function defined by f(x, y) = x*y*(x^2 - y^2)/(x^2 + y^2) away from the origin and f(0, 0) = 0. The origin is the difficult point in this problem. A look at the graph shows that we have patched the hole at the origin with the correct value so the function is continuous.

> func := x*y*(x^2-y^2)/(x^2+y^2);
funcx := simplify(diff(func,x));
funcy := simplify(diff(func,y));

func := x*y*(x^2-y^2)/(x^2+y^2)

funcx := y*(x^4-y^4+4*x^2*y^2)/((x^2+y^2)^2)

funcy := x*(x^4-y^4-4*x^2*y^2)/((x^2+y^2)^2)

Since we wanted to see if the partials are continuous, the obvious approach is to look at the graphs of the partials.

> plot3d(funcx, x=-1..1, y=-1..1,view=-1..1, axes=BOXED, grid=[40,40]);
plot3d(funcy, x=-1..1, y=-1..1,view=-1..1, axes=BOXED, grid=[40,40]);

[Maple Plot]

[Maple Plot]

Looking at the graphs it is clear that the partials are continuous at the origin. By the theorem from the book, the function is differentiable at the origin, hence everywhere.

Exercise:

3) Use the technique described above to show the function defined by f(x,y) = x^3*y^3/((x^2+y^2)^2) if [x, y] <> [0, 0] and f(0,0) = 0 is differentiable everywhere.

>

Continuous but not differentiable for lack of partials

As we start working on functions that are continuous but not differentiable, the easiest ones are those where the partial derivatives are not defined. These are function that are not differentiable when we take a cross section in x or y The easiest examples involve absolute values and roots.

Let f(x,y) = abs(x+y) . The function is continuous everywhere. When we take the cross sections x=0 and y=0 we get abs(y) and abs(x) respectively. Both of these curves have corners, so they are not differentiable ot 0. Hence the partial derivatives of f(x,y) don't exist.

> func := (x, y) -> abs(x + y);
pathx := func(h,0);
pathy := func(0,h);
PartialOnPathx := diff(pathx, h);
LimitOnPathx := limit(PartialOnPathx, h=0);
PartialOnPathy := diff(pathy, h);
LimitOnPathy := limit(PartialOnPathy, h=0);
plot({PartialOnPathx,PartialOnPathy,pathx,pathy},h=-1..1, y=-1..1);

func := proc (x, y) options operator, arrow; abs(x+...

pathx := abs(h)

pathy := abs(h)

PartialOnPathx := abs(1,h)

LimitOnPathx := undefined

PartialOnPathy := abs(1,h)

LimitOnPathy := undefined

[Maple Plot]

Exercise 4

Show that the function f(x,y) = (x^2+y^2)^(1/5) is not differentiable at the origin.

>

The hard case - showing non-differentiability for a continuous function.

The text points out that a function can be differentiable even if the partials are not continuous. We want some way to show that a function is not differentiable.

The trick is to notice that for a differentiable function, all the tangent vectors at a point lie in a plane.

Suppose that F(x,y) is differentiable at (a,b) with F[x](a,b) = c and F[y](a,b) = d .

Let U=[u_1, u_2] be a unit vector. Then the directional derivative in direction U must be the same whether we compute it from the definition of the directional deerivative or by taking the dot product of U with the gradient vector.

Consider the function defined by f(x,y) = (x^2*y)/(x^2+y^2).

The comments about easy points tell us that this function is differentiable everywhere except perhaps at the origin. Look at the graph of the function and its partial derivatives.

> func:= (x, y) -> x^2*y/(x^2+y^2);
funcx := simplify(diff(func(x,y),x));
funcy := simplify(diff(func(x,y),y));
plot3d(func(x,y), x=-1..1, y=-1..1,view=-1..1, axes=BOXED, grid=[40,40]);
plot3d(funcx, x=-1..1, y=-1..1,view=-1..3, axes=BOXED, grid=[40,40]);
plot3d(funcy, x=-1..1, y=-1..1,view=-3..1, axes=BOXED, grid=[40,40]);

func := proc (x, y) options operator, arrow; x^2*y/...

funcx := 2*x*y^3/((x^2+y^2)^2)

funcy := x^2*(x^2-y^2)/((x^2+y^2)^2)

[Maple Plot]

[Maple Plot]

[Maple Plot]

We see from the graphs that the function is continuous and that the partials are discontinuous.

The brute force method

We can simply have Maple compute the directional derivatives by both methods and compare them.

> func:= (x, y) -> x^2*y/(x^2+y^2);
funcxorg := limit(diff(func(x,0),x),x=0);
funcyorg := limit(diff(func(0,y),y),y=0);
dirderiv1 := theta -> cos(theta)*funcxorg+sin(theta)*funcyorg;
dirderiv2 := theta -> limit((func(h*cos(theta), h*sin(theta))-0)/h,h=0);
plot({dirderiv1(theta), dirderiv2(theta)}, theta=0..2*Pi, axes=boxed);

func := proc (x, y) options operator, arrow; x^2*y/...

funcxorg := 0

funcyorg := 0

dirderiv1 := proc (theta) options operator, arrow; ...

dirderiv2 := proc (theta) options operator, arrow; ...

[Maple Plot]

Since the two ways of computing directional derivatives do not always agree (and in fact disagree everywhere but on the axes) we conclude that the fuction is not differentiable.

It is instructive to look at the graph of the function on various scales and see that it never does flatten out to look like a plane. (The picture looks the same if del is 1 or 0.000001.)

> del := 1;
plot3d(func(x,y), x=-del..del, y=-del..del, view=-del..del, axes=normal,
style=patchcontour, orientation=[16,39], grid=[40,40]);

del := 1

[Maple Plot]

Exercises:

5) Show that the function in exercise 3 is not differentiable at the origin even though it is continuous there.

>

A non-graphing approach

We don't need to compute the directional derivative by both methods in every direction to show that a function is not differentiable. We simply need to show that the two methods give different answers in some direction.

Consider the function that sends (x,y) to x^2*y/(x^2+y^2)+sin(x)-2*y and sends the origin to 0. Once again, the comments about easy points tell us that this function is differentiable everywhere except perhaps at the origin. We compute the partials at the origin.

> func := (x, y) -> x^2*y/(x^2+y^2) + sin(x) -2*y;
funcxorg := limit(diff(func(x,0),x),x=0);
funcyorg := limit(diff(func(0,y),y),y=0);

func := proc (x, y) options operator, arrow; x^2*y/...

funcxorg := 1

funcyorg := -2

Now we compute the directional derivative along the line y=x (theta=Pi/4) using both methods.

> dirderiv1 := theta -> cos(theta)*funcxorg+sin(theta)*funcyorg:
dirderiv2 := theta -> limit((func(h*cos(theta), h*sin(theta))-0)/h,h=0):
dirderiv1(Pi/4); dirderiv2(Pi/4);

-1/2*sqrt(2)

-1/4*sqrt(2)

Since we get different answers, we conclude that the function is not differentiable at the origin.

6) Determine the status of the function defined by

f(x, y) = x*y^2/(x^2 + y^4) if (x,y) (0, 0) and f(0, 0) =0

(exercise 6 from section 13.10) at the origin. Is it not continuous, continuous but not differentiable, or differentiable at the origin?

>

The slick way to do these problems - converting to polar coordinates

The exercises for this section have been set up with the difficult point at the origin and with the functions symmetric about the origin. Such functions are often easier to describe in terms of polar coordinates. We can use Maple to convert functions to polar coordinates.

> makepolar := g -> simplify(subs({x=r*cos(theta), y=r*sin(theta)}, g));

makepolar := proc (g) options operator, arrow; simp...

Now look at the function from problem 3

> func := x*y/sqrt(x^2+y^2);
polarfunc := makepolar(func);

func := x*y/(sqrt(x^2+y^2))

polarfunc := r*cos(theta)*sin(theta)*csgn(r)

The function csgn(r) is a sign function that is either 1 or -1. Looking at the polar form, it is clear the the function is continuous at the origin. We also can see that the function is zero everywhere on the x or y axis. Time do check differentiability as r approaches 0.

> drfunc := diff(polarfunc,r);
drfunc0 := limit(drfunc, r=0);

drfunc := cos(theta)*sin(theta)*csgn(r)+r*cos(theta...

drfunc0 := undefined

The problem we are running into is the csgn(r) which is 1 in one direction and -1 in the other.

> drfunc0r := limit[dir](drfunc, r=0, right);
drfunc0l := limit[dir](drfunc, r=0, left);

drfunc0r := cos(theta)*sin(theta)

drfunc0l := -cos(theta)*sin(theta)

Thus for most values of theta we get a corner, not a tangent line. (The right hand and left hand limits for the derivative exist, but they are different from each other.) The function is clearly not differentiable at the origin.

Exercise:

7) Convert the functions in parts (b)-(h) of exercise 1 into polar form. Comment about continuity and differentiablility at the origin.

>

>