# Calculus/Vector calculus

Vector calculus specifically refers to multi-variable calculus applied to scalar and vector fields. While vector calculus can be generalized to $n$ dimensions ($\mathbb {R} ^{n}$), this chapter will specifically focus on 3 dimensions ($\mathbb {R} ^{3}$)

## Fields in vector calculus
### Scalar fields

A scalar field is a function $f:\mathbb {R} ^{3}\to \mathbb {R}$ that assigns a real number to each point in space. Scalar fields typically denote densities or potentials at each specific point. For the sake of simplicity, all scalar fields considered by this chapter will be assumed to be defined at all points and differentiable at all points.

### Vector fields

A vector field is a function $\mathbf {F} :\mathbb {R} ^{3}\to \mathbb {R} ^{3}$ that assigns a vector to each point in space. Vector fields typically denote flow densities or potential gradients at each specific point. For the sake of simplicity, all vector fields considered by this chapter will be assumed to be defined at all points and differentiable at all points.

### Vector fields in cylindrical coordinates

The cylindrical coordinate system used here has the three parameters: $(\rho ,\phi ,z)$. The Cartesian coordinate equivalent to the point $(\rho ,\phi ,z)$ is
$x=\rho \cos \phi$
$y=\rho \sin \phi$
$z=z$
Any vector field in cylindrical coordinates is a linear combination of the following 3 mutually orthogonal unit length basis vectors:
${\hat {\mathbf {\rho } }}=\cos \phi \mathbf {i} +\sin \phi \mathbf {j}$
${\hat {\mathbf {\phi } }}=-\sin \phi \mathbf {i} +\cos \phi \mathbf {j}$
${\hat {\mathbf {z} }}=\mathbf {k}$
Note that these basis vectors are not constant with respect to position. The fact that the basis vectors change from position to position should always be considered. The cylindrical basis vectors change according to the following rates:
| | ${\frac {\partial }{\partial \rho }}$ | ${\frac {\partial }{\partial \phi }}$ | ${\frac {\partial }{\partial z}}$ |
| ${\hat {\mathbf {\rho } }}$ | ${\frac {\partial {\hat {\mathbf {\rho } }}}{\partial \rho }}=\mathbf {0}$ | ${\frac {\partial {\hat {\mathbf {\rho } }}}{\partial \phi }}={\hat {\mathbf {\phi } }}$ | ${\frac {\partial {\hat {\mathbf {\rho } }}}{\partial z}}=\mathbf {0}$ |
| ${\hat {\mathbf {\phi } }}$ | ${\frac {\partial {\hat {\mathbf {\phi } }}}{\partial \rho }}=\mathbf {0}$ | ${\frac {\partial {\hat {\mathbf {\phi } }}}{\partial \phi }}=-{\hat {\mathbf {r} }}$ | ${\frac {\partial {\hat {\mathbf {\phi } }}}{\partial z}}=\mathbf {0}$ |
| ${\hat {\mathbf {z} }}$ | ${\frac {\partial {\hat {\mathbf {z} }}}{\partial \rho }}=\mathbf {0}$ | ${\frac {\partial {\hat {\mathbf {z} }}}{\partial \phi }}=\mathbf {0}$ | ${\frac {\partial {\hat {\mathbf {z} }}}{\partial z}}=\mathbf {0}$ |
Any vector field $\mathbf {F}$ expressed in cylindrical coordinates has the form: $\mathbf {F} (\mathbf {q} )=F_{\rho }(\mathbf {q} ){\hat {\mathbf {\rho } }}+F_{\phi }(\mathbf {q} ){\hat {\mathbf {\phi } }}+F_{z}(\mathbf {q} ){\hat {\mathbf {z} }}$
Given an arbitrary position $\mathbf {q} =(\rho ,\phi ,z)$ that changes with time, the velocity of the position is:
${\frac {d\mathbf {q} }{dt}}={\frac {d\rho }{dt}}{\hat {\mathbf {\rho } }}+\rho {\frac {d\phi }{dt}}{\hat {\mathbf {\phi } }}+{\frac {dz}{dt}}{\hat {\mathbf {z} }}$
The coefficient of $\rho$ for the term $\rho {\frac {d\phi }{dt}}{\hat {\mathbf {\phi } }}$ originates from the fact that as the azimuth angle $\phi$ increases, the position $\mathbf {q}$ swings around at a speed of $\rho$.

### Vector fields in spherical coordinates

The spherical coordinate system used here has the three parameters: $(r,\theta ,\phi )$. The Cartesian coordinate equivalent to the point $(r,\theta ,\phi )$ is
$x=r\sin \theta \cos \phi$
$y=r\sin \theta \sin \phi$
$z=r\cos \theta$
Any vector field in spherical coordinates is a linear combination of the following 3 mutually orthogonal unit length basis vectors:
${\hat {\mathbf {r} }}=\sin \theta \cos \phi \mathbf {i} +\sin \theta \sin \phi \mathbf {j} +\cos \theta \mathbf {k}$
${\hat {\mathbf {\theta } }}=\cos \theta \cos \phi \mathbf {i} +\cos \theta \sin \phi \mathbf {j} -\sin \theta \mathbf {k}$
${\hat {\mathbf {\phi } }}=-\sin \phi \mathbf {i} +\cos \phi \mathbf {j}$
Note that these basis vectors are not constant with respect to position. The fact that the basis vectors change from position to position should always be considered. The spherical basis vectors change according to the following rates:
| | ${\frac {\partial }{\partial r}}$ | ${\frac {\partial }{\partial \theta }}$ | ${\frac {\partial }{\partial \phi }}$ |
| ${\hat {\mathbf {r} }}$ | ${\frac {\partial {\hat {\mathbf {r} }}}{\partial r}}=\mathbf {0}$ | ${\frac {\partial {\hat {\mathbf {r} }}}{\partial \theta }}={\hat {\mathbf {\theta } }}$ | ${\frac {\partial {\hat {\mathbf {r} }}}{\partial \phi }}=\sin \theta {\hat {\mathbf {\phi } }}$ |
| ${\hat {\mathbf {\theta } }}$ | ${\frac {\partial {\hat {\mathbf {\theta } }}}{\partial r}}=\mathbf {0}$ | ${\frac {\partial {\hat {\mathbf {\theta } }}}{\partial \theta }}=-{\hat {\mathbf {r} }}$ | ${\frac {\partial {\hat {\mathbf {\theta } }}}{\partial \phi }}=\cos \theta {\hat {\mathbf {\phi } }}$ |
| ${\hat {\mathbf {\phi } }}$ | ${\frac {\partial {\hat {\mathbf {\phi } }}}{\partial r}}=\mathbf {0}$ | ${\frac {\partial {\hat {\mathbf {\phi } }}}{\partial \theta }}=\mathbf {0}$ | ${\frac {\partial {\hat {\mathbf {\phi } }}}{\partial \phi }}=-(\sin \theta {\hat {\mathbf {r} }}+\cos \theta {\hat {\mathbf {\theta } }})$ |
Any vector field $\mathbf {F}$ expressed in spherical coordinates has the form: $\mathbf {F} (\mathbf {q} )=F_{r}(\mathbf {q} ){\hat {\mathbf {r} }}+F_{\theta }(\mathbf {q} ){\hat {\mathbf {\theta } }}+F_{\phi }(\mathbf {q} ){\hat {\phi }}$
Given an arbitrary position $\mathbf {q} =(r,\theta ,\phi )$ that changes with time, the velocity of this position is:
${\frac {d\mathbf {q} }{dt}}={\frac {dr}{dt}}{\hat {\mathbf {r} }}+r{\frac {d\theta }{dt}}{\hat {\mathbf {\theta } }}+r\sin \theta {\frac {d\phi }{dt}}{\hat {\mathbf {\phi } }}$
The coefficient of $r$ for the term $r{\frac {d\theta }{dt}}{\hat {\mathbf {\theta } }}$ arises from the fact that as the latitudinal angle $\theta$ changes, the position $\mathbf {q}$ traverses a great circle at a speed of $r$.
The coefficient of $r\sin \theta$ for the term $r\sin \theta {\frac {d\phi }{dt}}{\hat {\mathbf {\phi } }}$ arises from the fact that as the longitudinal angle $\phi$ changes, the position $\mathbf {q}$ traverses a latitude circle at a speed of $r\sin \theta$.

## Volume, path, and surface integrals
### Volume Integrals

Volume integrals have already been discussed in the chapter Multivariable calculus, but a brief review is given here for completeness.
Given a scalar field $\rho :\mathbb {R} ^{3}\to \mathbb {R}$ that denotes a density at each specific point, and an arbitrary volume $\Omega \subseteq \mathbb {R} ^{3}$, the total "mass" $M$ inside of $\Omega$ can be determined by partitioning $\Omega$ into infinitesimal volumes. At each position $\mathbf {q} \in \Omega$, the volume of the infinitesimal volume is denoted by the infinitesimal $dV$. This gives rise to the following integral:
$M=\iiint _{\mathbf {q} \in \Omega }\rho (\mathbf {q} )dV$

### Path Integrals

Given any oriented path $C$ (oriented means that there is a preferred direction), the differential $d\mathbf {q} =dx\mathbf {i} +dy\mathbf {j} +dz\mathbf {k}$ denotes an infinitesimal displacement along $C$ in the preferred direction. This differential can be used in various path integrals. Letting $f:\mathbb {R} ^{3}\to \mathbb {R}$ denote an arbitrary scalar field, and $\mathbf {F} :\mathbb {R} ^{3}\to \mathbb {R} ^{3}$ denote an arbitrary vector field, various path integrals include:
$\int _{\mathbf {q} \in C}f(\mathbf {q} )d\mathbf {q}$, $\int _{\mathbf {q} \in C}f(\mathbf {q} )|d\mathbf {q} |$, $\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q}$, $\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )|d\mathbf {q} |$, and many more.
$\int _{\mathbf {q} \in C}d\mathbf {q}$ denotes the total displacement along $C$, and $\int _{\mathbf {q} \in C}|d\mathbf {q} |$ denotes the total length of $C$.

#### Calculating Path Integrals

To compute a path integral, the continuous oriented curve $C$ must be parameterized. $\mathbf {q} _{C}(t)$ will denote the point along $C$ indexed by $t$ from the range $[t_{0},t_{1}]$. $\mathbf {q} _{C}(t_{0})=\mathbf {q} _{0}$ must be the starting point of $C$ and $\mathbf {q} _{C}(t_{1})=\mathbf {q} _{1}$ must be the ending point of $C$. As $t$ increases, $\mathbf {q} _{C}(t)$ must proceed along $C$ in the preferred direction. An infinitesimal change in $t$, $dt$, results in the infinitesimal displacement $d\mathbf {q} ={\frac {d\mathbf {q} _{C}}{dt}}dt$ along $C$. In the path integral $\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q}$, the differential $d\mathbf {q}$ can be replaced with ${\frac {d\mathbf {q} _{C}}{dt}}dt$ to get $\int _{t=t_{0}}^{t_{1}}\mathbf {F} (\mathbf {q} _{C}(t))\cdot {\frac {d\mathbf {q} _{C}}{dt}}dt$
As an example, consider the vector field $\mathbf {F} (x,y,z)=3\mathbf {i} -x\mathbf {j} +5y\mathbf {k}$ and the straight line curve $C$ that starts at $(1,1,1)$ and ends at $(7,-1,-2)$. $C$ can be parameterized by $\mathbf {q} _{C}(t)=(1+6t,1-2t,1-3t)$ where $t\in [0,1]$. ${\frac {d\mathbf {q} _{C}}{dt}}=6\mathbf {i} -2\mathbf {j} -3\mathbf {k}$. We can then evaluate the path integral $\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q}$ as follows:
$\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =\int _{\mathbf {q} \in C}(3\mathbf {i} -x\mathbf {j} +5y\mathbf {k} )\cdot d\mathbf {q} =\int _{t=0}^{1}(3\mathbf {i} -(1+6t)\mathbf {j} +5(1-2t)\mathbf {k} )\cdot (6\mathbf {i} -2\mathbf {j} -3\mathbf {k} )dt$
$=\int _{t=0}^{1}(18+(2+12t)+(-15+30t))dt=\int _{t=0}^{1}(5+42t)dt=(5t+21t^{2}){\bigg |}_{t=0}^{1}=26$
If a vector field $\mathbf {F}$ denotes a "force field", which returns the force on an object as a function of position, the work performed on a point mass that traverses the oriented curve $C$ is $W=\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q}$
Consider the gravitational field that surrounds a point mass of $M$ located at the origin: $\mathbf {g} (\mathbf {q} )=-{\frac {GM}{|\mathbf {q} |^{2}}}{\frac {\mathbf {q} }{|\mathbf {q} |}}$ using Newton's inverse square law. The force acting on a point mass of $m$ at position $\mathbf {q}$ is $\mathbf {F} (\mathbf {q} )=m\mathbf {g} (\mathbf {q} )=-{\frac {GMm}{|\mathbf {q} |^{2}}}{\frac {\mathbf {q} }{|\mathbf {q} |}}$. In spherical coordinates the force is $\mathbf {F} (r,\theta ,\phi )=-{\frac {GMm}{r^{2}}}{\hat {\mathbf {r} }}$ (note that ${\hat {\mathbf {r} }},{\hat {\mathbf {\theta } }},{\hat {\mathbf {\phi } }}$ are the unit length mutually orthogonal basis vectors for spherical coordinates).
Consider an arbitrary path $C$ that $m$ traverses that starts at an altitude of $r=r_{1}$ and ends at an altitude of $r=r_{2}$. The work done by the gravitational field is:
$W=\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q}$
The infinitesimal displacement $d\mathbf {q}$ is equivalent to the displacement expressed in spherical coordinates: $dr\cdot {\hat {\mathbf {r} }}+r\cdot d\theta \cdot {\hat {\mathbf {\theta } }}+r\sin \theta \cdot d\phi \cdot {\hat {\mathbf {\phi } }}$.
$W=\int _{\mathbf {q} \in C}-{\frac {GMm}{r^{2}}}{\hat {\mathbf {r} }}\cdot (dr\cdot {\hat {\mathbf {r} }}+r\cdot d\theta \cdot {\hat {\mathbf {\theta } }}+r\sin \theta \cdot d\phi \cdot {\hat {\mathbf {\phi } }})=\int _{r=r_{1}}^{r_{2}}-{\frac {GMm}{r^{2}}}dr={\frac {GMm}{r}}{\bigg |}_{r=r_{1}}^{r_{2}}=GMm\left({\frac {1}{r_{2}}}-{\frac {1}{r_{1}}}\right)$
The work is equal to the amount of gravitational potential energy lost, so one possible function for the gravitational potential energy is $\phi (r,\theta ,\phi )=-{\frac {GMm}{r}}$ or equivalently, $\phi (\mathbf {q} )=-{\frac {GMm}{|\mathbf {q} |}}$.
Consider the spiral $C$ parameterized with respect to $t$ in cylindrical coordinates by $\mathbf {q} _{C}(t)=(\rho =R,\phi =t,z=k{\frac {t}{2\pi }})$. Consider the problem of determining the spiral's length with $t$ restricted to the range $[0,2\pi ]$. An infinitesimal change of $dt$ in $t$ results in the infinitesimal displacement:
$d\mathbf {q} ={\frac {d\mathbf {q} _{C}}{dt}}dt=\left({\frac {d\rho }{dt}}{\hat {\mathbf {\rho } }}+\rho {\frac {d\phi }{dt}}{\hat {\mathbf {\phi } }}+{\frac {dz}{dt}}{\hat {\mathbf {z} }}\right)dt=\left(R{\hat {\mathbf {\phi } }}+{\frac {k}{2\pi }}{\hat {\mathbf {z} }}\right)dt$
The length of the infinitesimal displacement is $|d\mathbf {q} |={\sqrt {R^{2}+\left({\frac {k}{2\pi }}\right)^{2}}}\cdot dt$.
The length of the spiral is therefore: $\int _{\mathbf {q} \in C}|d\mathbf {q} |=\int _{t=0}^{2\pi }{\sqrt {R^{2}+\left({\frac {k}{2\pi }}\right)^{2}}}\cdot dt=2\pi {\sqrt {R^{2}+\left({\frac {k}{2\pi }}\right)^{2}}}={\sqrt {(2\pi R)^{2}+k^{2}}}$

