Derivatives of vector fields

Another thing that changes when moving from 1D to 3D is that we now have a choice of two types of functions, scalar fields or vector fields. Now we’ll think about vector fields, that is, assigning a magnitude and a direction to every point in space. Think about those wind maps on the weather forecast, or magnetic field lines around a magnet.

To know a vector field, we need to know each of its components at each point in space. \[ {\mathbf{F}}(x,y,z) = F_1(x,y,z){\mathbf{e}}_x + F_2(x,y,z){\mathbf{e}}_y + F_3(x,y,z){\mathbf{e}}_z, \] or equivalently in a different co-ordinate system.

Firstly, given any vector field we can easily construct a scalar field by taking the magnitude at each point in space, \[ \left|{\mathbf{F}}(x,y,z)\right|=\sqrt{F_1(x,y,z)^2 + F_2(x,y,z)^2 + F_3(x,y,z)^2} \] and then take scalar derivatives. More on that next week.

We consider two different types.

The divergence of a vector field

This one takes a vector field and gives the answer as a scalar field, and the interpretation is “how much is the vector field pointing apart.” In Cartesian co-ordinates, the definition is \[ \nabla\cdot {\mathbf{F}} = {\frac{\partial F_1}{\partial x}} + {\frac{\partial F_2}{\partial y}} + {\frac{\partial F_3}{\partial z}}. \]

To get a feel for what this means, let’s look at some examples (plotting just the \(x-y\) plane)

If \({\mathbf{F}}=[x,y,0]\), then \(\nabla\cdot{\mathbf{F}} = 1 + 1 + 0 = 2\) which is positive. The arrows point apart:

Code
import numpy as np
import plotly.figure_factory as ff

x, y = np.meshgrid(np.linspace(-2, 2, 20), np.linspace(-2, 2, 20))
F1 = x
F2 = y

fig = ff.create_quiver(x, y, F1, F2, scale=0.1)
fig.show()

If \[{\mathbf{F}}=\left[\frac{1+x}{\sqrt{(1+x)^2+y^2}}+\frac{1-x}{\sqrt{(1-x)^2+y^2}},\frac{y}{\sqrt{(1+x)^2+y^2}}-\frac{y}{\sqrt{(1-x)^2+y^2}},0\right],\] then (do this as an exercise) \[\nabla\cdot{\mathbf{F}} = \frac{1}{\sqrt{(1+x)^2+y^2}} - \frac{1}{\sqrt{(1-x)^2+y^2}}.\] This is positive when \(x<0\) and negative when \(x>0\)1, which corresponds to the behaviour of the arrows:

Code
import numpy as np
import plotly.figure_factory as ff

x, y = np.meshgrid(np.linspace(-2, 2, 20), np.linspace(-2, 2, 20))
F1 = (1+x)/np.sqrt((1+x)*(1+x)+y*y) + (1-x)/np.sqrt((1-x)*(1-x)+y*y)
F2 = y/np.sqrt((1+x)*(1+x)+y*y) - y/np.sqrt((1-x)*(1-x)+y*y)

fig = ff.create_quiver(x, y, F1, F2, scale=0.1)
fig.show()

If \({\mathbf{F}}=[-y,x,0]\), then \(\nabla\cdot{\mathbf{F}} = 0 + 0 + 0 = 0\) - there is no divergence anywhere. The arrows don’t point apart from each other or towards each other:

Code
import numpy as np
import plotly.figure_factory as ff

x, y = np.meshgrid(np.linspace(-2, 2, 20), np.linspace(-2, 2, 20))
F1 = -y
F2 = x

fig = ff.create_quiver(x, y, F1, F2, scale=0.1)
fig.show()

The curl of a vector field

This one takes a vector field and gives another vector field, and the interpretation is “how much is the vector field rotating.” It’s a vector because the direction represents the axis of rotation and the magnitude of the vector gives the strength of rotation.

