
Suppose we have a function given to us as $f(x,y)$ in two dimensions or as $g(x,y,z)$ in three dimensions. We can take the partial derivatives with respect to the given variables and arrange them into a vector function of the variables called the gradient of $f$ , namely
which mean
Suppose however, we are given $f$ as a function of $r$ and $\theta $ , that is, in polar coordinates, (or $g$ in spherical coordinates, as a function of $\phi ,\theta $ , and $\rho $ ).
For example, suppose $f=\frac{1}{r}$ , or $g=\frac{1}{\rho}$ , or $g=\mathrm{sin}\theta $ .
How do we find the gradient of $f$ or $g$ ?
One way to find the gradient of such a function is to convert $r$ or $\rho $ or $\theta $ into rectangular coordinates using the appropriate formulae for them, and perform the partial differentiation on the resulting expressions.
Thus we can write
and find, by ordinary partial differentiating
It is a bit more convenient sometimes, to be able to express the gradient directly in polar coordinates or spherical coordinates, like it is expressed in rectangular coordinates as above.
We want here an expression involving partial derivatives with respect to $r$ and $\theta $ multiplied by vectors pointing respectively in the $r$ direction, and $\theta $ direction.
So we want to know: what vectors should these partial derivatives be multiplied by in order to form the gradient?
When we find the answer, the actual partial derivative with respect to each polar variable will be the dot product of a unit vector in a polar direction with the gradient.
We therefore digress to discuss what thes unit vectors are so that you can recognize them.
The r direction is the direction tilted by an angle $\theta $ counterclockwise from the $x$ axis. A unit vector in that direction, call it $\stackrel{\u27f6}{{u}_{r}}$ , can be written in any of the three following forms
The unit vector in the $\theta $ direction lies in the direction $90\xb0$ beyond the $r$ direction, counterclockwisely, and is therefore given by
We now ask: what is $\stackrel{\u27f6}{\nabla}f$ in polar coordinates?
We know that if we make differential changes in $r$ and $\theta $ the resulting change in $f$ will be given by
since this relation holds for any variables at all.
But they must also obey
As we noted briefly in section 3.8 , distance in polar coordinates upon making small changes in the variables $r$ and $\theta $ is described by
From this we deduce that $d{s}_{r}$ is $dr$ while $d{s}_{\theta}$ is $rd\theta $ .
Putting the two equations for ds together, we deduce:
${(\stackrel{\u27f6}{\nabla}f)}_{r}$ is the partial derivative of $f$ with respect to $r$ , just as ${(\stackrel{\u27f6}{\nabla}f)}_{x}$ is its partial derivative with respect to $x$ .
But because $d{s}_{\theta}$ has a factor of $r$ in it, there must be a compensating factor of $r$ in the denominator of the component of $\stackrel{\u27f6}{\nabla}f$ in the $\theta $ direction
and
A similar computation can be made for any orthogonal directions in any dimension, and we can anticipate the result.
The component of $\stackrel{\u27f6}{\nabla}f$ in the direction of any such variable will be the partial derivative of $f$ with respect to that variable, divided by the ratio of distance change in that direction to change in the variable itself.
Using the last equation we can immediately deduce that the gradient of $\theta $ is $\frac{\stackrel{\u27f6}{{u}_{\theta}}}{r}$ , except of course at $r=0$ , where $\theta $ is not differentiable. Similarly we find that the gradient of $\frac{1}{r}$ is $\frac{1}{{r}^{2}}\stackrel{\u27f6}{{u}_{r}}$ .
Exercises:
9.5 Use the fact that both angular variables in spherical coordinates are polar variables to express $d{s}^{2}$ in 3 dimensions in terms of differentials of the three variables of spherical coordinates. From this deduce the formula for gradient in spherical coordinates.
9.6 Find the gradient of $\varphi $ in spherical coordinates by this method and the gradient of $\theta $ in spherical coordinates also.
There is a third way to find the gradient in terms of given coordinates, and that is by using the chain rule.
We can first consider differential change of $f$ in rectangular coordinates, and then relate the differential changes in $x$ and $y$ to differential changes in the other coordinates, say $r$ and $\theta $ . Combining these we can relate the change in $f$ to changes in the latter two variables.
Since we know how to write the gradient in rectangular coordinates and can recognize unit vectors, we can express the resulting expression in terms of components of the gradient in the other coordinate system.
Explicitly we can write
and use the latter two equations to get rid of $dx$ and $dy$ in the first equation. The result is an expression for $df$ in terms of $dr$ and $d\theta $ , the coefficients of which can be described in terms of unit vectors in the various directions, and the gradient in rectangular coordinates.
Comparing that equation with the basic formula defining partial derivatives, Equation (A) above you can read off the components of the gradient.
This approach is useful when $f$ is given in rectangular coordinates but you want to write the gradient in your coordinate system, or if you are unsure of the relation between $d{s}^{2}$ and distance in that coordinate system.
Exercises:
9.7 Do this computation out explicitly in polar coordinates.
9.8 Do it as well in spherical coordinates.
What variables should we keep constant in taking partial derivatives?
It is worth noting that when we take the partial derivative with respect to $x$ or $y$ we always mean that we are keeping the other variable, $y$ or $x$ , constant; on the other hand the partials with respect to $r$ and $\theta $ always mean keeping the other one of these, $\theta $ or $r$ , constant. Any other meaning has to be described explicitly.
There are times and places where in a partial derivative one can become confused as to which variable or variables are being kept constant, and under such circumstances it is wise to modify the notation to supply this information explicitly. Thus we can write ${\left(\frac{\partial f}{\partial x}\right)}_{y}$ to mean the partial derivative with respect to $x$ keeping $y$ fixed, and then there can be no confusion as to what is kept constant.
The most important facts to remember about the gradient are:
It is straightforward to compute, in any orthogonal coordinate system
You can use it to determine the directional derivative of the function involved, in any direction.
In rectangular coordinates its components are the respective partial derivatives.
The gradient of the sum of two fields is the sum of their gradients (the gradient is a linear operator).
The gradient of a product can be computed by applying the usual product rule for differentiation.