### Surface Integrals

Given any oriented surface $\sigma$ (oriented means that the there is a preferred direction to pass through the surface), an infinitesimal portion of the surface is defined by an infinitesimal area $|dS|$, and a unit length outwards oriented normal vector $\mathbf {n}$. $\mathbf {n}$ has a length of 1 and is perpendicular to the surface of $\sigma$, while penetrating $\sigma$ in the preferred direction. The infinitesimal portion of the surface is denoted by the infinitesimal "surface vector": $\mathbf {dS} =|dS|\mathbf {n}$. If a vector field $\mathbf {F} :\mathbb {R} ^{3}\to \mathbb {R} ^{3}$ denotes a flow density, then the flow through the infinitesimal surface portion in the preferred direction is $\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS}$.
The infinitesimal "surface vector" $\mathbf {dS} =\mathbf {n} |dS|$ describes the infinitesimal surface element in a manner similar to how the infinitesimal displacement $d\mathbf {q}$ describes an infinitesimal portion of a path. More specifically, similar to how the interior points on a path do not affect the total displacement, the interior points on a surface to not affect the total surface vector.
Consider for instance two paths $C_{1}$ and $C_{2}$ that both start at point $A$, and end at point $B$. The total displacements, $\int _{\mathbf {q} \in C_{1}}d\mathbf {q}$ and $\int _{\mathbf {q} \in C_{2}}d\mathbf {q}$, are both equivalent and equal to the displacement between $A$ and $B$. Note however that the total lengths $\int _{\mathbf {q} \in C_{1}}|d\mathbf {q} |$ and $\int _{\mathbf {q} \in C_{2}}|d\mathbf {q} |$ are not necessarily equivalent.
Similarly, given two surfaces $S_{1}$ and $S_{2}$ that both share the same counter-clockwise oriented boundary $C$, the total surface vectors $\int _{\mathbf {q} \in S_{1}}\mathbf {dS}$ and $\int _{\mathbf {q} \in S_{2}}\mathbf {dS}$ are both equivalent and are a function of the boundary $C$. This implies that a surface can be freely deformed within its boundaries without changing the total surface vector. Note however that the surface areas $\int _{\mathbf {q} \in S_{1}}|\mathbf {dS} |$ and $\int _{\mathbf {q} \in S_{2}}|\mathbf {dS} |$ are not necessarily equivalent.
The fact that the total surface vectors of $S_{1}$ and $S_{2}$ are equivalent is not immediately obvious. To prove this fact, let $\mathbf {F}$ be a constant vector field. $S_{1}$ and $S_{2}$ share the same boundary, so the flux/flow of $\mathbf {F}$ through $S_{1}$ and $S_{2}$ is equivalent. The flux through $S_{1}$ is $\Phi _{1}=\int _{\mathbf {q} \in S_{1}}\mathbf {F} \cdot \mathbf {dS} =\mathbf {F} \cdot \int _{\mathbf {q} \in S_{1}}\mathbf {dS}$, and similarly for $S_{2}$ is $\Phi _{2}=\int _{\mathbf {q} \in S_{2}}\mathbf {F} \cdot \mathbf {dS} =\mathbf {F} \cdot \int _{\mathbf {q} \in S_{2}}\mathbf {dS}$. Since $\mathbf {F} \cdot \int _{\mathbf {q} \in S_{1}}\mathbf {dS} =\mathbf {F} \cdot \int _{\mathbf {q} \in S_{2}}\mathbf {dS}$ for every choice of $\mathbf {F}$, it follows that $\int _{\mathbf {q} \in S_{1}}\mathbf {dS} =\int _{\mathbf {q} \in S_{2}}\mathbf {dS}$.
The geometric significance of the total surface vector is that each component measures the area of the projection of the surface onto the plane formed by the other two dimensions. Let $\sigma$ be a surface with surface vector $\mathbf {S} =S_{x}\mathbf {i} +S_{y}\mathbf {j} +S_{z}\mathbf {k}$. It is then the case that: $S_{x}$ is the area of the projection of $\sigma$ onto the yz-plane; $S_{y}$ is the area of the projection of $\sigma$ onto the xz-plane; and $S_{z}$ is the area of the projection of $\sigma$ onto the xy-plane.
Given an oriented surface $\Sigma$, another important concept is the oriented boundary. The boundary of $\Sigma$ is an oriented curve $\partial \Sigma$ but how is the orientation chosen? If the boundary is "counter-clockwise" oriented, then the boundary must follow a counter-clockwise direction when the oriented surface normal vectors point towards the viewer. The counter-clockwise boundary also obeys the "right-hand rule": If you hold your right hand with your thumb in the direction of the surface normals (penetrating the surface in the "preferred" direction), then your fingers will wrap around in the direction of the counter-clockwise oriented boundary.
Consider the Cartesian points $(0,0,0)$; $(1,0,0)$; $(0,1,0)$; and $(0,0,1)$.
Let $\sigma _{1}$ be the surface formed by the triangular planes $\{(0,1,0),(0,0,0),(1,0,0)\}$; $\{(0,0,1),(0,0,0),(0,1,0)\}$; and $\{(1,0,0),(0,0,0),(0,0,1)\}$ where the vertices are listed in a counterclockwise direction relative to the surface normal directions. The surface vectors of each plane are respectively ${\frac {1}{2}}\mathbf {k}$; ${\frac {1}{2}}\mathbf {i}$; and ${\frac {1}{2}}\mathbf {j}$ respectively which add to a total surface vector of $\mathbf {S} _{1}={\frac {1}{2}}(\mathbf {i} +\mathbf {j} +\mathbf {k} )$.
Let $\sigma _{2}$ be the surface formed by the single triangular plane $\{(1,0,0),(0,1,0),(0,0,1)\}$ where the vertices are listed in a counterclockwise direction relative to the normal direction. It can be seen that $\sigma _{1}$ and $\sigma _{2}$ share a the common counter clockwise boundary $(1,0,0)\to (0,1,0)\to (0,0,1)$The surface vector is $\mathbf {S} _{2}={\frac {1}{2}}(\mathbf {j} -\mathbf {i} )\times (\mathbf {k} -\mathbf {i} )={\frac {1}{2}}(\mathbf {i} +\mathbf {j} +\mathbf {k} )$ which is equivalent to $\mathbf {S} _{1}$.
This example will show how moving a point that is in the interior of a "triangular mesh" does not affect the total surface vector. Consider the points $P_{0},P_{1},P_{2},\dots ,P_{n}$ where $n\geq 3$. Let the closed path $C$ be defined by the cycle $P_{1}\to P_{2}\to \dots \to P_{n}\to P_{1}$. For simplicity, $P_{n+1}=P_{1}$. For each $i=1,2,\dots ,n$, $\mathbf {v} _{i}$ will denote the displacement of $P_{i}$ relative to $P_{0}$. Like with $P_{n+1}$, $\mathbf {v} _{n+1}=\mathbf {v} _{1}$.
Let $\sigma$ denote a surface that is a "triangular mesh" comprised of the closed fan of triangles: $\{P_{2},P_{0},P_{1}\}$; $\{P_{3},P_{0},P_{2}\}$; ...; $\{P_{n},P_{0},P_{n-1}\}$; $\{P_{1},P_{0},P_{n}\}$ where the vertices of each triangle are listed in a counterclockwise direction. It can be seen that the counterclockwise boundary of $\sigma$ is $C$ and does not depend on the location of $P_{0}$. The total surface vector for $\sigma$ is:
$\mathbf {S} ={\frac {1}{2}}(\mathbf {v} _{1}\times \mathbf {v} _{2})+{\frac {1}{2}}(\mathbf {v} _{2}\times \mathbf {v} _{3})+\dots +{\frac {1}{2}}(\mathbf {v} _{n-1}\times \mathbf {v} _{n})+{\frac {1}{2}}(\mathbf {v} _{n}\times \mathbf {v} _{n+1})={\frac {1}{2}}\sum _{i=1}^{n}(\mathbf {v} _{i}\times \mathbf {v} _{i+1})$
Now displace $P_{0}$ by $\mathbf {w}$ to get $P'_{0}$. The displacement vector of $P_{i}$ relative to $P_{0}'$ becomes $\mathbf {v} '_{i}=\mathbf {v} _{i}-\mathbf {w}$. The counterclockwise boundary is unaffected. The total surface vector is:
$\mathbf {S} '={\frac {1}{2}}\sum _{i=1}^{n}(\mathbf {v} '_{i}\times \mathbf {v} '_{i+1})={\frac {1}{2}}\sum _{i=1}^{n}((\mathbf {v} _{i}-\mathbf {w} )\times (\mathbf {v} _{i+1}-\mathbf {w} ))={\frac {1}{2}}\sum _{i=1}^{n}((\mathbf {v} _{i}\times \mathbf {v} _{i+1})-(\mathbf {v} _{i}\times \mathbf {w} )-(\mathbf {w} \times \mathbf {v} _{i+1})+(\mathbf {w} \times \mathbf {w} ))$
$={\frac {1}{2}}\sum _{i=1}^{n}((\mathbf {v} _{i}\times \mathbf {v} _{i+1})-\mathbf {w} \times (\mathbf {v} _{i+1}-\mathbf {v} _{i}))=\mathbf {S} -{\frac {1}{2}}\mathbf {w} \times (\mathbf {v} _{n+1}-\mathbf {v} _{1})=\mathbf {S} -{\frac {1}{2}}\mathbf {w} \times \mathbf {0} =\mathbf {S}$
Therefore moving the interior point $P_{0}$ neither affects the boundary, nor the total surface vector.

#### Calculating Surface Integrals

To calculate a surface integral, the oriented surface $\sigma$ must be parameterized. Let $\mathbf {q} _{\sigma }(u,v)$ be a continuous function that maps each point $(u,v)$ from a two-dimensional domain $D_{u,v}$ to a point in $\sigma$. $\mathbf {q} _{\sigma }(u,v)$ must be continuous and onto. While $\mathbf {q} _{\sigma }(u,v)$ does not necessarily have to be one to one, the parameterization should never "fold back" on itself. The infinitesimal increases in $u$ and $v$ are respectively $du$ and $dv$. These respectively give rise to the displacements ${\frac {\partial \mathbf {q} _{\sigma }}{\partial u}}du$ and ${\frac {\partial \mathbf {q} _{\sigma }}{\partial v}}dv$. Assuming that the surface's orientation follows the right hand rule with respect to the displacements ${\frac {\partial \mathbf {q} _{\sigma }}{\partial u}}du$ and ${\frac {\partial \mathbf {q} _{\sigma }}{\partial v}}dv$, the surface vector that arises is $\mathbf {dS} =({\frac {\partial \mathbf {q} _{\sigma }}{\partial u}}\times {\frac {\partial \mathbf {q} _{\sigma }}{\partial v}})dudv$.
In the surface integral $\iint _{\mathbf {q} \in \sigma }\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS}$, the differential $\mathbf {dS}$ can be replaced with $({\frac {\partial \mathbf {q} _{\sigma }}{\partial u}}\times {\frac {\partial \mathbf {q} _{\sigma }}{\partial v}})dudv$ to get $\iint _{(u,v)\in D_{u,v}}\mathbf {F} (\mathbf {q} _{\sigma }(u,v))\cdot ({\frac {\partial \mathbf {q} _{\sigma }}{\partial u}}\times {\frac {\partial \mathbf {q} _{\sigma }}{\partial v}})dudv$.
Consider the problem of computing the surface area of a sphere of radius $R$.
Center the sphere $\sigma$ on the origin, and using $u$ and $v$ as the parameter variables, the sphere can be parameterized in spherical coordinates via $\mathbf {q} _{\sigma }(u,v)=(r=R,\theta =u,\phi =v)$ where $u\in [0,\pi ]$ and $v\in [-\pi ,+\pi ]$. The infinitesimal displacements from small changes in the parameters are:
$du$ causes ${\frac {\partial \mathbf {q} _{\sigma }}{\partial u}}du=({\frac {\partial r}{\partial u}}{\hat {\mathbf {r} }}+r{\frac {\partial \theta }{\partial u}}{\hat {\mathbf {\theta } }}+r\sin \theta {\frac {\partial \phi }{\partial u}}{\hat {\mathbf {\phi } }})du=(R{\hat {\mathbf {\theta } }})du$
$dv$ causes ${\frac {\partial \mathbf {q} _{\sigma }}{\partial v}}dv=({\frac {\partial r}{\partial v}}{\hat {\mathbf {r} }}+r{\frac {\partial \theta }{\partial v}}{\hat {\mathbf {\theta } }}+r\sin \theta {\frac {\partial \phi }{\partial v}}{\hat {\mathbf {\phi } }})dv=(R\sin(u){\hat {\mathbf {\phi } }})dv$
The infinitesimal surface vector is hence $\mathbf {dS} =(R{\hat {\mathbf {\theta } }})du\times (R\sin(u){\hat {\mathbf {\phi } }})dv=(R^{2}\sin(u){\hat {\mathbf {r} }})dudv$. While not important to this example, note how the parameterization was chosen so that the surface vector points outwards. The area is $|\mathbf {dS} |=R^{2}\sin(u)dudv$.
The total surface area is hence:
$\iint _{\mathbf {q} \in \sigma }|\mathbf {dS} |=\int _{u=0}^{\pi }\int _{v=-\pi }^{+\pi }R^{2}\sin(u)dvdu=2\pi R^{2}\int _{u=0}^{\pi }\sin(u)du=2\pi R^{2}(-\cos(u){\bigg |}_{u=0}^{\pi })=4\pi R^{2}$