In Cartesian co-ordinates, the definition is \[ \nabla \times {\mathbf{F}} = [{\frac{\partial F_3}{\partial y}}-{\frac{\partial F_2}{\partial z}},\,{\frac{\partial F_1}{\partial z}}-{\frac{\partial F_3}{\partial x}},\,{\frac{\partial F_2}{\partial x}}-{\frac{\partial F_1}{\partial y}}], \] which totally makes sense if you think of it as a literal cross product. Unfortunately it’s not actually a cross product, in the sense that this doesn’t work in curvilinear co-ordinates, but it’s a good way to think about it.

Note

Just like the cross product, the curl is only defined in three dimensions. Sometimes people talk about 2D curls, but they’re a bit different and much less important, so we’ll ignore this.

If \({\mathbf{F}}=[-y,x,0]\), then \(\nabla\times{\mathbf{F}} = [0,0,2]\) - the axis of rotation is in the \(z\) direction and it’s positive (so anti-clockwise looking down the axis).

Code
import numpy as np
import plotly.figure_factory as ff

x, y = np.meshgrid(np.linspace(-2, 2, 20), np.linspace(-2, 2, 20))
F1 = -y
F2 = x

fig = ff.create_quiver(x, y, F1, F2, scale=0.1)
fig.show()

If \({\mathbf{F}}=[x,y,0]\), then \(\nabla\times{\mathbf{F}} = [0,0,0]\) - there is no rotation.

Code
import numpy as np
import plotly.figure_factory as ff

x, y = np.meshgrid(np.linspace(-2, 2, 20), np.linspace(-2, 2, 20))
F1 = x
F2 = y

fig = ff.create_quiver(x, y, F1, F2, scale=0.1)
fig.show()

Example

Directly calculate the divergence and curl of \[ {\mathbf{F}}(x,y,z) = [xz(x^2+y^2),\,yz(x^2+y^2),\,(x^2+y^2)]. \]

\[ \begin{aligned} \nabla\cdot{\mathbf{F}} &= {\frac{\partial }{\partial x}}(xz(x^2+y^2)) + {\frac{\partial }{\partial y}}(yz(x^2+y^2)) + {\frac{\partial }{\partial z}}(x^2+y^2) \\ &= (z(x^2+y^2) + 2x^2z) + (z(x^2+y^2) + 2y^2z) + 0 \\ &= 4z(x^2+y^2) \end{aligned} \]

\[ \begin{aligned} \nabla\times{\mathbf{F}} &= [{\frac{\partial }{\partial y}}(x^2+y^2)-{\frac{\partial }{\partial z}}(yz(x^2+y^2)),\,{\frac{\partial }{\partial z}}(xz(x^2+y^2))-{\frac{\partial }{\partial x}}(x^2+y^2),\,pd{}{x}(yz(x^2+y^2))-{\frac{\partial }{\partial y}}(xz(x^2+y^2))] \\ &= [2y-y(x^2+y^2),\,x(x^2+y^2)-2x,\,2xyz-2xyz]\\ &=[2y-y(x^2+y^2),\,x(x^2+y^2)-2x,0]. \end{aligned} \]

Div and curl in curvilinear co-ordinates.

Just as for the grad, the div and curl are not as simple in different co-ordinate systems. For cylindrical and spherical co-ordinates, the full formulas can be found here: https://en.wikipedia.org/wiki/Del_in_cylindrical_and_spherical_coordinates#Del_formula. These are the sorts of things you’ll want on a formula sheet in the exam.

For example, if we can write a vector field \({\mathbf{F}}\) in the form \[ {\mathbf{F}}(r,\phi,\theta) = F_r {\mathbf{e}}_r + F_\phi {\mathbf{e}}_\phi + F_\theta {\mathbf{e}}_\theta \] then we can apply the formula \[ \nabla\cdot{\mathbf{F}} = \frac{1}{r}^2{\frac{\partial }{\partial r}}(r^2 F_r) + \frac{1}{r\sin\theta}{\frac{\partial F_\phi}{\partial \phi}} + \frac{1}{r\sin\theta}{\frac{\partial }{\partial \theta}}(\sin\theta F_\theta). \]

