Derivatives of scalar fields
In this part of the module, we study how to differentiate fields. A field is another word for a function defined over space. This week, scalar fields: assigning to each point in space a scalar value. Think about a temperature field.
For example, the following could be a vector field \[ f({\mathbf{r}}) = f(x,y,z) = x^2y +z. \] If you know a point in space (given by co-ordinates or a position vector) then you know the value of \(f\) at that point.
There are different types of differentiation in higher dimensions, and they are generalisations of different interpretations of the normal derivative.
Gradient
In one dimension, for a function \(y=f(x)\), the derivative \(\frac{dy}{dx}\) tells us the direction we have to move to increase the function (whether the derivative is positive or negative) and how fast the function is increasing in that direction (the magnitude of the derivative).
With this interpretation, it seems obvious that the derivative of a scalar field in three dimensions should be a 3D vector, and this is the gradient1: \[ \nabla f = \left[{\frac{\partial f}{\partial x}},\,{\frac{\partial f}{\partial y}},\,{\frac{\partial f}{\partial z}}\right]. \] We read this as “grad f” or “the gradient of f”2. The direction of this vector field tells you the direction in which the function increases fastest, and the magnitude tells you the rate at which it’s increasing.
It’s important to understand the interpretation of the different derivatives as well as the definitions.
Example
Find the gradient of the scalar field \(f = x^2y + z\) at the point \((x,y,z) = (5,2,1)\).
\[\nabla f = [2xy,\,x^2,\,1]\] so at \((5,2,1)\) we have \[\nabla f = [20,25,1].\]
Directional derivative
A different interpretation of the derivative \(\frac{dy}{dx}\) is the rate of change of \(y\) as we increase \(x\). In three dimensions, it’s not clear what variable we should increase to find the derivative. Of course you can do each variable separately and these are the partial derivatives \({\frac{\partial f}{\partial x}}\), \({\frac{\partial f}{\partial y}}\) and \({\frac{\partial f}{\partial z}}\), but what about the rate of change in a general direction.
This is where the directional derivative comes in. It’s defined as \[ {\mathbf{a}} \cdot \nabla f = \left[a_1 {\frac{\partial f}{\partial x}},a_2{\frac{\partial f}{\partial y}},a_3{\frac{\partial f}{\partial z}}\right] \] and we say “a dot grad f”, or “the derivative of f in the direction a”.
This is just the usual dot product with the gradient. Why does it get a special name? (1) It comes up a lot. (2) In curvilinear co-ordinates it isn’t just the simple dot product.
The interpretation is to imagine travelling at a speed \(v{a}\) and checking how quickly the function \(f\) is changing at our current position.
The “direction” \({\mathbf{a}}\) doesn’t need to be a fixed vector, it could also be a vector field. This comes up a lot in physics, like in the Navier-Sokes equations and Maxwell’s equations. We’ll see this a bit more next week.
Some people define the directional derivative only for unit vectors, including in the old version of the notes. We’ll assume that \({\mathbf{a}}\) can be any vector or vector field.
Example
Find the directional derivative of the scalar field \(f = x^2y + z\) at the point \((x,y,z) = (5,2,1)\), in the direction \({\mathbf{a}} = [1,1,2]\).
We saw above that \[\nabla f = [20,25,1],\] so \[{\mathbf{a}} \cdot\nabla f = [1,1,2]\cdot[20,25,1] = 47.\]
Derivatives in curvilinear co-ordinates
We defined the gradient as \[ \nabla f = \left[{\frac{\partial f}{\partial x}},\,{\frac{\partial f}{\partial y}},\,{\frac{\partial f}{\partial z}}\right] = {\frac{\partial f}{\partial x}}{\mathbf{e}}_x + {\frac{\partial f}{\partial y}}{\mathbf{e}}_y + {\frac{\partial f}{\partial z}}{\mathbf{e}}_z. \] What if we’re using, say, spherical polar co-ordinates? We would hope that \[ \nabla f = {\frac{\partial f}{\partial r}}{\mathbf{e}}_r + {\frac{\partial f}{\partial \theta}}{\mathbf{e}}_\theta + {\frac{\partial f}{\partial \phi}}{\mathbf{e}}_\phi. \]
This is wrong!
Let’s try. A very simple vector field is \(f(x,y,z) = x\), so \[ \nabla f = [1,0,0] = {\mathbf{e}}_x. \] Remembering our definition of spherical co-ordinates, this field can be written as \(f(r,\theta,\phi) = r\cos\phi\sin\theta\). Then \[ \begin{aligned} {\frac{\partial f}{\partial r}}{\mathbf{e}}_r + {\frac{\partial f}{\partial \theta}}{\mathbf{e}}_\theta + {\frac{\partial f}{\partial \phi}}{\mathbf{e}}_\phi &= \cos\phi\sin\theta {\mathbf{e}}_r + r\cos\phi\cos\theta {\mathbf{e}}_\theta - r\sin\phi\sin\theta {\mathbf{e}}_\phi \\ &= \cos\phi\sin\theta [\cos\phi\sin\theta,\,\sin\phi\sin\theta,\,\cos\theta] + r\cos\phi\cos\theta [\cos\phi\cos\theta,\,\sin\phi\cos\theta,\,-\sin\theta] - r\sin\phi\sin\theta[-\sin\phi,\,\cos\phi,\,0]\\ &= [\cos^2\phi\sin^2\theta -r \sin^2\phi\sin\theta+r\cos^2\phi\cos^2\theta,\,\dots] \end{aligned} \] This horrible expression looks like it could simplify to \([1,0,0]\) but unfortunately it doesn’t - there are too many \(r\)s. 3
In fact, the correct formula is \[ \nabla f(r,\theta,\phi) = {\frac{\partial f}{\partial r}}{\mathbf{e}}_r + \frac{1}{r}{\frac{\partial f}{\partial \theta}}{\mathbf{e}}_\theta + \frac{1}{r\sin\theta}{\frac{\partial f}{\partial \phi}}{\mathbf{e}}_\phi. \] Hopefully the \(r\) and \(r\sin\theta\) ring a bell - these are the scale factors \(h_\theta\) and \(h_\phi\). The general rule, for some co-ordinate system \((u,v,w)\), is \[ \nabla f(u,v,w) = \frac{1}{h_u}{\frac{\partial f}{\partial u}}{\mathbf{e}}_u + \frac{1}{h_v}{\frac{\partial f}{\partial v}}{\mathbf{e}}_v + \frac{1}{h_w}{\frac{\partial f}{\partial w}}{\mathbf{e}}_w. \]
Think: What is grad in cylindrical co-ordinates?
Recalling the scale factor \(h_\phi=\rho\), we immediately get \[ \nabla f(\rho,\phi,z) = {\frac{\partial f}{\partial \rho}} {\mathbf{e}}_\rho + \frac{1}{\rho}{\frac{\partial f}{\partial \phi}}{\mathbf{e}}_\phi + {\frac{\partial f}{\partial z}}{\mathbf{e}}_z. \]
The directional derivative also has a different definition in different co-ordinate systems, and it also it’s the simple thing you want it to be. We won’t spend time on it in this module. If you ever need it, it’s easy to find the formula online.
Example
Consider the scalar field defined in cylindrical co-ordinates as \[ f(\rho,\phi,z) = \rho^2 z^3 \sin \phi. \] Find \(\nabla f\) at the point \((\rho,\phi,z)=(2,\pi,1)\) and give your answer as a Cartesian vector.
There are two different ways of doing this. We could convert it all to Cartesians (including the point). Instead let’s keep it in cylindrical co-ordinates:
\[ \begin{aligned} \nabla f(\rho,\phi,z) &= {\frac{\partial f}{\partial \rho}} {\mathbf{e}}_\rho + \frac{1}{\rho}{\frac{\partial f}{\partial \phi}}{\mathbf{e}}_\phi + {\frac{\partial f}{\partial z}}{\mathbf{e}}_z \\ &= 2\rho z^3 \sin\phi {\mathbf{e}}_\rho + \rho z^3 \cos\phi {\mathbf{e}}_\phi + 3\rho^2 z^2 \sin\phi\\ &= 2\rho z^3 \sin\phi [\cos\phi,\sin\phi,0] + \rho z^3 \cos\phi [-\sin\phi,\cos\phi,0] + 3\rho^2 z^2 \sin\phi [0,0,1]\\ &= [\rho z^3 \sin\phi\cos\phi,\, \rho z^3(2\sin^2\phi+\cos^2\phi),\, 3\rho^2 z^2 \sin\phi] \end{aligned} \]
So then at \((\rho,\phi,z)=(2,\pi,1)\) we have \[ \nabla f = [0, 2, 0] \] because \(\cos\phi=-1\) and \(\sin\phi=0\).
Footnotes
We already saw this for calculating normals to surfaces.↩︎
Strictly speaking the symbol \(\nabla\) is called “nabla” or “del”, but we often call it “grad” in other settings.↩︎
In fact, we could see straight away that \[ \nabla f \neq {\frac{\partial f}{\partial r}}{\mathbf{e}}_r + {\frac{\partial f}{\partial \theta}}{\mathbf{e}}_\theta + {\frac{\partial f}{\partial \phi}}{\mathbf{e}}_\phi \] because of the dimensions of the quantities. The dimensions of a derivative should be the dimensions of \(f\) divided by length, which is what the first expression has. But \(\theta\) and \(\phi\) are dimensionless, so we need to divide by a length to keep these ones consistent.↩︎