## The Gradient and Directional Derivatives

Given a scalar field $\phi :\mathbb {R} ^{3}\to \mathbb {R}$ that denotes a potential, and given a curve $C$, a commonly sought after quantity is the rate of change in $\phi$ as $C$ is being traversed. Let $t$ be an arbitrary parameter for $C$, and let $\mathbf {q} _{C}(t)=(x(t),y(t),z(t))$ denote the point indexed by $t$. Given an arbitrary $t=t_{0}$ which corresponds to the point $\mathbf {q} _{C}(t_{0})=\mathbf {q} _{0}=(x_{0},y_{0},z_{0})$, then using the chain rule gives the following expression for the rate of increase of $\phi$ at $t=t_{0}$, ${\frac {d\phi }{dt}}{\bigg |}_{t_{0}}$:
${\frac {d\phi }{dt}}{\bigg |}_{t_{0}}={\frac {\partial \phi }{\partial x}}{\bigg |}_{\mathbf {q} _{0}}{\frac {dx}{dt}}{\bigg |}_{t_{0}}+{\frac {\partial \phi }{\partial y}}{\bigg |}_{\mathbf {q} _{0}}{\frac {dy}{dt}}{\bigg |}_{t_{0}}+{\frac {\partial \phi }{\partial z}}{\bigg |}_{\mathbf {q} _{0}}{\frac {dz}{dt}}{\bigg |}_{t_{0}}=(\nabla \phi )|_{\mathbf {q} _{0}}\cdot \mathbf {v} |_{t_{0}}$
where $\nabla \phi ={\frac {\partial \phi }{\partial x}}\mathbf {i} +{\frac {\partial \phi }{\partial y}}\mathbf {j} +{\frac {\partial \phi }{\partial z}}\mathbf {k}$ is a vector field that denotes the "gradient" of $\phi$, and $\mathbf {v} ={\frac {dx}{dt}}\mathbf {i} +{\frac {dy}{dt}}\mathbf {j} +{\frac {dz}{dt}}\mathbf {k}$ is the unnormalized tangent of $C$.
If $t$ is an arc-length parameter, i.e. $\left|\mathbf {v} \right|=1$, then the direction of the gradient is the direction of maximum gain: Given any unit length tangent $\mathbf {v}$, the direction $\mathbf {v} ={\frac {\nabla \phi }{|\nabla \phi |}}$ will maximize the rate of increase in $\phi$. This maximum rate of increase is $|\nabla \phi |$.

### Calculating total gain

Given the gradient of a scalar field $\phi$: $\nabla \phi$, the difference between $\phi$ at two different points can be calculated, provided that there is a continuous path that links the two points. Let $C$ denote an arbitrary continuous path that starts at point $\mathbf {q} _{0}$ and ends at point $\mathbf {q} _{1}$. Given an infinitesimal path segment $P$ with endpoints $\mathbf {q} _{l}$ and $\mathbf {q} _{u}$, let $\mathbf {q} _{c}\in P$ be an arbitrary point in $P$. $\Delta \mathbf {q} =\mathbf {q} _{u}-\mathbf {q} _{l}$ denotes the infinitesimal displacement denoted by $P$. The increase in $\phi$ along $P$ is:
$\phi (\mathbf {q} _{u})-\phi (\mathbf {q} _{l})\approx (\nabla \phi )|_{\mathbf {q} _{c}}\cdot \Delta \mathbf {q}$
The relative error in the approximations vanish as $\Delta \mathbf {q} \rightarrow \mathbf {0}$. Adding together the above equation over all infinitesimal path segments of $C$ yields the following path integral equation:
$\phi (\mathbf {q} _{1})-\phi (\mathbf {q} _{0})=\int _{\mathbf {q} \in C}(\nabla \phi )|_{\mathbf {q} }\cdot d\mathbf {q}$
This is the path integral analog of the fundamental theorem of calculus.

### The gradient in cylindrical coordinates

Let $f:\mathbb {R} ^{3}\to \mathbb {R}$ be a scalar field that denotes a potential and a curve $C$ that is parameterized by $t$: $\mathbf {q} _{C}(t)=(\rho (t),\phi (t),z(t))$. Let the rate of change in $\mathbf {q} _{C}(t)$ be quantified by the vector ${\frac {d\mathbf {q} _{C}}{dt}}={\frac {d\rho }{dt}}{\hat {\mathbf {\rho } }}+\rho {\frac {d\phi }{dt}}{\hat {\mathbf {\phi } }}+{\frac {dz}{dt}}{\hat {\mathbf {z} }}=v_{\rho }{\hat {\mathbf {\rho } }}+v_{\phi }{\hat {\mathbf {\phi } }}+v_{z}{\hat {\mathbf {z} }}$. The rate of change in $f$ is:
${\frac {df}{dt}}={\frac {\partial f}{\partial \rho }}{\frac {d\rho }{dt}}+{\frac {\partial f}{\partial \phi }}{\frac {d\phi }{dt}}+{\frac {\partial f}{\partial z}}{\frac {dz}{dt}}={\frac {\partial f}{\partial \rho }}v_{\rho }+{\frac {\partial f}{\partial \phi }}{\frac {v_{\phi }}{\rho }}+{\frac {\partial f}{\partial z}}v_{z}=\left({\frac {\partial f}{\partial \rho }}{\hat {\mathbf {\rho } }}+{\frac {1}{\rho }}{\frac {\partial f}{\partial \phi }}{\hat {\mathbf {\phi } }}+{\frac {\partial f}{\partial z}}{\hat {\mathbf {z} }}\right)\cdot (v_{\rho }{\hat {\mathbf {\rho } }}+v_{\phi }{\hat {\mathbf {\phi } }}+v_{z}{\hat {\mathbf {z} }})=(\nabla f)\cdot {\frac {d\mathbf {q} _{C}}{dt}}$
Therefore in cylindrical coordinates, the gradient is: $\nabla f={\frac {\partial f}{\partial \rho }}{\hat {\mathbf {\rho } }}+{\frac {1}{\rho }}{\frac {\partial f}{\partial \phi }}{\hat {\mathbf {\phi } }}+{\frac {\partial f}{\partial z}}{\hat {\mathbf {z} }}$

### The gradient in spherical coordinates

Let $f:\mathbb {R} ^{3}\to \mathbb {R}$ be a scalar field that denotes a potential and a curve $C$ that is parameterized by $t$: $\mathbf {q} _{C}(t)=(r(t),\theta (t),\phi (t))$. Let the rate of change in $\mathbf {q} _{C}(t)$ be quantified by the vector ${\frac {d\mathbf {q} _{C}}{dt}}={\frac {dr}{dt}}{\hat {\mathbf {r} }}+r{\frac {d\theta }{dt}}{\hat {\mathbf {\theta } }}+r\sin \theta {\frac {d\phi }{dt}}{\hat {\mathbf {\phi } }}=v_{r}{\hat {\mathbf {r} }}+v_{\theta }{\hat {\mathbf {\theta } }}+v_{\phi }{\hat {\mathbf {\phi } }}$. The rate of change in $f$ is:
${\frac {df}{dt}}={\frac {\partial f}{\partial r}}{\frac {dr}{dt}}+{\frac {\partial f}{\partial \theta }}{\frac {d\theta }{dt}}+{\frac {\partial f}{\partial \phi }}{\frac {d\phi }{dt}}={\frac {\partial f}{\partial r}}v_{r}+{\frac {\partial f}{\partial \theta }}{\frac {v_{\theta }}{r}}+{\frac {\partial f}{\partial \phi }}{\frac {v_{\phi }}{r\sin \theta }}=\left({\frac {\partial f}{\partial r}}{\hat {\mathbf {r} }}+{\frac {1}{r}}{\frac {\partial f}{\partial \theta }}{\hat {\mathbf {\theta } }}+{\frac {1}{r\sin \theta }}{\frac {\partial f}{\partial \phi }}{\hat {\mathbf {\phi } }}\right)\cdot (v_{r}{\hat {\mathbf {r} }}+v_{\theta }{\hat {\mathbf {\theta } }}+v_{\phi }{\hat {\phi }})=(\nabla f)\cdot {\frac {d\mathbf {q} _{C}}{dt}}$
Therefore in spherical coordinates, the gradient is: $\nabla f={\frac {\partial f}{\partial r}}{\hat {\mathbf {r} }}+{\frac {1}{r}}{\frac {\partial f}{\partial \theta }}{\hat {\mathbf {\theta } }}+{\frac {1}{r\sin \theta }}{\frac {\partial f}{\partial \phi }}{\hat {\mathbf {\phi } }}$

### The Directional Derivative

