Understanding the situation

We defined the gradient as a vector derivative

$$\overrightarrow{\nabla}f = \frac{\partial f}{\partial x} \hat{i} +\frac{\partial f}{\partial y} \hat{j} +\frac{\partial f}{\partial z} \hat{k}$$

where the curly d's ($\partial$) remind us that the function depends on many variables and when we take each derivative, we have to not change the other variables while we are doing it.

Let's look at an example in 2D to see how this works mathematically and let's represent the answer with a variety of different diagrams.

Presenting a sample problem

A simple important function of two variables that has non-trivial derivatives is the Gaussian:

$$f(x,y) = Ae^{-(x^2+y^2)}$$

Find the gradient of $f$.

Solving this problem

Let's start by thinking about what this function looks like in a geometric plot. Since the combination $x^2 + y^2 = r^2$  is the square of the distance from the origin in the x-y plane, the Gaussian function can be written

$$f(x,y) = Ae^{-r^2}$$

Since this is only a function of $r$, we expect it to be symmetric around the origin (only a function of the distance from 0, not the direction) and it is. Let's look at it in two views: a 3D graph showing the height $z = f (x,y)$ as a function of two variables on the left, and a contour plot (topographical map) looking at the graph from above on the right. In the topo map the lines of equal color mark lines of equal height (equal value of the function).

If we look at these two plots and think about their gradients as telling us how a ball would roll on the surface considered as a hill, we can see that we expect there to be no force at the top (it doesn't know way which way to roll), the force points down and away from the center, and gets smaller as we get farther away from the origin.

Let's see how this plays out in the math. It's easiest to consider the Gaussian as a function of r and r as a function of x and y. We can then use the chain rule. Let's get the derivative first with respect to x. Since we are treating y as a constant, this is just the same as if we were doing calculus with only 1 variable.

$$\frac{\partial f}{\partial x} = \frac{df}{dr} \frac{\partial r}{\partial x}= (-2rf)\frac{\frac{1}{2} 2x}{\sqrt{x^2+y^2}} = -\frac{2xrf}{r} = -2xf$$

Similarly, the derivative with respect to y will give  $-4yf$. So our total result for the gradient is

$$\overrightarrow{\nabla}f = -2xf\hat{i} -2yf\hat{j} = -2f(x\hat{i} + y\hat{j}) = -2f\overrightarrow{r}$$

Reading this equation, it says that the gradient of the Gaussian function, $f$, is just $-2f$ times the vector $r$  from the origin to the point where we are considering the gradient.

This tells us two things: (1) that the magnitude of the gradient of f is 2rf , (2) that the direction of the gradient is opposite to the vector to the position we are considering. What this means is made clear at the figure at the right. We are considering the gradient at the point (x,y). The vector to that point is r.  The gradient at (x,y) points back to the origin (the highest point) — in the direction opposite to r.

The force associated with the gradient is the negative, of the gradient so it points in the same direction as $\overrightarrow{r}$.

The gradient of the Gaussian function, $f$, is a vector function of position; that is, it is a vector for every position $\overrightarrow{r}$ given by

$$\overrightarrow{\nabla}f = -2f(x,y)(x\hat{i} + y\hat{j})$$

For the forces associated with this gradient, we take the negative since the force associated with a PE will point "downhill."

This equation assigns a vector to each point in space. This kind of thing is called a vector field and will be very important when we start talking more about electric forces. One useful way to represent it is as a field diagram -- a diagram that attaches the vector to each point in space. For this case, the forces associated with a potential energy, $f$, look something like the figure at the right.

You ought to be able to match this with the diagrams at the top of the page and see how the forces downhill agree with your expectations, both from the shape of the hill and from the equation we calculated for the gradient.

Joe Redish 11/4/14

Article 320