Example

By using cylindrical co-ordinates, calculate the divergence and curl of \[ {\mathbf{F}}(x,y,z) = [xz(x^2+y^2),\,yz(x^2+y^2),\,(x^2+y^2)]. \]

Important

Remember, the square brackets always mean the coefficients of the Cartesian basis vectors.

First we have to transform the vector field into cylindrical co-ordinates. So we need to find the coefficients of \[{\mathbf{e}}_\rho = [\cos\phi,\sin\phi,0],\] \[{\mathbf{e}}_\phi = [-\sin\phi,\cos\phi,0],\] \[{\mathbf{e}}_z = [0,0,1].\]

Step by step: \[ \begin{aligned} {\mathbf{F}}(x,y,z) &= [xz(x^2+y^2),\,yz(x^2+y^2),\,(x^2+y^2)]\\ &= [z\rho^3\cos\phi,\,z\rho^3\sin\phi,\,\rho^2]\\ &= z\rho^3[\cos\phi,\sin\phi,0] + \rho^2 [0,0,1]\\ &= z\rho^3{\mathbf{e}}_\rho + \rho^2 {\mathbf{e}}_z \end{aligned} \]

This is the form we need to apply the formulas for div and curl (which you can find online) \[ \nabla\cdot{\mathbf{F}} = \frac{1}{\rho}{\frac{\partial \rho F_\rho}{\partial \rho}} + \frac{1}{\rho}{\frac{\partial F_\phi}{\partial \phi}} + {\frac{\partial F_z}{\partial z}} \] and \[ \nabla\times{\mathbf{F}} = \left( \frac{1}{\rho} {\frac{\partial F_z}{\partial \phi}} - {\frac{\partial F_\phi}{\partial z}} \right) {\mathbf{e}}_\rho + \left( {\frac{\partial F_\rho}{\partial z}} - {\frac{\partial F_z}{\partial \rho}} \right) {\mathbf{e}}_\phi + \frac{1}{\rho} \left( {\frac{\partial (\rho F_\phi)}{\partial \rho}} - {\frac{\partial F_\rho}{\partial \phi}} \right) {\mathbf{e}}_z \] so in this case we have divergence \[ \nabla\cdot{\mathbf{F}} = \frac{1}{\rho} 4z\rho^3 + 0 + 0 = 4z\rho^2 = 4z(x^2+y^2) \] which is the same as we found before.

For the curl \[\begin{aligned} (\nabla\times{\mathbf{F}})_\rho &= \frac{1}{\rho} {\frac{\partial F_z}{\partial \phi}} - {\frac{\partial F_\phi}{\partial z}} = 0 - 0 = 0 \\ (\nabla\times{\mathbf{F}})_\phi &= {\frac{\partial F_\rho}{\partial z}} - {\frac{\partial F_z}{\partial \rho}} = \rho^3 - 2\rho = \rho(\rho^2 - 2) \\ (\nabla\times{\mathbf{F}})_z &= \frac{1}{\rho} \left( {\frac{\partial (\rho F_\phi)}{\partial \rho}} - {\frac{\partial F_\rho}{\partial \phi}} \right) = 0 - 0 = 0 \end{aligned} \] So the curl is \[\begin{aligned}\nabla\times{\mathbf{F}} &= \rho(\rho^2 - 2)\,{\mathbf{e}}_\phi \\&=[-\rho(\rho^2 - 2)\sin\phi,\,\rho(\rho^2 - 2)\cos\phi,\,0] \\&=[-((x^2+y^2) - 2)y,\,((x^2+y^2) - 2)x,\,0]\end{aligned}\] which is the same as we got before.

Note

Sometimes it simplifies things a lot to convert to a different co-ordinate system. Sometimes it’s not worth the effort.

Footnotes

  1. How can you prove this?↩︎