Given a scalar field $f$ and a vector $\mathbf {v}$, scalar field $g=\mathbf {v} \cdot (\nabla f)$ computes the rate of change in $f$ at each position $\mathbf {q}$ where the velocity of $\mathbf {q}$ is ${\frac {d\mathbf {q} }{dt}}=\mathbf {v}$. Scalar field $g$ can also be expressed as $g=(\mathbf {v} \cdot \nabla )f$. Velocity $\mathbf {v}$ can also be a vector field $\mathbf {V}$ so ${\frac {d\mathbf {q} }{dt}}$ depends on the position $\mathbf {q}$. Scalar field $g$ becomes $g=(\mathbf {V} \cdot \nabla )f$.
In Cartesian coordinates where $\mathbf {V} =v_{x}\mathbf {i} +v_{y}\mathbf {j} +v_{z}\mathbf {k}$ the directional derivative is:
$(\mathbf {V} \cdot \nabla )f=v_{x}{\frac {\partial f}{\partial x}}+v_{y}{\frac {\partial f}{\partial y}}+v_{z}{\frac {\partial f}{\partial z}}$
In cylindrical coordinates where $\mathbf {V} =v_{\rho }{\hat {\mathbf {\rho } }}+v_{\phi }{\hat {\mathbf {\phi } }}+v_{z}{\hat {\mathbf {z} }}$ the directional derivative is:
$(\mathbf {V} \cdot \nabla )f=v_{\rho }{\frac {\partial f}{\partial \rho }}+{\frac {v_{\phi }}{\rho }}{\frac {\partial f}{\partial \phi }}+v_{z}{\frac {\partial f}{\partial z}}$
In spherical coordinates where $\mathbf {V} =v_{r}{\hat {\mathbf {r} }}+v_{\theta }{\hat {\mathbf {\theta } }}+v_{\phi }{\hat {\mathbf {\phi } }}$ the directional derivative is:
$(\mathbf {V} \cdot \nabla )f=v_{r}{\frac {\partial f}{\partial r}}+{\frac {v_{\theta }}{r}}{\frac {\partial f}{\partial \theta }}+{\frac {v_{\phi }}{r\sin \theta }}{\frac {\partial f}{\partial \phi }}$
What makes the discussion of directional derivatives nontrivial is the fact that $f$ can instead be a vector field $\mathbf {F}$. Vector field $\mathbf {G} =(\mathbf {V} \cdot \nabla )\mathbf {F}$ computes ${\frac {d\mathbf {F} }{dt}}$ at each position $\mathbf {q}$ where ${\frac {d\mathbf {q} }{dt}}=\mathbf {V} (\mathbf {q} )$.
In cylindrical coordinates, basis vectors ${\hat {\mathbf {\rho } }}$ and ${\hat {\mathbf {\phi } }}$ are not fixed, and in spherical coordinates, all of the basis vectors ${\hat {\mathbf {r} }}$, ${\hat {\mathbf {\theta } }}$, and ${\hat {\mathbf {\phi } }}$ are not fixed. This makes determining the directional derivative of a vector field that is expressed using the cylindrical or spherical basis vectors non-trivial. To directly compute the directional derivative, the rates of change of each basis vector with respect to each coordinate should be used. Alternatively, the following identities related to the directional derivative can be used (proofs can be found here):
Given vector fields $\mathbf {V}$, $\mathbf {F}$, and $\mathbf {G}$, then $(\mathbf {V} \cdot \nabla )(\mathbf {F} +\mathbf {G} )=(\mathbf {V} \cdot \nabla )\mathbf {F} +(\mathbf {V} \cdot \nabla )\mathbf {G}$
Given vector fields $\mathbf {V}$ and $\mathbf {G}$, and scalar field $f$, then $(\mathbf {V} \cdot \nabla )(f\mathbf {G} )=((\mathbf {V} \cdot \nabla )f)\mathbf {G} +f((\mathbf {V} \cdot \nabla )\mathbf {G} )$
In cylindrical coordinates, $((v_{\rho }{\hat {\mathbf {\rho } }}+v_{\phi }{\hat {\mathbf {\phi } }}+v_{z}{\hat {\mathbf {z} }})\cdot \nabla ){\hat {\mathbf {\rho } }}={\frac {v_{\phi }}{\rho }}{\hat {\mathbf {\phi } }}$ and $((v_{\rho }{\hat {\mathbf {\rho } }}+v_{\phi }{\hat {\mathbf {\phi } }}+v_{z}{\hat {\mathbf {z} }})\cdot \nabla ){\hat {\mathbf {\phi } }}=-{\frac {v_{\phi }}{\rho }}{\hat {\mathbf {\rho } }}$
In spherical coordinates, $((v_{r}{\hat {\mathbf {r} }}+v_{\theta }{\hat {\mathbf {\theta } }}+v_{\phi }{\hat {\mathbf {\phi } }})\cdot \nabla ){\hat {\mathbf {r} }}={\frac {1}{r}}(v_{\theta }{\hat {\mathbf {\theta } }}+v_{\phi }{\hat {\mathbf {\phi } }})$, and $((v_{r}{\hat {\mathbf {r} }}+v_{\theta }{\hat {\mathbf {\theta } }}+v_{\phi }{\hat {\mathbf {\phi } }})\cdot \nabla ){\hat {\mathbf {\theta } }}={\frac {1}{r}}(-v_{\theta }{\hat {\mathbf {r} }}+\cot \theta v_{\phi }{\hat {\mathbf {\phi } }})$, and $((v_{r}{\hat {\mathbf {r} }}+v_{\theta }{\hat {\mathbf {\theta } }}+v_{\phi }{\hat {\mathbf {\phi } }})\cdot \nabla ){\hat {\mathbf {\phi } }}=-{\frac {v_{\phi }}{r\sin \theta }}(\sin \theta {\hat {\mathbf {r} }}+\cos \theta {\hat {\mathbf {\theta } }})$
In Cartesian coordinates where $\mathbf {F} =F_{x}\mathbf {i} +F_{y}\mathbf {j} +F_{z}\mathbf {k}$ and $\mathbf {V} =v_{x}\mathbf {i} +v_{y}\mathbf {j} +v_{z}\mathbf {k}$ the directional derivative is:
$\mathbf {G} =(\mathbf {V} \cdot \nabla )\mathbf {F}$ $=(v_{x}{\frac {\partial }{\partial x}}+v_{y}{\frac {\partial }{\partial y}}+v_{z}{\frac {\partial }{\partial z}})(F_{x}\mathbf {i} +F_{y}\mathbf {j} +F_{z}\mathbf {k} )$ $=(v_{x}{\frac {\partial F_{x}}{\partial x}}+v_{y}{\frac {\partial F_{x}}{\partial y}}+v_{z}{\frac {\partial F_{x}}{\partial z}})\mathbf {i} +(v_{x}{\frac {\partial F_{y}}{\partial x}}+v_{y}{\frac {\partial F_{y}}{\partial y}}+v_{z}{\frac {\partial F_{y}}{\partial z}})\mathbf {j} +(v_{x}{\frac {\partial F_{z}}{\partial x}}+v_{y}{\frac {\partial F_{z}}{\partial y}}+v_{z}{\frac {\partial F_{z}}{\partial z}})\mathbf {k}$
In cylindrical coordinates where $\mathbf {F} =F_{\rho }{\hat {\mathbf {\rho } }}+F_{\phi }{\hat {\mathbf {\phi } }}+F_{z}{\hat {\mathbf {z} }}$ and $\mathbf {V} =v_{\rho }{\hat {\mathbf {\rho } }}+v_{\phi }{\hat {\mathbf {\phi } }}+v_{z}{\hat {\mathbf {z} }}$ the directional derivative is:
$\mathbf {G} =(\mathbf {V} \cdot \nabla )\mathbf {F}$ $=(v_{\rho }{\frac {\partial }{\partial \rho }}+{\frac {v_{\phi }}{\rho }}{\frac {\partial }{\partial \phi }}+v_{z}{\frac {\partial }{\partial z}})(F_{\rho }{\hat {\mathbf {\rho } }}+F_{\phi }{\hat {\mathbf {\phi } }}+F_{z}{\hat {\mathbf {z} }})$
$=(v_{\rho }{\frac {\partial F_{\rho }}{\partial \rho }}{\hat {\mathbf {\rho } }}+{\frac {v_{\phi }}{\rho }}({\frac {\partial F_{\rho }}{\partial \phi }}{\hat {\mathbf {\rho } }}+F_{\rho }{\hat {\mathbf {\phi } }})+v_{z}{\frac {\partial F_{\rho }}{\partial z}}{\hat {\mathbf {\rho } }})+(v_{\rho }{\frac {\partial F_{\phi }}{\partial \rho }}{\hat {\mathbf {\phi } }}+{\frac {v_{\phi }}{\rho }}({\frac {\partial F_{\phi }}{\partial \phi }}{\hat {\mathbf {\phi } }}+F_{\phi }(-{\hat {\mathbf {\rho } }}))+v_{z}{\frac {\partial F_{\phi }}{\partial z}}{\hat {\mathbf {\phi } }})+(v_{\rho }{\frac {\partial F_{z}}{\partial \rho }}{\hat {\mathbf {z} }}+{\frac {v_{\phi }}{\rho }}{\frac {\partial F_{z}}{\partial \phi }}{\hat {\mathbf {z} }}+v_{z}{\frac {\partial F_{z}}{\partial z}}{\hat {\mathbf {z} }})$
$=(v_{\rho }{\frac {\partial F_{\rho }}{\partial \rho }}+{\frac {v_{\phi }}{\rho }}({\frac {\partial F_{\rho }}{\partial \phi }}-F_{\phi })+v_{z}{\frac {\partial F_{\rho }}{\partial z}}){\hat {\mathbf {\rho } }}+(v_{\rho }{\frac {\partial F_{\phi }}{\partial \rho }}+{\frac {v_{\phi }}{\rho }}({\frac {\partial F_{\phi }}{\partial \phi }}+F_{\rho })+v_{z}{\frac {\partial F_{\phi }}{\partial z}}){\hat {\mathbf {\phi } }}+(v_{\rho }{\frac {\partial F_{z}}{\partial \rho }}+{\frac {v_{\phi }}{\rho }}{\frac {\partial F_{z}}{\partial \phi }}+v_{z}{\frac {\partial F_{z}}{\partial z}}){\hat {\mathbf {z} }}$
In spherical coordinates where $\mathbf {F} =F_{r}{\hat {\mathbf {r} }}+F_{\theta }{\hat {\mathbf {\theta } }}+F_{\phi }{\hat {\mathbf {\phi } }}$ and $\mathbf {V} =v_{r}{\hat {\mathbf {r} }}+v_{\theta }{\hat {\mathbf {\theta } }}+v_{\phi }{\hat {\mathbf {\phi } }}$ the directional derivative is:
$\mathbf {G} =(\mathbf {V} \cdot \nabla )\mathbf {F}$ $=(v_{r}{\frac {\partial }{\partial r}}+{\frac {v_{\theta }}{r}}{\frac {\partial }{\partial \theta }}+{\frac {v_{\phi }}{r\sin \theta }}{\frac {\partial }{\partial \phi }})(F_{r}{\hat {\mathbf {r} }}+F_{\theta }{\hat {\mathbf {\theta } }}+F_{\phi }{\hat {\mathbf {\phi } }})$
$=(v_{r}{\frac {\partial F_{r}}{\partial r}}{\hat {\mathbf {r} }}+{\frac {v_{\theta }}{r}}({\frac {\partial F_{r}}{\partial \theta }}{\hat {\mathbf {r} }}+F_{r}{\hat {\mathbf {\theta } }})+{\frac {v_{\phi }}{r\sin \theta }}({\frac {\partial F_{r}}{\partial \phi }}{\hat {\mathbf {r} }}+F_{r}\sin \theta {\hat {\mathbf {\phi } }}))$ $+(v_{r}{\frac {\partial F_{\theta }}{\partial r}}{\hat {\mathbf {\theta } }}+{\frac {v_{\theta }}{r}}({\frac {\partial F_{\theta }}{\partial \theta }}{\hat {\mathbf {\theta } }}+F_{\theta }(-{\hat {\mathbf {r} }}))+{\frac {v_{\phi }}{r\sin \theta }}({\frac {\partial F_{\theta }}{\partial \phi }}{\hat {\mathbf {\theta } }}+F_{\theta }\cos \theta {\hat {\mathbf {\phi } }}))$ $+(v_{r}{\frac {\partial F_{\phi }}{\partial r}}{\hat {\mathbf {\phi } }}+{\frac {v_{\theta }}{r}}{\frac {\partial F_{\phi }}{\partial \theta }}{\hat {\mathbf {\phi } }}+{\frac {v_{\phi }}{r\sin \theta }}({\frac {\partial F_{\phi }}{\partial \phi }}{\hat {\mathbf {\phi } }}+F_{\phi }(-\sin \theta {\hat {\mathbf {r} }}-\cos \theta {\hat {\mathbf {\theta } }})))$
$=(v_{r}{\frac {\partial F_{r}}{\partial r}}+{\frac {v_{\theta }}{r}}({\frac {\partial F_{r}}{\partial \theta }}-F_{\theta })+{\frac {v_{\phi }}{r\sin \theta }}({\frac {\partial F_{r}}{\partial \phi }}-F_{\phi }\sin \theta )){\hat {\mathbf {r} }}$ $+(v_{r}{\frac {\partial F_{\theta }}{\partial r}}+{\frac {v_{\theta }}{r}}({\frac {\partial F_{\theta }}{\partial \theta }}+F_{r})+{\frac {v_{\phi }}{r\sin \theta }}({\frac {\partial F_{\theta }}{\partial \phi }}-F_{\phi }\cos \theta )){\hat {\mathbf {\theta } }}$ $+(v_{r}{\frac {\partial F_{\phi }}{\partial r}}+{\frac {v_{\theta }}{r}}{\frac {\partial F_{\phi }}{\partial \theta }}+{\frac {v_{\phi }}{r\sin \theta }}({\frac {\partial F_{\phi }}{\partial \phi }}+F_{r}\sin \theta +F_{\theta }\cos \theta )){\hat {\mathbf {\phi } }}$

## The Divergence and Gauss's Divergence Theorem

Let $\mathbf {F} =F_{x}\mathbf {i} +F_{y}\mathbf {j} +F_{z}\mathbf {k}$ denote a vector field that denotes "flow density". For any infinitesimal surface vector $\mathbf {dS} =dS_{x}\mathbf {i} +dS_{y}\mathbf {j} +dS_{z}\mathbf {k}$ at position $\mathbf {q}$, the flow through $\mathbf {dS}$ in the preferred direction is $\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} =F_{x}(\mathbf {q} )dS_{x}+F_{y}(\mathbf {q} )dS_{y}+F_{z}(\mathbf {q} )dS_{z}$. $F_{x}$ is the flow density parallel to the x-axis etc.
Given a volume $\Omega$ with a closed surface boundary $\partial \Omega$ with an outwards orientation, the total outwards flow/flux through $\partial \Omega$ is given by the surface integral $\iint _{\mathbf {q} \in \partial \Omega }\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS}$. This outwards flow is equal to the total flow that is being generated in the interior of $\Omega$.
For an infinitesimal rectangular prism $R=[x_{l},x_{u}]\times [y_{l},y_{u}]\times [z_{l},z_{u}]$ ($\Delta x=x_{u}-x_{l}$, $\Delta y=y_{u}-y_{l}$, and $\Delta z=z_{u}-z_{l}$) that is centered on position $(x_{c},y_{c},z_{c})$, the outwards flow through the surface $\partial R$ is:
$\iint _{\mathbf {q} \in \partial R}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} \approx$ $\mathbf {F} (x_{u},y_{c},z_{c})\cdot (\Delta y\Delta z\mathbf {i} )+\mathbf {F} (x_{l},y_{c},z_{c})\cdot (-\Delta y\Delta z\mathbf {i} )+$ $\mathbf {F} (x_{c},y_{u},z_{c})\cdot (\Delta x\Delta z\mathbf {j} )+\mathbf {F} (x_{c},y_{l},z_{c})\cdot (-\Delta x\Delta z\mathbf {j} )+$ $\mathbf {F} (x_{c},y_{c},z_{u})\cdot (\Delta x\Delta y\mathbf {k} )+\mathbf {F} (x_{c},y_{c},z_{l})\cdot (-\Delta x\Delta y\mathbf {k} )=$
${\frac {F_{x}(x_{u},y_{c},z_{c})-F_{x}(x_{l},y_{c},z_{c})}{\Delta x}}(\Delta x\Delta y\Delta z)+$ ${\frac {F_{y}(x_{c},y_{u},z_{c})-F_{y}(x_{c},y_{l},z_{c})}{\Delta y}}(\Delta x\Delta y\Delta z)+$ ${\frac {F_{z}(x_{c},y_{c},z_{u})-F_{z}(x_{c},y_{c},z_{l})}{\Delta z}}(\Delta x\Delta y\Delta z)\approx$
$\left({\frac {\partial F_{x}}{\partial x}}{\bigg |}_{(x_{c},y_{c},z_{c})}+{\frac {\partial F_{y}}{\partial y}}{\bigg |}_{(x_{c},y_{c},z_{c})}+{\frac {\partial F_{z}}{\partial z}}{\bigg |}_{(x_{c},y_{c},z_{c})}\right)\Delta x\Delta y\Delta z\approx$
$\iiint _{\mathbf {q} \in R}\left({\frac {\partial F_{x}}{\partial x}}+{\frac {\partial F_{y}}{\partial y}}+{\frac {\partial F_{z}}{\partial z}}\right)dV$
All relative errors vanish as $\Delta x,\Delta y,\Delta z\rightarrow 0^{+}$.
$\nabla \cdot \mathbf {F} ={\frac {\partial F_{x}}{\partial x}}+{\frac {\partial F_{y}}{\partial y}}+{\frac {\partial F_{z}}{\partial z}}$ is the "divergence" of $\mathbf {F}$ and is the density of "flow generation" at $(x_{c},y_{c},z_{c})$. As noted above, the total outwards flow through $\partial \Omega$ is the total flow generated inside of $\Omega$, which gives Gauss's divergence theorem:
$\iint _{\mathbf {q} \in \partial \Omega }\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} =\iiint _{\mathbf {q} \in \Omega }(\nabla \cdot \mathbf {F} )|_{\mathbf {q} }dV$
In the image to the right, an example of the total flow across a closed boundary being the total flow generated in the interior of the boundary is given. The direction of the flow across each edge is denoted by the direction of the arrows, and the rate is denoted by the number of arrows. Each node inside the boundary is labelled with the rate of flow generation at the current node. It can be checked that a net total of 2 units of flow is being drawn into the boundary, and the total rate of flow generation across all interior nodes is a net consumption of 2 units.

