TOPIC: GRADIENTS AND CONNTOUR CURVES

These notes concern the relation between contour curves, or by another name, level sets, and gradients.

Here is the key definition, given first for functions f(x,y) of two variables:

Definition of Contour Curves

The level set of f at value c is the set of all points (x,y) such that f(x,y) = c. Another name for this is the contour curve of f at level c.

For example, if

f(x,y) = x2 + y2

and if

c=1,

then the level set of f at value c is the set of points satisfying

x2 + y2 = 1

which is of course the unit circle.

In general, if f is any reasonable function (say, a polynomial of any degree...) then the set of points satisfying f(x,y) = c is a curve in the plane. possibly disconected. For example, if

f(x,y) = x2 - y2 and c = 1

as before, then level set of f at value c is a hyperbola -- with two branches.

Let's think of this in terms of our map analogy: If we think of f as altitude, then the level sets of f, plotted out as curves, are the curves of constant altitude. On a map, these are called contour curves, and so a plot of them is often called a contour plot. Now if you are walking along a contour curve on the terrain represented on our map, so you are walking along a path of constant altitude, then you will be walking always in a direction perpendicular to the direction of steepest ascent -- i.e., the direction in which the gradient would point.

This is the key fact relating level curves and gradients:

Theorem on Gradients and Contour Curves

Consider any point (x0,y0), and the level curve of f through this point (i.e., the level curve of f at value f(x0,y0)). Then the gradient of f at f(x0,y0) is perpendicular to the tangent direction along the level curve of f though (x0,y0).

It is very easy to see why this theorem is true. Suppose that (a,b) is any vector that is tangent to the level curve of f through (x0,y0). Then, as you move in the (a,b) direction, you are at that instant moving along the level curve, and the vaalue of f does not change. So the directional derivative in this direction is zero; i.e.,

dot(gradf(x0,y0),(a,b)) = 0

This is the perpendicularity that we wanted to establish.

Now that we know the theorem is true, why is it useful?

The short answer is that this theorem allows us to avoid parameterization of cuves when working with their tangent vectors -- something that we do a lot of.

To see this in action, consider the problem of computing the tangent direction to the circle

x2 + y2 = 2

at the point

(1,1)

Of course for a circle, the geometry is so simple that we can figure out the answer without any computation. That will give us a good check though.

Now the tangent direction is the instantaneous direction of motion as one moves along the curve. To get a formula without using the theorem, consider any parameterization (x(t),y(t)) through (1,1) at t = 0. For

We can parameterize this curve -- the circle of radius sqrt(2) -- by

(x(t),y(t)) = sqrt(2)*(cos(t),sint(t))

This parameterized path runs over the circle, and passes through (1,1) at t = pi/4, as you easily check. The tangent direction as it does so is the instantaneous direction of motion; i.e., the direction of the velocity vector (x'(t),y'(t)) at t = pi/4. In this case

(x'(t),y'(t)) = sqrt(2)*(-sin(t),cos(t))

so that

(x'(pi/4),y'(pi/4)) = (-1,1) which is what geometric reasoning suggests.

Actually, any multiple of (-1,1) would have been an equally good answer: A contour curve is just a curve, and no orientation or speed of travel is specified for it.

That is, there are two directions you can move on any curve, and neither one is singled out above the other. And there are infinitely many speeds of travel.

(x(t),y(t)) = sqrt(2)*(cos(2-4*t),sint(2-4*t))

is another parameterization. This one runs clockwise, and passes through (1,1) at complicated value of t, but you can use it just as well and you will get a multiple of what we found above.

To compute the directions along a tangent line this way, from its basic definition, you have to first come up with a parameterization, and this can be unpleasant. That's why it is so useful that the gradient vector is perpendicular is perpendicular to the tangent direction.To find the tangent direction without introducing a parameterization, just compute the gradient, and then take the direction perpendicular to that.

How do you find the perpendicular direction?

Just like this: Consider a vector (a,b) in the plane. Switch the component, and chage sign of the first component. This produces (-b,a). Now the dot product of (a,b) and (-b,a) is

a*(-b) + b*a = 0

so that the two vectors are orthogonal. This operation of sending (a,b) to (-b,a) in fact effects a 90 degree rotation in the counter--clockwise direction. Clearly it is 90 degrees in some direction. To see which one, consider (1,0). this gets mapped to (0,1), and so the direction is counter--clockwise.

This operation of sending (a,b) to (-b,a) is used extensively in compter graphics, and is sometimes called "perping". We will use it quite a bit in this course, so we make a formal definition:

Definition of the Perp Operation

Given any vector V = (a,b) in the plane, the perping operation transforms V into

Vperp = (-b,a)

which is a counterclocwise rotation of V through and angle pi/2.

Now let us solve our problem using the theorem and perping: The gradient of f is (2*x,2*y), and at (1,1) this is (2,2). Clearly (2,2)perp = (-2,2), which is a multiple of what we found by parameterization. But this is much simpler, even for a circle.

The advantage becomes much clearer if you consider the same problem for

x4 + y6 = 2

at the point

(1,1)

Working with the gradient and perping, we find easily that the tangent direction is (-6,4). It is harder to even get going by parameterizing. In general, parameterizing curves is not so easy, and involves arbitrary choices, and so it should be avoided where it can be.

Fortunately, many of the curve we deal with here are contour curves, so this will be possible whenever the problem is to find the tangent direction.

In summary, to find the two tangent directions along a level curve, do this: Compute the gradient gradf = (fx,fy) Then the "perped" vector (-fy,fx) points in one direction along the tangent line and -1 times this vector, i.e., (fy,-fx) points along the other. Thus, computing the gradient and then perping enables us to avoid setting up a parameterization.