### The divergence in cylindrical coordinates

Let $\mathbf {F} =F_{\rho }{\hat {\mathbf {\rho } }}+F_{\phi }{\hat {\mathbf {\phi } }}+F_{z}{\hat {\mathbf {z} }}$ denote a vector field that denotes "flow density". In order to compute the divergence (flow generation density) of $\mathbf {F}$, consider an infinitesimal volume $R$ defined by all points $(\rho ,\phi ,z)$ where $\rho \in [\rho _{l},\rho _{u}]$, $\phi \in [\phi _{l},\phi _{u}]$, and $z\in [z_{l},z_{u}]$. Note that $R$ is not a rectangular prism. Let $\Delta \rho =\rho _{u}-\rho _{l}$, $\Delta \phi =\phi _{u}-\phi _{l}$, and $\Delta z=z_{u}-z_{l}$. Let $(\rho _{c},\phi _{c},z_{c})\in R$ be an arbitrary point from $R$.
The volume of $R$ is approximately $\Delta \rho \cdot \rho _{c}\Delta \phi \cdot \Delta z$. The 6 surfaces bounding $R$ are described in the following table:
| Surface | approximate area | direction | approximate flow density |
| $\rho =\rho _{u}$, $\phi \in [\phi _{l},\phi _{u}]$, $z\in [z_{l},z_{u}]$ | $\rho _{u}\Delta \phi \cdot \Delta z$ | $+{\hat {\mathbf {\rho } }}$ | $\mathbf {F} (\rho _{u},\phi _{c},z_{c})$ |
| $\rho =\rho _{l}$, $\phi \in [\phi _{l},\phi _{u}]$, $z\in [z_{l},z_{u}]$ | $\rho _{l}\Delta \phi \cdot \Delta z$ | $-{\hat {\mathbf {\rho } }}$ | $\mathbf {F} (\rho _{l},\phi _{c},z_{c})$ |
| $\rho \in [\rho _{l},\rho _{u}]$, $\phi =\phi _{u}$, $z\in [z_{l},z_{u}]$ | $\Delta \rho \cdot \Delta z$ | $+{\hat {\mathbf {\phi } }}$ | $\mathbf {F} (\rho _{c},\phi _{u},z_{c})$ |
| $\rho \in [\rho _{l},\rho _{u}]$, $\phi =\phi _{l}$, $z\in [z_{l},z_{u}]$ | $\Delta \rho \cdot \Delta z$ | $-{\hat {\mathbf {\phi } }}$ | $\mathbf {F} (\rho _{c},\phi _{l},z_{c})$ |
| $\rho \in [\rho _{l},\rho _{u}]$, $\phi \in [\phi _{l},\phi _{u}]$, $z=z_{u}$ | $\Delta \rho \cdot \rho _{c}\Delta \phi$ | $+{\hat {\mathbf {z} }}$ | $\mathbf {F} (\rho _{c},\phi _{c},z_{u})$ |
| $\rho \in [\rho _{l},\rho _{u}]$, $\phi \in [\phi _{l},\phi _{u}]$, $z=z_{l}$ | $\Delta \rho \cdot \rho _{c}\Delta \phi$ | $-{\hat {\mathbf {z} }}$ | $\mathbf {F} (\rho _{c},\phi _{c},z_{l})$ |
The total outwards flow through the surface $\partial R$ of $R$ is:
$\iint _{\mathbf {q} \in \partial R}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} \approx$ $\mathbf {F} (\rho _{u},\phi _{c},z_{c})\cdot (\rho _{u}\Delta \phi \cdot \Delta z\cdot {\hat {\mathbf {\rho } }})+\mathbf {F} (\rho _{l},\phi _{c},z_{c})\cdot (\rho _{l}\Delta \phi \cdot \Delta z\cdot -{\hat {\mathbf {\rho } }})+$ $\mathbf {F} (\rho _{c},\phi _{u},z_{c})\cdot (\Delta \rho \cdot \Delta z\cdot {\hat {\mathbf {\phi } }})+\mathbf {F} (\rho _{c},\phi _{l},z_{c})\cdot (\Delta \rho \cdot \Delta z\cdot -{\hat {\mathbf {\phi } }})+$ $\mathbf {F} (\rho _{c},\phi _{c},z_{u})\cdot (\Delta \rho \cdot \rho _{c}\Delta \phi \cdot {\hat {\mathbf {z} }})+\mathbf {F} (\rho _{c},\phi _{c},z_{l})\cdot (\Delta \rho \cdot \rho _{c}\Delta \phi \cdot -{\hat {\mathbf {z} }})=$
${\frac {\rho _{u}F_{\rho }(\rho _{u},\phi _{c},z_{c})-\rho _{l}F_{\rho }(\rho _{l},\phi _{c},z_{c})}{\Delta \rho }}(\Delta \rho \Delta \phi \Delta z)+$ ${\frac {F_{\phi }(\rho _{c},\phi _{u},z_{c})-F_{\phi }(\rho _{c},\phi _{l},z_{c})}{\Delta \phi }}(\Delta \rho \Delta \phi \Delta z)+$ $\rho _{c}{\frac {F_{z}(\rho _{c},\phi _{c},z_{u})-F_{z}(\rho _{c},\phi _{c},z_{l})}{\Delta z}}(\Delta \rho \Delta \phi \Delta z)\approx$
$\left({\frac {\partial }{\partial \rho }}(\rho F_{\rho }){\bigg |}_{(\rho _{c},\phi _{c},z_{c})}+{\frac {\partial }{\partial \phi }}(F_{\phi }){\bigg |}_{(\rho _{c},\phi _{c},z_{c})}+\rho _{c}{\frac {\partial }{\partial z}}(F_{z}){\bigg |}_{(\rho _{c},\phi _{c},z_{c})}\right)(\Delta \rho \Delta \phi \Delta z)=$
$\left({\frac {1}{\rho _{c}}}{\frac {\partial }{\partial \rho }}(\rho F_{\rho }){\bigg |}_{(\rho _{c},\phi _{c},z_{c})}+{\frac {1}{\rho _{c}}}{\frac {\partial }{\partial \phi }}(F_{\phi }){\bigg |}_{(\rho _{c},\phi _{c},z_{c})}+{\frac {\partial }{\partial z}}(F_{z}){\bigg |}_{(\rho _{c},\phi _{c},z_{c})}\right)(\Delta \rho \cdot \rho _{c}\Delta \phi \cdot \Delta z)\approx$
$\iiint _{\mathbf {q} \in R}\left({\frac {1}{\rho }}{\frac {\partial }{\partial \rho }}(\rho F_{\rho })+{\frac {1}{\rho }}{\frac {\partial }{\partial \phi }}(F_{\phi })+{\frac {\partial }{\partial z}}(F_{z})\right)dV$
All relative errors vanish as $\Delta \rho ,\Delta \phi ,\Delta z\rightarrow 0^{+}$.
The divergence (flow generation density) is therefore:
$\nabla \cdot \mathbf {F} ={\frac {1}{\rho }}{\frac {\partial }{\partial \rho }}(\rho F_{\rho })+{\frac {1}{\rho }}{\frac {\partial }{\partial \phi }}(F_{\phi })+{\frac {\partial }{\partial z}}(F_{z})$
A reader may wonder why the area of surface $\rho =\rho _{u}$, $\phi \in [\phi _{l},\phi _{u}]$, $z\in [z_{l},z_{u}]$ is approximated by $\rho _{u}\Delta \phi \cdot \Delta z$ instead of $\rho _{c}\Delta \phi \cdot \Delta z$ since the difference between $\rho _{u}$ and $\rho _{c}$ approaches 0 as $\Delta \rho \rightarrow 0^{+}$. While the absolute difference between $\rho _{u}$ and $\rho _{c}$ approaches 0 as $\Delta \rho \rightarrow 0^{+}$, the difference relative to the infinitesimal $\Delta \rho$ does not approach 0: ${\frac {\rho _{u}-\rho _{c}}{\Delta \rho }}\not \to 0$.
With respect to the surface $\rho \in [\rho _{l},\rho _{u}]$, $\phi \in [\phi _{l},\phi _{u}]$, $z=z_{u}$, the area can be approximated by $\Delta \rho \cdot \rho _{l}\Delta \phi$, $\Delta \rho \cdot \rho _{c}\Delta \phi$, or $\Delta \rho \cdot \rho _{u}\Delta \phi$ since $\Delta \rho$ is already a factor, and the differences between $\rho _{l}\Delta \rho$, $\rho _{c}\Delta \rho$, and $\rho _{u}\Delta \rho$ relative to the infinitesimal $\Delta \rho$ do approach 0 as $\Delta \rho \rightarrow 0^{+}$.

### The divergence in spherical coordinates

Let $\mathbf {F} =F_{r}{\hat {\mathbf {r} }}+F_{\theta }{\hat {\mathbf {\theta } }}+F_{\phi }{\hat {\mathbf {\phi } }}$ denote a vector field that denotes "flow density". In order to compute the divergence (flow generation density) of $\mathbf {F}$, consider an infinitesimal volume $R$ defined by all points $(r,\theta ,\phi )$ where $r\in [r_{l},r_{u}]$, $\theta \in [\theta _{l},\theta _{u}]$, and $\phi \in [\phi _{l},\phi _{u}]$. Note that $R$ is not a rectangular prism. Let $\Delta r=r_{u}-r_{l}$, $\Delta \theta =\theta _{u}-\theta _{l}$, and $\Delta \phi =\phi _{u}-\phi _{l}$. Let $(r_{c},\theta _{c},\phi _{c})\in R$ be an arbitrary point from $R$.
The volume of $R$ is approximately $\Delta r\cdot r_{c}\Delta \theta \cdot r_{c}\sin \theta _{c}\Delta \phi$. The 6 surfaces bounding $R$ are shown in the following table:
| Surface | approximate area | direction | approximate flow density |
| $r=r_{u}$, $\theta \in [\theta _{l},\theta _{u}]$, $\phi \in [\phi _{l},\phi _{u}]$ | $r_{u}\Delta \theta \cdot r_{u}\sin \theta _{c}\Delta \phi$ | $+{\hat {\mathbf {r} }}$ | $\mathbf {F} (r_{u},\theta _{c},\phi _{c})$ |
| $r=r_{l}$, $\theta \in [\theta _{l},\theta _{u}]$, $\phi \in [\phi _{l},\phi _{u}]$ | $r_{l}\Delta \theta \cdot r_{l}\sin \theta _{c}\Delta \phi$ | $-{\hat {\mathbf {r} }}$ | $\mathbf {F} (r_{l},\theta _{c},\phi _{c})$ |
| $r\in [r_{l},r_{u}]$, $\theta =\theta _{u}$, $\phi \in [\phi _{l},\phi _{u}]$ | $\Delta r\cdot r_{c}\sin \theta _{u}\Delta \phi$ | $+{\hat {\mathbf {\theta } }}$ | $\mathbf {F} (r_{c},\theta _{u},\phi _{c})$ |
| $r\in [r_{l},r_{u}]$, $\theta =\theta _{l}$, $\phi \in [\phi _{l},\phi _{u}]$ | $\Delta r\cdot r_{c}\sin \theta _{l}\Delta \phi$ | $-{\hat {\mathbf {\theta } }}$ | $\mathbf {F} (r_{c},\theta _{l},\phi _{c})$ |
| $r\in [r_{l},r_{u}]$, $\theta \in [\theta _{l},\theta _{u}]$, $\phi =\phi _{u}$ | $\Delta r\cdot r_{c}\Delta \theta$ | $+{\hat {\mathbf {\phi } }}$ | $\mathbf {F} (r_{c},\theta _{c},\phi _{u})$ |
| $r\in [r_{l},r_{u}]$, $\theta \in [\theta _{l},\theta _{u}]$, $\phi =\phi _{l}$ | $\Delta r\cdot r_{c}\Delta \theta$ | $-{\hat {\mathbf {\phi } }}$ | $\mathbf {F} (r_{c},\theta _{c},\phi _{l})$ |
The total outwards flow through the surface $\partial R$ of $R$ is:
$\iint _{\mathbf {q} \in \partial R}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} \approx$
$\mathbf {F} (r_{u},\theta _{c},\phi _{c})\cdot (r_{u}\Delta \theta \cdot r_{u}\sin \theta _{c}\Delta \phi \cdot {\hat {\mathbf {r} }})+\mathbf {F} (r_{l},\theta _{c},\phi _{c})\cdot (r_{l}\Delta \theta \cdot r_{l}\sin \theta _{c}\Delta \phi \cdot -{\hat {\mathbf {r} }})+$
$\mathbf {F} (r_{c},\theta _{u},\phi _{c})\cdot (\Delta r\cdot r_{c}\sin \theta _{u}\Delta \phi \cdot {\hat {\mathbf {\theta } }})+\mathbf {F} (r_{c},\theta _{l},\phi _{c})\cdot (\Delta r\cdot r_{c}\sin \theta _{l}\Delta \phi \cdot -{\hat {\mathbf {\theta } }})+$
$\mathbf {F} (r_{c},\theta _{c},\phi _{u})\cdot (\Delta r\cdot r_{c}\Delta \theta \cdot {\hat {\mathbf {\phi } }})+\mathbf {F} (r_{c},\theta _{c},\phi _{l})\cdot (\Delta r\cdot r_{c}\Delta \theta \cdot -{\hat {\mathbf {\phi } }})=$
$\left(\sin \theta _{c}{\frac {r_{u}^{2}F_{r}(r_{u},\theta _{c},\phi _{c})-r_{l}^{2}F_{r}(r_{l},\theta _{c},\phi _{c})}{\Delta r}}+r_{c}{\frac {\sin \theta _{u}F_{\theta }(r_{c},\theta _{u},\phi _{c})-\sin \theta _{l}F_{\theta }(r_{c},\theta _{l},\phi _{c})}{\Delta \theta }}+r_{c}{\frac {F_{\phi }(r_{c},\theta _{c},\phi _{u})-F_{\phi }(r_{c},\theta _{c},\phi _{l})}{\Delta \phi }}\right)\Delta r\Delta \theta \Delta \phi \approx$
$\left(\sin \theta _{c}{\frac {\partial }{\partial r}}(r^{2}F_{r}){\bigg |}_{(r_{c},\theta _{c},\phi _{c})}+r_{c}{\frac {\partial }{\partial \theta }}(\sin \theta F_{\theta }){\bigg |}_{(r_{c},\theta _{c},\phi _{c})}+r_{c}{\frac {\partial }{\partial \phi }}(F_{\phi }){\bigg |}_{(r_{c},\theta _{c},\phi _{c})}\right)(\Delta r\Delta \theta \Delta \phi )=$
$\left({\frac {1}{r_{c}^{2}}}{\frac {\partial }{\partial r}}(r^{2}F_{r}){\bigg |}_{(r_{c},\theta _{c},\phi _{c})}+{\frac {1}{r_{c}\sin \theta _{c}}}{\frac {\partial }{\partial \theta }}(\sin \theta F_{\theta }){\bigg |}_{(r_{c},\theta _{c},\phi _{c})}+{\frac {1}{r_{c}\sin \theta _{c}}}{\frac {\partial }{\partial \phi }}(F_{\phi }){\bigg |}_{(r_{c},\theta _{c},\phi _{c})}\right)(\Delta r\cdot r_{c}\Delta \theta \cdot r_{c}\sin \theta _{c}\Delta \phi )\approx$
$\iiint _{\mathbf {q} \in R}\left({\frac {1}{r^{2}}}{\frac {\partial }{\partial r}}(r^{2}F_{r})+{\frac {1}{r\sin \theta }}{\frac {\partial }{\partial \theta }}(\sin \theta F_{\theta })+{\frac {1}{r\sin \theta }}{\frac {\partial }{\partial \phi }}(F_{\phi })\right)dV$
All relative errors vanish as $\Delta r,\Delta \theta ,\Delta \phi \rightarrow 0^{+}$
The divergence (flow generation density) is therefore:
$\nabla \cdot \mathbf {F} ={\frac {1}{r^{2}}}{\frac {\partial }{\partial r}}(r^{2}F_{r})+{\frac {1}{r\sin \theta }}{\frac {\partial }{\partial \theta }}(\sin \theta F_{\theta })+{\frac {1}{r\sin \theta }}{\frac {\partial }{\partial \phi }}(F_{\phi })$

### Divergence free vector fields

A vector field $\mathbf {F}$ for which $\nabla \cdot \mathbf {F} =0$ is a "divergence free" vector field. $\mathbf {F}$ can also be referred to as "incompressible" (since the flow density of an incompressible fluid is divergence free) or "solenoidal" (since magnetic fields are divergence free).
A key property of a divergence free vector field $\mathbf {F}$ is that the flux of $\mathbf {F}$ through a surface is purely a function of the surface's boundary. If $\sigma _{1}$ and $\sigma _{2}$ are two surfaces which share the same counterclockwise oriented boundary $C$, then $\iint _{\mathbf {q} \in \sigma _{1}}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} =\iint _{\mathbf {q} \in \sigma _{2}}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS}$. In other words, the flux is purely a function of $C$. This property can be derived from Gauss's divergence theorem as follows:
To begin, it will be assumed that $\sigma _{1}$ and $\sigma _{2}$ do not intersect each other, except for at the common boundary $C$. The argument presented here easily generalizes to cases where $\sigma _{1}$ and $\sigma _{2}$ do intersect each other. Invert the orientation of $\sigma _{2}$ to get $-\sigma _{2}$ and combine $\sigma _{1}$ and $-\sigma _{2}$ to get a closed surface $\sigma _{3}=\sigma _{1}-\sigma _{2}$, stitching the surfaces together along the seam $C$. Let $\Omega$ denote the volume which is the interior of $\sigma _{3}$, and it will also be assumed that $\sigma _{3}$ is oriented outwards (which is the case if $\sigma _{1}$ is "in front" of $\sigma _{2}$).
Gauss's divergence theorem states that $\iint _{\mathbf {q} \in \sigma _{3}}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} =\iiint _{\mathbf {q} \in \Omega }(\nabla \cdot \mathbf {F} )|_{\mathbf {q} }dV=0$. The flux through $\sigma _{3}$ is the flux through $\sigma _{1}$ minus the flux through $\sigma _{2}$: $\iint _{\mathbf {q} \in \sigma _{3}}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} =\iint _{\mathbf {q} \in \sigma _{1}}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} +\iint _{\mathbf {q} \in -\sigma _{2}}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS}$ $=\iint _{\mathbf {q} \in \sigma _{1}}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} -\iint _{\mathbf {q} \in \sigma _{2}}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS}$. Therefore:
$\iint _{\mathbf {q} \in \sigma _{3}}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} =0$ $\implies \iint _{\mathbf {q} \in \sigma _{1}}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} =\iint _{\mathbf {q} \in \sigma _{2}}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS}$

## The Laplacian Operator

Given a scalar field $f$, if the gradient $\nabla f$ is interpreted as denoting flow density, the rate of flow generation at each point is $\nabla \cdot (\nabla f)$ which is referred to as the "Laplacian" of $f$ and is denoted by $\nabla ^{2}f$ (or alternately $\Delta f$).
The laplacian $\nabla ^{2}f$ is effectively a measure of the "convexity" of $f$ at each point $\mathbf {q}$. When there is a net flow of the gradient away from $\mathbf {q}$, this means that $f(\mathbf {q} )$ is "low" compared to its neighboring points and that the convexity $(\nabla ^{2}f)|_{\mathbf {q} }$ is positive. When there is a net flow of the gradient towards $\mathbf {q}$, this means that $f(\mathbf {q} )$ is "high" compared to its neighboring points and that the convexity $(\nabla ^{2}f)|_{\mathbf {q} }$ is negative.
In Cartesian coordinates, the Laplacian is:
$\nabla ^{2}f=\nabla \cdot (\nabla f)=\nabla \cdot ({\frac {\partial f}{\partial x}}\mathbf {i} +{\frac {\partial f}{\partial y}}\mathbf {j} +{\frac {\partial f}{\partial z}}\mathbf {k} )={\frac {\partial ^{2}f}{\partial x^{2}}}+{\frac {\partial ^{2}f}{\partial y^{2}}}+{\frac {\partial ^{2}f}{\partial z^{2}}}$
In cylindrical coordinates, the Laplacian is:
$\nabla ^{2}f=\nabla \cdot (\nabla f)=\nabla \cdot ({\frac {\partial f}{\partial \rho }}{\hat {\mathbf {\rho } }}+{\frac {1}{\rho }}{\frac {\partial f}{\partial \phi }}{\hat {\mathbf {\phi } }}+{\frac {\partial f}{\partial z}}{\hat {\mathbf {z} }})={\frac {1}{\rho }}{\frac {\partial }{\partial \rho }}(\rho {\frac {\partial f}{\partial \rho }})+{\frac {1}{\rho ^{2}}}{\frac {\partial ^{2}f}{\partial \phi ^{2}}}+{\frac {\partial ^{2}f}{\partial z^{2}}}$
In spherical coordinates, the Laplacian is:
$\nabla ^{2}f=\nabla \cdot (\nabla f)=\nabla \cdot ({\frac {\partial f}{\partial r}}{\hat {\mathbf {r} }}+{\frac {1}{r}}{\frac {\partial f}{\partial \theta }}{\hat {\mathbf {\theta } }}+{\frac {1}{r\sin \theta }}{\frac {\partial f}{\partial \phi }}{\hat {\mathbf {\phi } }})={\frac {1}{r^{2}}}{\frac {\partial }{\partial r}}(r^{2}{\frac {\partial f}{\partial r}})+{\frac {1}{r^{2}\sin \theta }}{\frac {\partial }{\partial \theta }}(\sin \theta {\frac {\partial f}{\partial \theta }})+{\frac {1}{r^{2}\sin ^{2}\theta }}{\frac {\partial ^{2}f}{\partial \phi ^{2}}}$

### The Laplacian and Vector fields

Occasionally, the Laplacian operator is applied to a vector field as opposed to a scalar field. Other than for Cartesian coordinates, the Laplacian cannot be applied directly to each component, as in non-Cartesian coordinate systems, the basis vectors are subject to change. In cylindrical coordinates, basis vectors ${\hat {\mathbf {\rho } }}$ and ${\hat {\mathbf {\phi } }}$ are not fixed, and in spherical coordinates, all of the basis vectors ${\hat {\mathbf {r} }}$, ${\hat {\mathbf {\theta } }}$, and ${\hat {\mathbf {\phi } }}$ are not fixed. This makes determining the Laplacian of a vector field that is expressed using the cylindrical or spherical basis vectors non-trivial. To directly compute the Laplacian, the rates of change of each basis vector with respect to each coordinate should be used. Alternatively, the following identities related to the Laplacian can be used (proofs can be found here):
Given vector fields $\mathbf {F}$ and $\mathbf {G}$, then $\nabla ^{2}(\mathbf {F} +\mathbf {G} )=\nabla ^{2}\mathbf {F} +\nabla ^{2}\mathbf {G}$
Given scalar field $f$ and vector field $\mathbf {G}$, then $\nabla ^{2}(f\mathbf {G} )=(\nabla ^{2}f)\mathbf {G} +2((\nabla f)\cdot \nabla )\mathbf {G} +f(\nabla ^{2}\mathbf {G} )$
In cylindrical coordinates, $\nabla ^{2}{\hat {\mathbf {\rho } }}=-{\frac {1}{\rho ^{2}}}{\hat {\mathbf {\rho } }}$ and $\nabla ^{2}{\hat {\mathbf {\phi } }}=-{\frac {1}{\rho ^{2}}}{\hat {\mathbf {\phi } }}$
In spherical coordinates, $\nabla ^{2}{\hat {\mathbf {r} }}=-{\frac {2}{r^{2}}}{\hat {\mathbf {r} }}$, and $\nabla ^{2}{\hat {\mathbf {\theta } }}=-{\frac {1}{r^{2}\sin ^{2}\theta }}(\sin(2\theta ){\hat {\mathbf {r} }}+{\hat {\mathbf {\theta } }})$, and $\nabla ^{2}{\hat {\mathbf {\phi } }}=-{\frac {1}{r^{2}\sin ^{2}\theta }}{\hat {\mathbf {\phi } }}$
In Cartesian coordinates where $\mathbf {F} =F_{x}\mathbf {i} +F_{y}\mathbf {j} +F_{z}\mathbf {k}$, the Laplacian is:
$\nabla ^{2}(F_{x}\mathbf {i} +F_{y}\mathbf {j} +F_{z}\mathbf {k} )=\nabla ^{2}(F_{x}\mathbf {i} )+\nabla ^{2}(F_{y}\mathbf {j} )+\nabla ^{2}(F_{z}\mathbf {k} )=(\nabla ^{2}F_{x})\mathbf {i} +(\nabla ^{2}F_{y})\mathbf {j} +(\nabla ^{2}F_{z})\mathbf {k}$
In cylindrical coordinates where $\mathbf {F} =F_{\rho }{\hat {\mathbf {\rho } }}+F_{\phi }{\hat {\mathbf {\phi } }}+F_{z}{\hat {\mathbf {z} }}$, the Laplacian is:
$\nabla ^{2}(F_{\rho }{\hat {\mathbf {\rho } }}+F_{\phi }{\hat {\mathbf {\phi } }}+F_{z}{\hat {\mathbf {z} }})=\nabla ^{2}(F_{\rho }{\hat {\mathbf {\rho } }})+\nabla ^{2}(F_{\phi }{\hat {\mathbf {\phi } }})+\nabla ^{2}(F_{z}{\hat {\mathbf {z} }})$
$=({\frac {1}{\rho }}{\frac {\partial }{\partial \rho }}(\rho {\frac {\partial }{\partial \rho }}(F_{\rho }{\hat {\mathbf {\rho } }}))+{\frac {1}{\rho ^{2}}}{\frac {\partial ^{2}}{\partial \phi ^{2}}}(F_{\rho }{\hat {\mathbf {\rho } }})+{\frac {\partial ^{2}}{\partial z^{2}}}(F_{\rho }{\hat {\mathbf {\rho } }}))$ $+({\frac {1}{\rho }}{\frac {\partial }{\partial \rho }}(\rho {\frac {\partial }{\partial \rho }}(F_{\phi }{\hat {\mathbf {\phi } }}))+{\frac {1}{\rho ^{2}}}{\frac {\partial ^{2}}{\partial \phi ^{2}}}(F_{\phi }{\hat {\mathbf {\phi } }})+{\frac {\partial ^{2}}{\partial z^{2}}}(F_{\phi }{\hat {\mathbf {\phi } }}))$ $+({\frac {1}{\rho }}{\frac {\partial }{\partial \rho }}(\rho {\frac {\partial }{\partial \rho }}(F_{z}{\hat {\mathbf {z} }}))+{\frac {1}{\rho ^{2}}}{\frac {\partial ^{2}}{\partial \phi ^{2}}}(F_{z}{\hat {\mathbf {z} }})+{\frac {\partial ^{2}}{\partial z^{2}}}(F_{z}{\hat {\mathbf {z} }}))$
$=(({\frac {1}{\rho }}{\frac {\partial }{\partial \rho }}(\rho {\frac {\partial F_{\rho }}{\partial \rho }})+{\frac {1}{\rho ^{2}}}{\frac {\partial ^{2}F_{\rho }}{\partial \phi ^{2}}}+{\frac {\partial ^{2}F_{\rho }}{\partial z^{2}}}){\hat {\mathbf {\rho } }}+{\frac {1}{\rho ^{2}}}(2{\frac {\partial F_{\rho }}{\partial \phi }}{\hat {\mathbf {\phi } }}+F_{\rho }(-{\hat {\mathbf {\rho } }})))$ $+(({\frac {1}{\rho }}{\frac {\partial }{\partial \rho }}(\rho {\frac {\partial F_{\phi }}{\partial \rho }})+{\frac {1}{\rho ^{2}}}{\frac {\partial ^{2}F_{\phi }}{\partial \phi ^{2}}}+{\frac {\partial ^{2}F_{\phi }}{\partial z^{2}}}){\hat {\mathbf {\phi } }}+{\frac {1}{\rho ^{2}}}(2{\frac {\partial F_{\phi }}{\partial \phi }}(-{\hat {\mathbf {\rho } }})+F_{\phi }(-{\hat {\mathbf {\phi } }})))$ $+({\frac {1}{\rho }}{\frac {\partial }{\partial \rho }}(\rho {\frac {\partial F_{z}}{\partial \rho }})+{\frac {1}{\rho ^{2}}}{\frac {\partial ^{2}F_{z}}{\partial \phi ^{2}}}+{\frac {\partial ^{2}F_{z}}{\partial z^{2}}}){\hat {\mathbf {z} }}$
$=((\nabla ^{2}F_{\rho })-{\frac {1}{\rho ^{2}}}(2{\frac {\partial F_{\phi }}{\partial \phi }}+F_{\rho })){\hat {\mathbf {\rho } }}+((\nabla ^{2}F_{\phi })+{\frac {1}{\rho ^{2}}}(2{\frac {\partial F_{\rho }}{\partial \phi }}-F_{\phi })){\hat {\mathbf {\phi } }}+(\nabla ^{2}F_{z}){\hat {\mathbf {z} }}$

## The Curl and Stokes' Theorem

Given a scalar field $f:\mathbb {R} ^{3}\to \mathbb {R}$ and a curve $C$ with endpoints $\mathbf {q} _{0}$ and $\mathbf {q} _{1}$, the difference between $f(\mathbf {q} _{1})$ and $f(\mathbf {q} _{0})$ is given by the following path integral involving the gradient field $\mathbf {F} =\nabla f$: $f(\mathbf {q} _{1})-f(\mathbf {q} _{0})=\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q}$. If $C$ is closed ($\mathbf {q} _{1}=\mathbf {q} _{0}$), then $\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =0$. In other words, the "gain" of $\mathbf {F} =\nabla f$ around a closed curve $C$ is always 0. Most vector fields $\mathbf {F} :\mathbb {R} ^{3}\to \mathbb {R} ^{3}$ are not the gradient of any scalar field however, and the gain of $\mathbf {F}$ around a closed curve $C$ may not always be 0. This gives rise to the notion of circulation or "curl".
The path integral $\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q}$ for a closed curve $C$ is the "circulation" of $\mathbf {F}$ around $C$. Stokes' theorem will show that the circulation around $C$ is the total circulation accumulated in the interior of $C$.

### Green's Theorem

Quantifying "circulation density" is best introduced in 2 dimensions. Given a large counter-clockwise oriented loop $C$ that is confined to 2 dimensions, $C$ can be decomposed into a family of infinitesimal loops as shown on the right. Boundaries that are common to adjacent loops cancel each other out due to their opposite orientations, so the total circulation around $C$ is the sum of the circulations around each infinitesimal loop.
Consider the infinitesimal rectangle $R=[x_{l},x_{u}]\times [y_{l},y_{u}]$. Let $(x_{c},y_{c})\in R$ be an arbitrary point inside the rectangle, let $\Delta x=x_{u}-x_{l}$ and $\Delta y=y_{u}-y_{l}$, and let $\partial R$ be the counterclockwise boundary of $R$.
The circulation around $\partial R$ is approximately (the relative error vanishes as $\Delta x,\Delta y\rightarrow 0^{+}$):
$\int _{\mathbf {q} \in \partial R}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} \approx \mathbf {F} (x_{u},y_{c})\cdot (+\Delta y\mathbf {j} )+\mathbf {F} (x_{c},y_{u})\cdot (-\Delta x\mathbf {i} )+\mathbf {F} (x_{l},y_{c})\cdot (-\Delta y\mathbf {j} )+\mathbf {F} (x_{c},y_{l})\cdot (+\Delta x\mathbf {i} )$ $=F_{y}(x_{u},y_{c})\Delta y-F_{x}(x_{c},y_{u})\Delta x-F_{y}(x_{l},y_{c})\Delta y+F_{x}(x_{c},y_{l})\Delta x$ $=\left({\frac {F_{y}(x_{u},y_{c})-F_{y}(x_{l},y_{c})}{\Delta x}}-{\frac {F_{x}(x_{c},y_{u})-F_{x}(x_{c},y_{l})}{\Delta y}}\right)\Delta x\Delta y$ $\approx \left({\frac {\partial F_{y}}{\partial x}}{\bigg |}_{(x_{c},y_{c})}-{\frac {\partial F_{x}}{\partial y}}{\bigg |}_{(x_{c},y_{c})}\right)\Delta x\Delta y$ $\approx \iint _{R}\left({\frac {\partial F_{y}}{\partial x}}-{\frac {\partial F_{x}}{\partial y}}\right)dxdy$
As $\Delta x,\Delta y\rightarrow 0^{+}$, the relative errors present in the approximations vanish, and therefore, for an infinitesimal rectangle, $\int _{\mathbf {q} \in \partial R}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =\iint _{\mathbf {q} \in R}\left({\frac {\partial F_{y}}{\partial x}}-{\frac {\partial F_{x}}{\partial y}}\right)dxdy$
${\frac {\partial F_{y}}{\partial x}}-{\frac {\partial F_{x}}{\partial y}}$ is the "circulation density" at $(x_{c},y_{c})$. Let $C$ be a counter-clockwise oriented loop with interior $D$. The circulation around loop $C$ is the total circulation contained by $D$: $\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =\iint _{\mathbf {q} \in D}\left({\frac {\partial F_{y}}{\partial x}}-{\frac {\partial F_{x}}{\partial y}}\right)dxdy$. This is Green's theorem.

### Stokes' Theorem

Stokes' Theorem is effectively a generalization of Green's theorem to 3 dimensions, and the "curl" is a generalization of the quantity ${\frac {\partial F_{y}}{\partial x}}-{\frac {\partial F_{x}}{\partial y}}$ to 3 dimensions. An arbitrary oriented surface $\sigma$ can be articulated into a family of infinitesimal surfaces, some parallel to the xy-plane, others parallel to the zx-plane, and the remainder parallel to the yz-plane. Let $\mathbf {F}$ denote an arbitrary vector field.
Let $\sigma$ be a surface that is parallel to the yz-plane with counter-clockwise oriented boundary $C$. Green's theorem gives:
$\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =\iint _{\mathbf {q} \in \sigma }\left({\frac {\partial F_{z}}{\partial y}}-{\frac {\partial F_{y}}{\partial z}}\right)(\mathbf {dS} \cdot \mathbf {i} )=\iint _{\mathbf {q} \in \sigma }\left(\left({\frac {\partial F_{z}}{\partial y}}-{\frac {\partial F_{y}}{\partial z}}\right)\mathbf {i} \right)\cdot \mathbf {dS}$
$\mathbf {dS} \cdot \mathbf {i}$ is positive if the normal direction to $\sigma$ points in the positive x direction and is negative if otherwise. If the normal direction to $\sigma$ points in the negative x direction, then $C$ is oriented clockwise instead of counter-clockwise in the yz-plane.
Repeating this argument for $\sigma$ being parallel to the zx-plane and xy-plane respectively gives:
$\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =\iint _{\mathbf {q} \in \sigma }\left({\frac {\partial F_{x}}{\partial z}}-{\frac {\partial F_{z}}{\partial x}}\right)(\mathbf {dS} \cdot \mathbf {j} )=\iint _{\mathbf {q} \in \sigma }\left(\left({\frac {\partial F_{x}}{\partial z}}-{\frac {\partial F_{z}}{\partial x}}\right)\mathbf {j} \right)\cdot \mathbf {dS}$
and
$\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =\iint _{\mathbf {q} \in \sigma }\left({\frac {\partial F_{y}}{\partial x}}-{\frac {\partial F_{x}}{\partial y}}\right)(\mathbf {dS} \cdot \mathbf {k} )=\iint _{\mathbf {q} \in \sigma }\left(\left({\frac {\partial F_{y}}{\partial x}}-{\frac {\partial F_{x}}{\partial y}}\right)\mathbf {k} \right)\cdot \mathbf {dS}$
Treating $\sigma$ as an ensemble of infinitesimal surfaces parallel to the yz-plane, zx-plane, or xy-plane gives:
$\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =\iint _{\mathbf {q} \in \sigma }\left(\left({\frac {\partial F_{z}}{\partial y}}-{\frac {\partial F_{y}}{\partial z}}\right)\mathbf {i} +\left({\frac {\partial F_{x}}{\partial z}}-{\frac {\partial F_{z}}{\partial x}}\right)\mathbf {j} +\left({\frac {\partial F_{y}}{\partial x}}-{\frac {\partial F_{x}}{\partial y}}\right)\mathbf {k} \right)\cdot \mathbf {dS}$
This is Stokes' theorem, and $\nabla \times \mathbf {F} =\left({\frac {\partial F_{z}}{\partial y}}-{\frac {\partial F_{y}}{\partial z}}\right)\mathbf {i} +\left({\frac {\partial F_{x}}{\partial z}}-{\frac {\partial F_{z}}{\partial x}}\right)\mathbf {j} +\left({\frac {\partial F_{y}}{\partial x}}-{\frac {\partial F_{x}}{\partial y}}\right)\mathbf {k}$ is the "curl" of $\mathbf {F}$ which generalizes the "circulation density" to 3 dimensions.
The direction of $\nabla \times \mathbf {F}$ at $\mathbf {q}$ is effectively an "axis of rotation" around which the counterclockwise circulation density in a plane whose normal is parallel to $\nabla \times \mathbf {F}$ is $|\nabla \times \mathbf {F} |$. Out of all planes that pass through $\mathbf {q}$, the plane whose normal is parallel to $\nabla \times \mathbf {F}$ has the largest counterclockwise circulation density at $\mathbf {q}$ which is $|\nabla \times \mathbf {F} |$.
An arbitrary vector field $\mathbf {F}$ that is differentiable everywhere is considered to be "irrotational" or "conservative" if $\nabla \times \mathbf {F} =\mathbf {0}$ everywhere, or equivalently that $\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =0$ for all continuous closed curves $C$.

### The curl in cylindrical coordinates

Let $\mathbf {F} =F_{\rho }{\hat {\mathbf {\rho } }}+F_{\phi }{\hat {\mathbf {\phi } }}+F_{z}{\hat {\mathbf {z} }}$ denote an arbitrary vector field in cylindrical coordinates. By calculating the circulation densities in surfaces perpendicular to ${\hat {\mathbf {\rho } }}$, ${\hat {\mathbf {\phi } }}$, and ${\hat {\mathbf {z} }}$, the curl can be computed:
$\nabla \times \mathbf {F} ={\frac {1}{\rho }}({\frac {\partial }{\partial \phi }}(F_{z})-{\frac {\partial }{\partial z}}(\rho F_{\phi })){\hat {\mathbf {\rho } }}+({\frac {\partial }{\partial z}}(F_{\rho })-{\frac {\partial }{\partial \rho }}(F_{z})){\hat {\mathbf {\phi } }}+{\frac {1}{\rho }}({\frac {\partial }{\partial \rho }}(\rho F_{\phi })-{\frac {\partial }{\partial \phi }}(F_{\rho })){\hat {\mathbf {z} }}$ $=({\frac {1}{\rho }}{\frac {\partial }{\partial \phi }}(F_{z})-{\frac {\partial }{\partial z}}(F_{\phi })){\hat {\mathbf {\rho } }}+({\frac {\partial }{\partial z}}(F_{\rho })-{\frac {\partial }{\partial \rho }}(F_{z})){\hat {\mathbf {\phi } }}+{\frac {1}{\rho }}({\frac {\partial }{\partial \rho }}(\rho F_{\phi })-{\frac {\partial }{\partial \phi }}(F_{\rho })){\hat {\mathbf {z} }}$

### The curl in spherical coordinates

Let $\mathbf {F} =F_{r}{\hat {\mathbf {r} }}+F_{\theta }{\hat {\mathbf {\theta } }}+F_{\phi }{\hat {\mathbf {\phi } }}$ denote an arbitrary vector field in spherical coordinates. By calculating circulation densities in surfaces perpendicular to ${\hat {\mathbf {r} }}$, ${\hat {\mathbf {\theta } }}$, and ${\hat {\mathbf {\phi } }}$, the curl can be computed:
$\nabla \times \mathbf {F} ={\frac {1}{r^{2}\sin \theta }}({\frac {\partial }{\partial \theta }}(r\sin \theta F_{\phi })-{\frac {\partial }{\partial \phi }}(rF_{\theta })){\hat {\mathbf {r} }}+{\frac {1}{r\sin \theta }}({\frac {\partial }{\partial \phi }}(F_{r})-{\frac {\partial }{\partial r}}(r\sin \theta F_{\phi })){\hat {\mathbf {\theta } }}+{\frac {1}{r}}({\frac {\partial }{\partial r}}(rF_{\theta })-{\frac {\partial }{\partial \theta }}(F_{r})){\hat {\mathbf {\phi } }}$
$={\frac {1}{r\sin \theta }}({\frac {\partial }{\partial \theta }}(\sin \theta F_{\phi })-{\frac {\partial }{\partial \phi }}(F_{\theta })){\hat {\mathbf {r} }}+{\frac {1}{r}}({\frac {1}{\sin \theta }}{\frac {\partial }{\partial \phi }}(F_{r})-{\frac {\partial }{\partial r}}(rF_{\phi })){\hat {\mathbf {\theta } }}+{\frac {1}{r}}({\frac {\partial }{\partial r}}(rF_{\theta })-{\frac {\partial }{\partial \theta }}(F_{r})){\hat {\mathbf {\phi } }}$

### Irrotational vector fields

A vector field $\mathbf {F}$ for which $\nabla \times \mathbf {F} =\mathbf {0}$ at all points is an "irrotational" vector field. $\mathbf {F}$ can also be referred to as being "conservative" since the gain around any closed curve is always 0.
A key property of an irrotational vector field $\mathbf {F}$ is that the gain of $\mathbf {F}$ along a continuous curve is purely a function of the curve's end points. If $C_{1}$ and $C_{2}$ are two continuous curves which share the same starting point $\mathbf {q} _{0}$ and end point $\mathbf {q} _{1}$, then $\int _{\mathbf {q} \in C_{1}}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =\int _{\mathbf {q} \in C_{2}}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q}$. In other words, the gain is purely a function of $\mathbf {q} _{0}$ and $\mathbf {q} _{1}$. This property can be derived from Stokes' theorem as follows:
Invert the orientation of $C_{2}$ to get $-C_{2}$ and combine $C_{1}$ and $-C_{2}$ to get a continuous closed curve $C_{3}=C_{1}-C_{2}$, linking the curves together at the endpoints $\mathbf {q} _{0}$ and $\mathbf {q} _{1}$. Let $\sigma$ denote a surface for which $C_{3}$ is the counterclockwise oriented boundary.
Stokes' theorem states that $\int _{\mathbf {q} \in C_{3}}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =\iint _{\mathbf {q} \in \sigma }(\nabla \times \mathbf {F} )|_{\mathbf {q} }\cdot \mathbf {dS} =0$. The gain around $C_{3}$ is the gain along $C_{1}$ minus the gain along $C_{2}$: $\int _{\mathbf {q} \in C_{3}}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =\int _{\mathbf {q} \in C_{1}}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} +\int _{\mathbf {q} \in -C_{2}}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q}$ $=\int _{\mathbf {q} \in C_{1}}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} -\int _{\mathbf {q} \in C_{2}}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q}$. Therefore:
$\int _{\mathbf {q} \in C_{3}}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =0$ $\implies \int _{\mathbf {q} \in C_{1}}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =\int _{\mathbf {q} \in C_{2}}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q}$

## Summary and Extensions

In summary:
    The gradient of a scalar field $f$ is $\nabla f={\frac {\partial f}{\partial x}}\mathbf {i} +{\frac {\partial f}{\partial y}}\mathbf {j} +{\frac {\partial f}{\partial z}}\mathbf {k}$ which denotes the rate of change in $f$ in each direction, at each point.
       Given an oriented curve $C$ which starts at $\mathbf {q} _{0}$ and ends at $\mathbf {q} _{1}$, the increase in $f$ along $C$ is: $f(\mathbf {q} _{1})-f(\mathbf {q} _{0})=\int _{\mathbf {q} \in C}(\nabla f)|_{\mathbf {q} }\cdot d\mathbf {q}$ (the gradient theorem)
    If a vector field $\mathbf {F} =F_{x}\mathbf {i} +F_{y}\mathbf {j} +F_{z}\mathbf {k}$ denotes "flow density", then the divergence is $\nabla \cdot \mathbf {F} ={\frac {\partial F_{x}}{\partial x}}+{\frac {\partial F_{y}}{\partial y}}+{\frac {\partial F_{z}}{\partial z}}$ which denotes the density of "flow generation" at each point.
       Given a volume $\Omega$ with outwards oriented surface $\partial \Omega$, the total flow being generated inside $\Omega$ is: $\iint _{\mathbf {q} \in \partial \Omega }\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} =\iiint _{\mathbf {q} \in \Omega }(\nabla \cdot \mathbf {F} )|_{\mathbf {q} }dV$ (Gauss's divergence theorem)
    The curl of a vector field $\mathbf {F} =F_{x}\mathbf {i} +F_{y}\mathbf {j} +F_{z}\mathbf {k}$ is $\nabla \times \mathbf {F} =\left({\frac {\partial F_{z}}{\partial y}}-{\frac {\partial F_{y}}{\partial z}}\right)\mathbf {i} +\left({\frac {\partial F_{x}}{\partial z}}-{\frac {\partial F_{z}}{\partial x}}\right)\mathbf {j} +\left({\frac {\partial F_{y}}{\partial x}}-{\frac {\partial F_{x}}{\partial y}}\right)\mathbf {k}$ which denotes the "circulation density" at each point.
       Given an oriented surface $\sigma$ with a counter-clockwise oriented boundary $\partial \sigma$, the total circulation present in $\sigma$ is: $\int _{\mathbf {q} \in \partial \sigma }\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =\iint _{\mathbf {q} \in \sigma }(\nabla \times \mathbf {F} )|_{\mathbf {q} }\cdot \mathbf {dS}$ (Stokes' theorem)

### Extending the gradient theorem

The gradient theorem states that given an everywhere differentiable scalar field $f$ and a continuous oriented curve $C$ with endpoints $\mathbf {q} _{0}$ and $\mathbf {q} _{1}$, that $f(\mathbf {q} _{1})-f(\mathbf {q} _{0})=\int _{\mathbf {q} \in C}(\nabla f)|_{\mathbf {q} }\cdot d\mathbf {q}$. This theorem can be extended to equate a surface integral with a volume integral, as opposed to equating a difference with a path integral.
Let $\Omega$ be an arbitrary volume with outwards oriented surface $\partial \Omega$. Let $L=(x_{l},y,z)-(x_{u},y,z)$ be an arbitrary line segment parallel to the x-axis that is completely contained by $\Omega$ and that starts and ends on the surface of $\Omega$. Let this line segment have an infinitesimal cross-sectional area of $t$. The volume integral of ${\frac {\partial f}{\partial x}}$ over $L$ is: $\iiint _{\mathbf {q} \in L}{\frac {\partial f}{\partial x}}dV=t\int _{x=x_{l}}^{x_{u}}{\frac {\partial f}{\partial x}}dx=t(f(x_{u},y,z)-f(x_{l},y,z))$. Let $\mathbf {dS} _{l}$ and $\mathbf {dS} _{u}$ be the infinitesimal surface portions of $\partial \Omega$ formed when $L$ intersects $\partial \Omega$ at $(x_{l},y,z)$ and $(x_{u},y,z)$ respectively. The x-component of $\mathbf {dS} _{l}$ and $\mathbf {dS} _{u}$ is $-t$ and $t$ respectively. Adding up all possible line segments $L$ gives:
$\iiint _{\mathbf {q} \in \Omega }{\frac {\partial f}{\partial x}}dV=\iint _{\mathbf {q} \in \partial \Omega }f(\mathbf {q} )dS_{x}$ where $dS_{x}$ is the x-component of the differential $\mathbf {dS}$.
Repeating for the y-axis and z-axis gives:
$\iiint _{\mathbf {q} \in \Omega }{\frac {\partial f}{\partial y}}dV=\iint _{\mathbf {q} \in \partial \Omega }f(\mathbf {q} )dS_{y}$ where $dS_{y}$ is the y-component of the differential $\mathbf {dS}$.
$\iiint _{\mathbf {q} \in \Omega }{\frac {\partial f}{\partial z}}dV=\iint _{\mathbf {q} \in \partial \Omega }f(\mathbf {q} )dS_{z}$ where $dS_{z}$ is the z-component of the differential $\mathbf {dS}$.
This yields:
$\iiint _{\mathbf {q} \in \Omega }\left({\frac {\partial f}{\partial x}}\mathbf {i} +{\frac {\partial f}{\partial y}}\mathbf {j} +{\frac {\partial f}{\partial z}}\mathbf {k} \right)dV=\iint _{\mathbf {q} \in \partial \Omega }f(\mathbf {q} )(dS_{x}\mathbf {i} +dS_{y}\mathbf {j} +dS_{z}\mathbf {k} )$
and hence:
$\iint _{\mathbf {q} \in \partial \Omega }f(\mathbf {q} )\mathbf {dS} =\iiint _{\mathbf {q} \in \Omega }(\nabla f)|_{\mathbf {q} }dV$
The above integral equation is effectively a generalization of the gradient theorem.

### Extending Stokes' Theorem

Stokes' theorem states that given an everywhere differentiable vector field $\mathbf {F} =F_{x}\mathbf {i} +F_{y}\mathbf {j} +F_{z}\mathbf {k}$ and an oriented surface $\sigma$ with counterclockwise boundary $\partial \sigma$, that $\int _{\mathbf {q} \in \partial \sigma }\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =\iint _{\mathbf {q} \in \sigma }(\nabla \times \mathbf {F} )|_{\mathbf {q} }\cdot \mathbf {dS}$. This theorem can be extended to equate a surface integral with a volume integral, as opposed to equating a path integral with a surface integral.
Let $\Omega$ be an arbitrary volume with outwards oriented surface $\partial \Omega$. Let $x_{c}\in \mathbb {R}$ be arbitrary, and let $D$ be the cross-section of $\Omega$ in the plane $x=x_{c}$. Let $\partial D$ be the counter-clockwise boundary of $D$ (the surface normal vectors of $D$ point in the positive x-direction). Green's theorem gives:
$\int _{\mathbf {q} \in \partial D}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} =\iint _{\mathbf {q} \in D}\left({\frac {\partial F_{z}}{\partial y}}-{\frac {\partial F_{y}}{\partial z}}\right)dydz$
Now let the cross-section $D$ have an infinitesimal thickness $dx$, forming the volume slice $D'$. Let $E$ denote the infinitesimal strip of $\partial \Omega$ that wraps the cross-section ($E$ is similar to $\partial D$ except that $E$ is a surface with a non-zero infinitesimal width). Let $\mathbf {dS}$ be an infinitesimal portion of $E$. Ignoring the component of $\mathbf {dS}$ that is parallel to $D$, $dS_{y}\mathbf {j} +dS_{z}\mathbf {k}$ denotes a thin strip of surface that wraps around $D$, and is parallel to the x-axis. The counterclockwise displacement $d\mathbf {q}$ along the boundary of $D$ manifested by $dS_{y}\mathbf {j} +dS_{z}\mathbf {k}$ is $d\mathbf {q} =-{\frac {dS_{z}}{dx}}\mathbf {j} +{\frac {dS_{y}}{dx}}\mathbf {k}$. Substituting into the path integral around $\partial D$ gives:
$\iint _{\mathbf {q} \in E}(F_{z}(\mathbf {q} ){\frac {dS_{y}}{dx}}-F_{y}(\mathbf {q} ){\frac {dS_{z}}{dx}})=\iint _{\mathbf {q} \in D}\left({\frac {\partial F_{z}}{\partial y}}-{\frac {\partial F_{y}}{\partial z}}\right)dydz$
$\implies \iint _{\mathbf {q} \in E}(F_{z}(\mathbf {q} )dS_{y}-F_{y}(\mathbf {q} )dS_{z})=\iiint _{\mathbf {q} \in D'}\left({\frac {\partial F_{z}}{\partial y}}-{\frac {\partial F_{y}}{\partial z}}\right)dV$
Integrating over all cross-sections gives:
$\iint _{\mathbf {q} \in \partial \Omega }(F_{z}(\mathbf {q} )dS_{y}-F_{y}(\mathbf {q} )dS_{z})=\iiint _{\mathbf {q} \in \Omega }\left({\frac {\partial F_{z}}{\partial y}}-{\frac {\partial F_{y}}{\partial z}}\right)dV$
Repeating the above argument for the y-axis and z-axis gives:
$\iint _{\mathbf {q} \in \partial \Omega }(F_{x}(\mathbf {q} )dS_{z}-F_{z}(\mathbf {q} )dS_{x})=\iiint _{\mathbf {q} \in \Omega }\left({\frac {\partial F_{x}}{\partial z}}-{\frac {\partial F_{z}}{\partial x}}\right)dV$
$\iint _{\mathbf {q} \in \partial \Omega }(F_{y}(\mathbf {q} )dS_{x}-F_{x}(\mathbf {q} )dS_{y})=\iiint _{\mathbf {q} \in \Omega }\left({\frac {\partial F_{y}}{\partial x}}-{\frac {\partial F_{x}}{\partial y}}\right)dV$
This yields:
$\iint _{\mathbf {q} \in \partial \Omega }((F_{z}(\mathbf {q} )dS_{y}-F_{y}(\mathbf {q} )dS_{z})\mathbf {i} +(F_{x}(\mathbf {q} )dS_{z}-F_{z}(\mathbf {q} )dS_{x})\mathbf {j} +(F_{y}(\mathbf {q} )dS_{x}-F_{x}(\mathbf {q} )dS_{y})\mathbf {k} )$ $=\iiint _{\mathbf {q} \in \Omega }\left(\left({\frac {\partial F_{z}}{\partial y}}-{\frac {\partial F_{y}}{\partial z}}\right)\mathbf {i} +\left({\frac {\partial F_{x}}{\partial z}}-{\frac {\partial F_{z}}{\partial x}}\right)\mathbf {j} +\left({\frac {\partial F_{y}}{\partial x}}-{\frac {\partial F_{x}}{\partial y}}\right)\mathbf {k} \right)dV$
$\implies \iint _{\mathbf {q} \in \partial \Omega }\mathbf {dS} \times \mathbf {F} (\mathbf {q} )=\iiint _{\mathbf {q} \in \Omega }(\nabla \times \mathbf {F} )|_{\mathbf {q} }dV$
The above integral equation is effectively a generalization of Stokes' theorem.