# Calculus/Vector calculus

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

## Fields in vector calculus

A depiction of xyz Cartesian coordinates with the ijk elementary basis vectors.

### Scalar fields

A scalar field is a function ${\displaystyle 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 ${\displaystyle \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.

A depiction of cylindrical coordinates and the accompanying orthonormal basis vectors.

### Vector fields in cylindrical coordinates

The cylindrical coordinate system used here has the three parameters: ${\displaystyle (\rho ,\phi ,z)}$. The Cartesian coordinate equivalent to the point ${\displaystyle (\rho ,\phi ,z)}$ is

${\displaystyle x=\rho \cos \phi }$

${\displaystyle y=\rho \sin \phi }$

${\displaystyle z=z}$

Any vector field in cylindrical coordinates is a linear combination of the following 3 mutually orthogonal unit length basis vectors:

${\displaystyle {\hat {\mathbf {\rho } }}=\cos \phi \mathbf {i} +\sin \phi \mathbf {j} }$

${\displaystyle {\hat {\mathbf {\phi } }}=-\sin \phi \mathbf {i} +\cos \phi \mathbf {j} }$

${\displaystyle {\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:

${\displaystyle {\frac {\partial }{\partial \rho }}}$ ${\displaystyle {\frac {\partial }{\partial \phi }}}$ ${\displaystyle {\frac {\partial }{\partial z}}}$
${\displaystyle {\hat {\mathbf {\rho } }}}$ ${\displaystyle {\frac {\partial {\hat {\mathbf {\rho } }}}{\partial \rho }}=\mathbf {0} }$ ${\displaystyle {\frac {\partial {\hat {\mathbf {\rho } }}}{\partial \phi }}={\hat {\mathbf {\phi } }}}$ ${\displaystyle {\frac {\partial {\hat {\mathbf {\rho } }}}{\partial z}}=\mathbf {0} }$
${\displaystyle {\hat {\mathbf {\phi } }}}$ ${\displaystyle {\frac {\partial {\hat {\mathbf {\phi } }}}{\partial \rho }}=\mathbf {0} }$ ${\displaystyle {\frac {\partial {\hat {\mathbf {\phi } }}}{\partial \phi }}=-{\hat {\mathbf {r} }}}$ ${\displaystyle {\frac {\partial {\hat {\mathbf {\phi } }}}{\partial z}}=\mathbf {0} }$
${\displaystyle {\hat {\mathbf {z} }}}$ ${\displaystyle {\frac {\partial {\hat {\mathbf {z} }}}{\partial \rho }}=\mathbf {0} }$ ${\displaystyle {\frac {\partial {\hat {\mathbf {z} }}}{\partial \phi }}=\mathbf {0} }$ ${\displaystyle {\frac {\partial {\hat {\mathbf {z} }}}{\partial z}}=\mathbf {0} }$

Any vector field ${\displaystyle \mathbf {F} }$ expressed in cylindrical coordinates has the form: ${\displaystyle \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 ${\displaystyle \mathbf {q} =(\rho ,\phi ,z)}$ that changes with time, the velocity of the position is:

${\displaystyle {\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 ${\displaystyle \rho }$ for the term ${\displaystyle \rho {\frac {d\phi }{dt}}{\hat {\mathbf {\phi } }}}$ originates from the fact that as the azimuth angle ${\displaystyle \phi }$ increases, the position ${\displaystyle \mathbf {q} }$ swings around at a speed of ${\displaystyle \rho }$.

A depiction of spherical coordinates and the accompanying orthonormal basis vectors.

### Vector fields in spherical coordinates

The spherical coordinate system used here has the three parameters: ${\displaystyle (r,\theta ,\phi )}$. The Cartesian coordinate equivalent to the point ${\displaystyle (r,\theta ,\phi )}$ is

${\displaystyle x=r\sin \theta \cos \phi }$

${\displaystyle y=r\sin \theta \sin \phi }$

${\displaystyle z=r\cos \theta }$

Any vector field in spherical coordinates is a linear combination of the following 3 mutually orthogonal unit length basis vectors:

${\displaystyle {\hat {\mathbf {r} }}=\sin \theta \cos \phi \mathbf {i} +\sin \theta \sin \phi \mathbf {j} +\cos \theta \mathbf {k} }$

${\displaystyle {\hat {\mathbf {\theta } }}=\cos \theta \cos \phi \mathbf {i} +\cos \theta \sin \phi \mathbf {j} -\sin \theta \mathbf {k} }$

${\displaystyle {\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:

${\displaystyle {\frac {\partial }{\partial r}}}$ ${\displaystyle {\frac {\partial }{\partial \theta }}}$ ${\displaystyle {\frac {\partial }{\partial \phi }}}$
${\displaystyle {\hat {\mathbf {r} }}}$ ${\displaystyle {\frac {\partial {\hat {\mathbf {r} }}}{\partial r}}=\mathbf {0} }$ ${\displaystyle {\frac {\partial {\hat {\mathbf {r} }}}{\partial \theta }}={\hat {\mathbf {\theta } }}}$ ${\displaystyle {\frac {\partial {\hat {\mathbf {r} }}}{\partial \phi }}=\sin \theta {\hat {\mathbf {\phi } }}}$
${\displaystyle {\hat {\mathbf {\theta } }}}$ ${\displaystyle {\frac {\partial {\hat {\mathbf {\theta } }}}{\partial r}}=\mathbf {0} }$ ${\displaystyle {\frac {\partial {\hat {\mathbf {\theta } }}}{\partial \theta }}=-{\hat {\mathbf {r} }}}$ ${\displaystyle {\frac {\partial {\hat {\mathbf {\theta } }}}{\partial \phi }}=\cos \theta {\hat {\mathbf {\phi } }}}$
${\displaystyle {\hat {\mathbf {\phi } }}}$ ${\displaystyle {\frac {\partial {\hat {\mathbf {\phi } }}}{\partial r}}=\mathbf {0} }$ ${\displaystyle {\frac {\partial {\hat {\mathbf {\phi } }}}{\partial \theta }}=\mathbf {0} }$ ${\displaystyle {\frac {\partial {\hat {\mathbf {\phi } }}}{\partial \phi }}=-(\sin \theta {\hat {\mathbf {r} }}+\cos \theta {\hat {\mathbf {\theta } }})}$

Any vector field ${\displaystyle \mathbf {F} }$ expressed in spherical coordinates has the form: ${\displaystyle \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 ${\displaystyle \mathbf {q} =(r,\theta ,\phi )}$ that changes with time, the velocity of this position is:

${\displaystyle {\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 ${\displaystyle r}$ for the term ${\displaystyle r{\frac {d\theta }{dt}}{\hat {\mathbf {\theta } }}}$ arises from the fact that as the latitudinal angle ${\displaystyle \theta }$ changes, the position ${\displaystyle \mathbf {q} }$ traverses a great circle at a speed of ${\displaystyle r}$.

The coefficient of ${\displaystyle r\sin \theta }$ for the term ${\displaystyle r\sin \theta {\frac {d\phi }{dt}}{\hat {\mathbf {\phi } }}}$ arises from the fact that as the longitudinal angle ${\displaystyle \phi }$ changes, the position ${\displaystyle \mathbf {q} }$ traverses a latitude circle at a speed of ${\displaystyle 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 ${\displaystyle \rho :\mathbb {R} ^{3}\to \mathbb {R} }$ that denotes a density at each specific point, and an arbitrary volume ${\displaystyle \Omega \subseteq \mathbb {R} ^{3}}$, the total "mass" ${\displaystyle M}$ inside of ${\displaystyle \Omega }$ can be determined by partitioning ${\displaystyle \Omega }$ into infinitesimal volumes. At each position ${\displaystyle \mathbf {q} \in \Omega }$, the volume of the infinitesimal volume is denoted by the infinitesimal ${\displaystyle dV}$. This gives rise to the following integral:

${\displaystyle M=\iiint _{\mathbf {q} \in \Omega }\rho (\mathbf {q} )dV}$

### Path Integrals

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

${\displaystyle \int _{\mathbf {q} \in C}f(\mathbf {q} )d\mathbf {q} }$, ${\displaystyle \int _{\mathbf {q} \in C}f(\mathbf {q} )|d\mathbf {q} |}$, ${\displaystyle \int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} }$, ${\displaystyle \int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )|d\mathbf {q} |}$, and many more.

${\displaystyle \int _{\mathbf {q} \in C}d\mathbf {q} }$ denotes the total displacement along ${\displaystyle C}$, and ${\displaystyle \int _{\mathbf {q} \in C}|d\mathbf {q} |}$ denotes the total length of ${\displaystyle C}$.

#### Calculating Path Integrals

To compute a path integral, the continuous oriented curve ${\displaystyle C}$ must be parameterized. ${\displaystyle \mathbf {q} _{C}(t)}$ will denote the point along ${\displaystyle C}$ indexed by ${\displaystyle t}$ from the range ${\displaystyle [t_{0},t_{1}]}$. ${\displaystyle \mathbf {q} _{C}(t_{0})=\mathbf {q} _{0}}$ must be the starting point of ${\displaystyle C}$ and ${\displaystyle \mathbf {q} _{C}(t_{1})=\mathbf {q} _{1}}$ must be the ending point of ${\displaystyle C}$. As ${\displaystyle t}$ increases, ${\displaystyle \mathbf {q} _{C}(t)}$ must proceed along ${\displaystyle C}$ in the preferred direction. An infinitesimal change in ${\displaystyle t}$, ${\displaystyle dt}$, results in the infinitesimal displacement ${\displaystyle d\mathbf {q} ={\frac {d\mathbf {q} _{C}}{dt}}dt}$ along ${\displaystyle C}$. In the path integral ${\displaystyle \int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} }$, the differential ${\displaystyle d\mathbf {q} }$ can be replaced with ${\displaystyle {\frac {d\mathbf {q} _{C}}{dt}}dt}$ to get ${\displaystyle \int _{t=t_{0}}^{t_{1}}\mathbf {F} (\mathbf {q} _{C}(t))\cdot {\frac {d\mathbf {q} _{C}}{dt}}dt}$

Example 1

As an example, consider the vector field ${\displaystyle \mathbf {F} (x,y,z)=3\mathbf {i} -x\mathbf {j} +5y\mathbf {k} }$ and the straight line curve ${\displaystyle C}$ that starts at ${\displaystyle (1,1,1)}$ and ends at ${\displaystyle (7,-1,-2)}$. ${\displaystyle C}$ can be parameterized by ${\displaystyle \mathbf {q} _{C}(t)=(1+6t,1-2t,1-3t)}$ where ${\displaystyle t\in [0,1]}$. ${\displaystyle {\frac {d\mathbf {q} _{C}}{dt}}=6\mathbf {i} -2\mathbf {j} -3\mathbf {k} }$. We can then evaluate the path integral ${\displaystyle \int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} }$ as follows:

${\displaystyle \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}$

${\displaystyle =\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 ${\displaystyle \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 ${\displaystyle C}$ is ${\displaystyle W=\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} }$

Example 2

Consider the gravitational field that surrounds a point mass of ${\displaystyle M}$ located at the origin: ${\displaystyle \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 ${\displaystyle m}$ at position ${\displaystyle \mathbf {q} }$ is ${\displaystyle \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 ${\displaystyle \mathbf {F} (r,\theta ,\phi )=-{\frac {GMm}{r^{2}}}{\hat {\mathbf {r} }}}$ (note that ${\displaystyle {\hat {\mathbf {r} }},{\hat {\mathbf {\theta } }},{\hat {\mathbf {\phi } }}}$ are the unit length mutually orthogonal basis vectors for spherical coordinates).

Consider an arbitrary path ${\displaystyle C}$ that ${\displaystyle m}$ traverses that starts at an altitude of ${\displaystyle r=r_{1}}$ and ends at an altitude of ${\displaystyle r=r_{2}}$. The work done by the gravitational field is:

${\displaystyle W=\int _{\mathbf {q} \in C}\mathbf {F} (\mathbf {q} )\cdot d\mathbf {q} }$

The infinitesimal displacement ${\displaystyle d\mathbf {q} }$ is equivalent to the displacement expressed in spherical coordinates: ${\displaystyle dr\cdot {\hat {\mathbf {r} }}+r\cdot d\theta \cdot {\hat {\mathbf {\theta } }}+r\sin \theta \cdot d\phi \cdot {\hat {\mathbf {\phi } }}}$.

${\displaystyle 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 ${\displaystyle \phi (r,\theta ,\phi )=-{\frac {GMm}{r}}}$ or equivalently, ${\displaystyle \phi (\mathbf {q} )=-{\frac {GMm}{|\mathbf {q} |}}}$.

Example 3

Consider the spiral ${\displaystyle C}$ parameterized with respect to ${\displaystyle t}$ in cylindrical coordinates by ${\displaystyle \mathbf {q} _{C}(t)=(\rho =R,\phi =t,z=k{\frac {t}{2\pi }})}$. Consider the problem of determining the spiral's length with ${\displaystyle t}$ restricted to the range ${\displaystyle [0,2\pi ]}$. An infinitesimal change of ${\displaystyle dt}$ in ${\displaystyle t}$ results in the infinitesimal displacement:

${\displaystyle 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 ${\displaystyle |d\mathbf {q} |={\sqrt {R^{2}+\left({\frac {k}{2\pi }}\right)^{2}}}\cdot dt}$.

The length of the spiral is therefore: ${\displaystyle \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 ${\displaystyle \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 ${\displaystyle |dS|}$, and a unit length outwards oriented normal vector ${\displaystyle \mathbf {n} }$. ${\displaystyle \mathbf {n} }$ has a length of 1 and is perpendicular to the surface of ${\displaystyle \sigma }$, while penetrating ${\displaystyle \sigma }$ in the preferred direction. The infinitesimal portion of the surface is denoted by the infinitesimal "surface vector": ${\displaystyle \mathbf {dS} =|dS|\mathbf {n} }$. If a vector field ${\displaystyle \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 ${\displaystyle \mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} }$.

The infinitesimal "surface vector" ${\displaystyle \mathbf {dS} =\mathbf {n} |dS|}$ describes the infinitesimal surface element in a manner similar to how the infinitesimal displacement ${\displaystyle 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.

The displacement between two points is independent of the path that connects them.

Consider for instance two paths ${\displaystyle C_{1}}$ and ${\displaystyle C_{2}}$ that both start at point ${\displaystyle A}$, and end at point ${\displaystyle B}$. The total displacements, ${\displaystyle \int _{\mathbf {q} \in C_{1}}d\mathbf {q} }$ and ${\displaystyle \int _{\mathbf {q} \in C_{2}}d\mathbf {q} }$, are both equivalent and equal to the displacement between ${\displaystyle A}$ and ${\displaystyle B}$. Note however that the total lengths ${\displaystyle \int _{\mathbf {q} \in C_{1}}|d\mathbf {q} |}$ and ${\displaystyle \int _{\mathbf {q} \in C_{2}}|d\mathbf {q} |}$ are not necessarily equivalent.

Similarly, given two surfaces ${\displaystyle S_{1}}$ and ${\displaystyle S_{2}}$ that both share the same counter-clockwise oriented boundary ${\displaystyle C}$, the total surface vectors ${\displaystyle \int _{\mathbf {q} \in S_{1}}\mathbf {dS} }$ and ${\displaystyle \int _{\mathbf {q} \in S_{2}}\mathbf {dS} }$ are both equivalent and are a function of the boundary ${\displaystyle 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 ${\displaystyle \int _{\mathbf {q} \in S_{1}}|\mathbf {dS} |}$ and ${\displaystyle \int _{\mathbf {q} \in S_{2}}|\mathbf {dS} |}$ are not necessarily equivalent.

The fact that the total surface vectors of ${\displaystyle S_{1}}$ and ${\displaystyle S_{2}}$ are equivalent is not immediately obvious. To prove this fact, let ${\displaystyle \mathbf {F} }$ be a constant vector field. ${\displaystyle S_{1}}$ and ${\displaystyle S_{2}}$ share the same boundary, so the flux/flow of ${\displaystyle \mathbf {F} }$ through ${\displaystyle S_{1}}$ and ${\displaystyle S_{2}}$ is equivalent. The flux through ${\displaystyle S_{1}}$ is ${\displaystyle \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 ${\displaystyle S_{2}}$ is ${\displaystyle \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 ${\displaystyle \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 ${\displaystyle \mathbf {F} }$, it follows that ${\displaystyle \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 ${\displaystyle \sigma }$ be a surface with surface vector ${\displaystyle \mathbf {S} =S_{x}\mathbf {i} +S_{y}\mathbf {j} +S_{z}\mathbf {k} }$. It is then the case that: ${\displaystyle S_{x}}$ is the area of the projection of ${\displaystyle \sigma }$ onto the yz-plane; ${\displaystyle S_{y}}$ is the area of the projection of ${\displaystyle \sigma }$ onto the xz-plane; and ${\displaystyle S_{z}}$ is the area of the projection of ${\displaystyle \sigma }$ onto the xy-plane.

The boundary ${\displaystyle \partial \Sigma }$ of ${\displaystyle \Sigma }$ is counter-clockwise oriented.

Given an oriented surface ${\displaystyle \Sigma }$, another important concept is the oriented boundary. The boundary of ${\displaystyle \Sigma }$ is an oriented curve ${\displaystyle \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.

Example 1

Consider the Cartesian points ${\displaystyle (0,0,0)}$; ${\displaystyle (1,0,0)}$; ${\displaystyle (0,1,0)}$; and ${\displaystyle (0,0,1)}$.

Let ${\displaystyle \sigma _{1}}$ be the surface formed by the triangular planes ${\displaystyle \{(0,1,0),(0,0,0),(1,0,0)\}}$; ${\displaystyle \{(0,0,1),(0,0,0),(0,1,0)\}}$; and ${\displaystyle \{(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 ${\displaystyle {\frac {1}{2}}\mathbf {k} }$; ${\displaystyle {\frac {1}{2}}\mathbf {i} }$; and ${\displaystyle {\frac {1}{2}}\mathbf {j} }$ respectively which add to a total surface vector of ${\displaystyle \mathbf {S} _{1}={\frac {1}{2}}(\mathbf {i} +\mathbf {j} +\mathbf {k} )}$.

Let ${\displaystyle \sigma _{2}}$ be the surface formed by the single triangular plane ${\displaystyle \{(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 ${\displaystyle \sigma _{1}}$ and ${\displaystyle \sigma _{2}}$ share a the common counter clockwise boundary ${\displaystyle (1,0,0)\to (0,1,0)\to (0,0,1)}$The surface vector is ${\displaystyle \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 ${\displaystyle \mathbf {S} _{1}}$.

Example 2

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 ${\displaystyle P_{0},P_{1},P_{2},\dots ,P_{n}}$ where ${\displaystyle n\geq 3}$. Let the closed path ${\displaystyle C}$ be defined by the cycle ${\displaystyle P_{1}\to P_{2}\to \dots \to P_{n}\to P_{1}}$. For simplicity, ${\displaystyle P_{n+1}=P_{1}}$. For each ${\displaystyle i=1,2,\dots ,n}$, ${\displaystyle \mathbf {v} _{i}}$ will denote the displacement of ${\displaystyle P_{i}}$ relative to ${\displaystyle P_{0}}$. Like with ${\displaystyle P_{n+1}}$, ${\displaystyle \mathbf {v} _{n+1}=\mathbf {v} _{1}}$.

Let ${\displaystyle \sigma }$ denote a surface that is a "triangular mesh" comprised of the closed fan of triangles: ${\displaystyle \{P_{2},P_{0},P_{1}\}}$; ${\displaystyle \{P_{3},P_{0},P_{2}\}}$; ...; ${\displaystyle \{P_{n},P_{0},P_{n-1}\}}$; ${\displaystyle \{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 ${\displaystyle \sigma }$ is ${\displaystyle C}$ and does not depend on the location of ${\displaystyle P_{0}}$. The total surface vector for ${\displaystyle \sigma }$ is:

${\displaystyle \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 ${\displaystyle P_{0}}$ by ${\displaystyle \mathbf {w} }$ to get ${\displaystyle P'_{0}}$. The displacement vector of ${\displaystyle P_{i}}$ relative to ${\displaystyle P_{0}'}$ becomes ${\displaystyle \mathbf {v} '_{i}=\mathbf {v} _{i}-\mathbf {w} }$. The counterclockwise boundary is unaffected. The total surface vector is:

${\displaystyle \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} ))}$

${\displaystyle ={\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 ${\displaystyle P_{0}}$ neither affects the boundary, nor the total surface vector.

#### Calculating Surface Integrals

To calculate a surface integral, the oriented surface ${\displaystyle \sigma }$ must be parameterized. Let ${\displaystyle \mathbf {q} _{\sigma }(u,v)}$ be a continuous function that maps each point ${\displaystyle (u,v)}$ from a two-dimensional domain ${\displaystyle D_{u,v}}$ to a point in ${\displaystyle \sigma }$. ${\displaystyle \mathbf {q} _{\sigma }(u,v)}$ must be continuous and onto. While ${\displaystyle \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 ${\displaystyle u}$ and ${\displaystyle v}$ are respectively ${\displaystyle du}$ and ${\displaystyle dv}$. These respectively give rise to the displacements ${\displaystyle {\frac {\partial \mathbf {q} _{\sigma }}{\partial u}}du}$ and ${\displaystyle {\frac {\partial \mathbf {q} _{\sigma }}{\partial v}}dv}$. Assuming that the surface's orientation follows the right hand rule with respect to the displacements ${\displaystyle {\frac {\partial \mathbf {q} _{\sigma }}{\partial u}}du}$ and ${\displaystyle {\frac {\partial \mathbf {q} _{\sigma }}{\partial v}}dv}$, the surface vector that arises is ${\displaystyle \mathbf {dS} =({\frac {\partial \mathbf {q} _{\sigma }}{\partial u}}\times {\frac {\partial \mathbf {q} _{\sigma }}{\partial v}})dudv}$.

In the surface integral ${\displaystyle \iint _{\mathbf {q} \in \sigma }\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} }$, the differential ${\displaystyle \mathbf {dS} }$ can be replaced with ${\displaystyle ({\frac {\partial \mathbf {q} _{\sigma }}{\partial u}}\times {\frac {\partial \mathbf {q} _{\sigma }}{\partial v}})dudv}$ to get ${\displaystyle \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}$.

Example 3

Consider the problem of computing the surface area of a sphere of radius ${\displaystyle R}$.

Center the sphere ${\displaystyle \sigma }$ on the origin, and using ${\displaystyle u}$ and ${\displaystyle v}$ as the parameter variables, the sphere can be parameterized in spherical coordinates via ${\displaystyle \mathbf {q} _{\sigma }(u,v)=(r=R,\theta =u,\phi =v)}$ where ${\displaystyle u\in [0,\pi ]}$ and ${\displaystyle v\in [-\pi ,+\pi ]}$. The infinitesimal displacements from small changes in the parameters are:

${\displaystyle du}$ causes ${\displaystyle {\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}$

${\displaystyle dv}$ causes ${\displaystyle {\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 ${\displaystyle \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 ${\displaystyle |\mathbf {dS} |=R^{2}\sin(u)dudv}$.

The total surface area is hence:

${\displaystyle \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 ${\displaystyle \phi :\mathbb {R} ^{3}\to \mathbb {R} }$ that denotes a potential, and given a curve ${\displaystyle C}$, a commonly sought after quantity is the rate of change in ${\displaystyle \phi }$ as ${\displaystyle C}$ is being traversed. Let ${\displaystyle t}$ be an arbitrary parameter for ${\displaystyle C}$, and let ${\displaystyle \mathbf {q} _{C}(t)=(x(t),y(t),z(t))}$ denote the point indexed by ${\displaystyle t}$. Given an arbitrary ${\displaystyle t=t_{0}}$ which corresponds to the point ${\displaystyle \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 ${\displaystyle \phi }$ at ${\displaystyle t=t_{0}}$, ${\displaystyle {\frac {d\phi }{dt}}{\bigg |}_{t_{0}}}$:

${\displaystyle {\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 ${\displaystyle \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 ${\displaystyle \phi }$, and ${\displaystyle \mathbf {v} ={\frac {dx}{dt}}\mathbf {i} +{\frac {dy}{dt}}\mathbf {j} +{\frac {dz}{dt}}\mathbf {k} }$ is the unnormalized tangent of ${\displaystyle C}$.

If ${\displaystyle t}$ is an arc-length parameter, i.e. ${\displaystyle \left|\mathbf {v} \right|=1}$, then the direction of the gradient is the direction of maximum gain: Given any unit length tangent ${\displaystyle \mathbf {v} }$, the direction ${\displaystyle \mathbf {v} ={\frac {\nabla \phi }{|\nabla \phi |}}}$ will maximize the rate of increase in ${\displaystyle \phi }$. This maximum rate of increase is ${\displaystyle |\nabla \phi |}$.

### Calculating total gain

Given the gradient of a scalar field ${\displaystyle \phi }$: ${\displaystyle \nabla \phi }$, the difference between ${\displaystyle \phi }$ at two different points can be calculated, provided that there is a continuous path that links the two points. Let ${\displaystyle C}$ denote an arbitrary continuous path that starts at point ${\displaystyle \mathbf {q} _{0}}$ and ends at point ${\displaystyle \mathbf {q} _{1}}$. Given an infinitesimal path segment ${\displaystyle P}$ with endpoints ${\displaystyle \mathbf {q} _{l}}$ and ${\displaystyle \mathbf {q} _{u}}$, let ${\displaystyle \mathbf {q} _{c}\in P}$ be an arbitrary point in ${\displaystyle P}$. ${\displaystyle \Delta \mathbf {q} =\mathbf {q} _{u}-\mathbf {q} _{l}}$ denotes the infinitesimal displacement denoted by ${\displaystyle P}$. The increase in ${\displaystyle \phi }$ along ${\displaystyle P}$ is:

${\displaystyle \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 ${\displaystyle \Delta \mathbf {q} \rightarrow \mathbf {0} }$. Adding together the above equation over all infinitesimal path segments of ${\displaystyle C}$ yields the following path integral equation:

${\displaystyle \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 ${\displaystyle f:\mathbb {R} ^{3}\to \mathbb {R} }$ be a scalar field that denotes a potential and a curve ${\displaystyle C}$ that is parameterized by ${\displaystyle t}$: ${\displaystyle \mathbf {q} _{C}(t)=(\rho (t),\phi (t),z(t))}$. Let the rate of change in ${\displaystyle \mathbf {q} _{C}(t)}$ be quantified by the vector ${\displaystyle {\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 ${\displaystyle f}$ is:

${\displaystyle {\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: ${\displaystyle \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 ${\displaystyle f:\mathbb {R} ^{3}\to \mathbb {R} }$ be a scalar field that denotes a potential and a curve ${\displaystyle C}$ that is parameterized by ${\displaystyle t}$: ${\displaystyle \mathbf {q} _{C}(t)=(r(t),\theta (t),\phi (t))}$. Let the rate of change in ${\displaystyle \mathbf {q} _{C}(t)}$ be quantified by the vector ${\displaystyle {\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 ${\displaystyle f}$ is:

${\displaystyle {\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: ${\displaystyle \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 ${\displaystyle f}$ and a vector ${\displaystyle \mathbf {v} }$, scalar field ${\displaystyle g=\mathbf {v} \cdot (\nabla f)}$ computes the rate of change in ${\displaystyle f}$ at each position ${\displaystyle \mathbf {q} }$ where the velocity of ${\displaystyle \mathbf {q} }$ is ${\displaystyle {\frac {d\mathbf {q} }{dt}}=\mathbf {v} }$. Scalar field ${\displaystyle g}$ can also be expressed as ${\displaystyle g=(\mathbf {v} \cdot \nabla )f}$. Velocity ${\displaystyle \mathbf {v} }$ can also be a vector field ${\displaystyle \mathbf {V} }$ so ${\displaystyle {\frac {d\mathbf {q} }{dt}}}$ depends on the position ${\displaystyle \mathbf {q} }$. Scalar field ${\displaystyle g}$ becomes ${\displaystyle g=(\mathbf {V} \cdot \nabla )f}$.

In Cartesian coordinates where ${\displaystyle \mathbf {V} =v_{x}\mathbf {i} +v_{y}\mathbf {j} +v_{z}\mathbf {k} }$ the directional derivative is:

${\displaystyle (\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 ${\displaystyle \mathbf {V} =v_{\rho }{\hat {\mathbf {\rho } }}+v_{\phi }{\hat {\mathbf {\phi } }}+v_{z}{\hat {\mathbf {z} }}}$ the directional derivative is:

${\displaystyle (\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 ${\displaystyle \mathbf {V} =v_{r}{\hat {\mathbf {r} }}+v_{\theta }{\hat {\mathbf {\theta } }}+v_{\phi }{\hat {\mathbf {\phi } }}}$ the directional derivative is:

${\displaystyle (\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 ${\displaystyle f}$ can instead be a vector field ${\displaystyle \mathbf {F} }$. Vector field ${\displaystyle \mathbf {G} =(\mathbf {V} \cdot \nabla )\mathbf {F} }$ computes ${\displaystyle {\frac {d\mathbf {F} }{dt}}}$ at each position ${\displaystyle \mathbf {q} }$ where ${\displaystyle {\frac {d\mathbf {q} }{dt}}=\mathbf {V} (\mathbf {q} )}$.

In cylindrical coordinates, basis vectors ${\displaystyle {\hat {\mathbf {\rho } }}}$ and ${\displaystyle {\hat {\mathbf {\phi } }}}$ are not fixed, and in spherical coordinates, all of the basis vectors ${\displaystyle {\hat {\mathbf {r} }}}$, ${\displaystyle {\hat {\mathbf {\theta } }}}$, and ${\displaystyle {\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 ${\displaystyle \mathbf {V} }$, ${\displaystyle \mathbf {F} }$, and ${\displaystyle \mathbf {G} }$, then ${\displaystyle (\mathbf {V} \cdot \nabla )(\mathbf {F} +\mathbf {G} )=(\mathbf {V} \cdot \nabla )\mathbf {F} +(\mathbf {V} \cdot \nabla )\mathbf {G} }$

Given vector fields ${\displaystyle \mathbf {V} }$ and ${\displaystyle \mathbf {G} }$, and scalar field ${\displaystyle f}$, then ${\displaystyle (\mathbf {V} \cdot \nabla )(f\mathbf {G} )=((\mathbf {V} \cdot \nabla )f)\mathbf {G} +f((\mathbf {V} \cdot \nabla )\mathbf {G} )}$

In cylindrical coordinates, ${\displaystyle ((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 ${\displaystyle ((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, ${\displaystyle ((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 ${\displaystyle ((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 ${\displaystyle ((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 } }})}$

Full Expansions

In Cartesian coordinates where ${\displaystyle \mathbf {F} =F_{x}\mathbf {i} +F_{y}\mathbf {j} +F_{z}\mathbf {k} }$ and ${\displaystyle \mathbf {V} =v_{x}\mathbf {i} +v_{y}\mathbf {j} +v_{z}\mathbf {k} }$ the directional derivative is:

${\displaystyle \mathbf {G} =(\mathbf {V} \cdot \nabla )\mathbf {F} }$ ${\displaystyle =(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} )}$ ${\displaystyle =(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 ${\displaystyle \mathbf {F} =F_{\rho }{\hat {\mathbf {\rho } }}+F_{\phi }{\hat {\mathbf {\phi } }}+F_{z}{\hat {\mathbf {z} }}}$ and ${\displaystyle \mathbf {V} =v_{\rho }{\hat {\mathbf {\rho } }}+v_{\phi }{\hat {\mathbf {\phi } }}+v_{z}{\hat {\mathbf {z} }}}$ the directional derivative is:

${\displaystyle \mathbf {G} =(\mathbf {V} \cdot \nabla )\mathbf {F} }$ ${\displaystyle =(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} }})}$

${\displaystyle =(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} }})}$

${\displaystyle =(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 ${\displaystyle \mathbf {F} =F_{r}{\hat {\mathbf {r} }}+F_{\theta }{\hat {\mathbf {\theta } }}+F_{\phi }{\hat {\mathbf {\phi } }}}$ and ${\displaystyle \mathbf {V} =v_{r}{\hat {\mathbf {r} }}+v_{\theta }{\hat {\mathbf {\theta } }}+v_{\phi }{\hat {\mathbf {\phi } }}}$ the directional derivative is:

${\displaystyle \mathbf {G} =(\mathbf {V} \cdot \nabla )\mathbf {F} }$ ${\displaystyle =(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 } }})}$

${\displaystyle =(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 } }}))}$ ${\displaystyle +(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 } }}))}$ ${\displaystyle +(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 } }})))}$

${\displaystyle =(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} }}}$ ${\displaystyle +(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 } }}}$ ${\displaystyle +(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 ${\displaystyle \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 ${\displaystyle \mathbf {dS} =dS_{x}\mathbf {i} +dS_{y}\mathbf {j} +dS_{z}\mathbf {k} }$ at position ${\displaystyle \mathbf {q} }$, the flow through ${\displaystyle \mathbf {dS} }$ in the preferred direction is ${\displaystyle \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}}$. ${\displaystyle F_{x}}$ is the flow density parallel to the x-axis etc.

Given a volume ${\displaystyle \Omega }$ with a closed surface boundary ${\displaystyle \partial \Omega }$ with an outwards orientation, the total outwards flow/flux through ${\displaystyle \partial \Omega }$ is given by the surface integral ${\displaystyle \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 ${\displaystyle \Omega }$.

For an infinitesimal rectangular prism ${\displaystyle R=[x_{l},x_{u}]\times [y_{l},y_{u}]\times [z_{l},z_{u}]}$ (${\displaystyle \Delta x=x_{u}-x_{l}}$, ${\displaystyle \Delta y=y_{u}-y_{l}}$, and ${\displaystyle \Delta z=z_{u}-z_{l}}$) that is centered on position ${\displaystyle (x_{c},y_{c},z_{c})}$, the outwards flow through the surface ${\displaystyle \partial R}$ is:

${\displaystyle \iint _{\mathbf {q} \in \partial R}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} \approx }$ ${\displaystyle \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} )+}$ ${\displaystyle \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} )+}$ ${\displaystyle \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} )=}$

${\displaystyle {\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)+}$ ${\displaystyle {\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)+}$ ${\displaystyle {\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 }$

${\displaystyle \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 }$

${\displaystyle \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 ${\displaystyle \Delta x,\Delta y,\Delta z\rightarrow 0^{+}}$.

${\displaystyle \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 ${\displaystyle \mathbf {F} }$ and is the density of "flow generation" at ${\displaystyle (x_{c},y_{c},z_{c})}$. As noted above, the total outwards flow through ${\displaystyle \partial \Omega }$ is the total flow generated inside of ${\displaystyle \Omega }$, which gives Gauss's divergence theorem:

${\displaystyle \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}$

This image depicts an example of the total flow across a closed boundary being the total flow generated inside the boundary.

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 ${\displaystyle \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 ${\displaystyle \mathbf {F} }$, consider an infinitesimal volume ${\displaystyle R}$ defined by all points ${\displaystyle (\rho ,\phi ,z)}$ where ${\displaystyle \rho \in [\rho _{l},\rho _{u}]}$, ${\displaystyle \phi \in [\phi _{l},\phi _{u}]}$, and ${\displaystyle z\in [z_{l},z_{u}]}$. Note that ${\displaystyle R}$ is not a rectangular prism. Let ${\displaystyle \Delta \rho =\rho _{u}-\rho _{l}}$, ${\displaystyle \Delta \phi =\phi _{u}-\phi _{l}}$, and ${\displaystyle \Delta z=z_{u}-z_{l}}$. Let ${\displaystyle (\rho _{c},\phi _{c},z_{c})\in R}$ be an arbitrary point from ${\displaystyle R}$.

The volume of ${\displaystyle R}$ is approximately ${\displaystyle \Delta \rho \cdot \rho _{c}\Delta \phi \cdot \Delta z}$. The 6 surfaces bounding ${\displaystyle R}$ are described in the following table:

Surface approximate area direction approximate flow density
${\displaystyle \rho =\rho _{u}}$, ${\displaystyle \phi \in [\phi _{l},\phi _{u}]}$, ${\displaystyle z\in [z_{l},z_{u}]}$ ${\displaystyle \rho _{u}\Delta \phi \cdot \Delta z}$ ${\displaystyle +{\hat {\mathbf {\rho } }}}$ ${\displaystyle \mathbf {F} (\rho _{u},\phi _{c},z_{c})}$
${\displaystyle \rho =\rho _{l}}$, ${\displaystyle \phi \in [\phi _{l},\phi _{u}]}$, ${\displaystyle z\in [z_{l},z_{u}]}$ ${\displaystyle \rho _{l}\Delta \phi \cdot \Delta z}$ ${\displaystyle -{\hat {\mathbf {\rho } }}}$ ${\displaystyle \mathbf {F} (\rho _{l},\phi _{c},z_{c})}$
${\displaystyle \rho \in [\rho _{l},\rho _{u}]}$, ${\displaystyle \phi =\phi _{u}}$, ${\displaystyle z\in [z_{l},z_{u}]}$ ${\displaystyle \Delta \rho \cdot \Delta z}$ ${\displaystyle +{\hat {\mathbf {\phi } }}}$ ${\displaystyle \mathbf {F} (\rho _{c},\phi _{u},z_{c})}$
${\displaystyle \rho \in [\rho _{l},\rho _{u}]}$, ${\displaystyle \phi =\phi _{l}}$, ${\displaystyle z\in [z_{l},z_{u}]}$ ${\displaystyle \Delta \rho \cdot \Delta z}$ ${\displaystyle -{\hat {\mathbf {\phi } }}}$ ${\displaystyle \mathbf {F} (\rho _{c},\phi _{l},z_{c})}$
${\displaystyle \rho \in [\rho _{l},\rho _{u}]}$, ${\displaystyle \phi \in [\phi _{l},\phi _{u}]}$, ${\displaystyle z=z_{u}}$ ${\displaystyle \Delta \rho \cdot \rho _{c}\Delta \phi }$ ${\displaystyle +{\hat {\mathbf {z} }}}$ ${\displaystyle \mathbf {F} (\rho _{c},\phi _{c},z_{u})}$
${\displaystyle \rho \in [\rho _{l},\rho _{u}]}$, ${\displaystyle \phi \in [\phi _{l},\phi _{u}]}$, ${\displaystyle z=z_{l}}$ ${\displaystyle \Delta \rho \cdot \rho _{c}\Delta \phi }$ ${\displaystyle -{\hat {\mathbf {z} }}}$ ${\displaystyle \mathbf {F} (\rho _{c},\phi _{c},z_{l})}$

The total outwards flow through the surface ${\displaystyle \partial R}$ of ${\displaystyle R}$ is:

${\displaystyle \iint _{\mathbf {q} \in \partial R}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} \approx }$ ${\displaystyle \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 } }})+}$ ${\displaystyle \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 } }})+}$ ${\displaystyle \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} }})=}$

${\displaystyle {\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)+}$ ${\displaystyle {\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)+}$ ${\displaystyle \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 }$

${\displaystyle \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)=}$

${\displaystyle \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 }$

${\displaystyle \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 ${\displaystyle \Delta \rho ,\Delta \phi ,\Delta z\rightarrow 0^{+}}$.

The divergence (flow generation density) is therefore:

${\displaystyle \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 ${\displaystyle \rho =\rho _{u}}$, ${\displaystyle \phi \in [\phi _{l},\phi _{u}]}$, ${\displaystyle z\in [z_{l},z_{u}]}$ is approximated by ${\displaystyle \rho _{u}\Delta \phi \cdot \Delta z}$ instead of ${\displaystyle \rho _{c}\Delta \phi \cdot \Delta z}$ since the difference between ${\displaystyle \rho _{u}}$ and ${\displaystyle \rho _{c}}$ approaches 0 as ${\displaystyle \Delta \rho \rightarrow 0^{+}}$. While the absolute difference between ${\displaystyle \rho _{u}}$ and ${\displaystyle \rho _{c}}$ approaches 0 as ${\displaystyle \Delta \rho \rightarrow 0^{+}}$, the difference relative to the infinitesimal ${\displaystyle \Delta \rho }$ does not approach 0: ${\displaystyle {\frac {\rho _{u}-\rho _{c}}{\Delta \rho }}\not \to 0}$.

With respect to the surface ${\displaystyle \rho \in [\rho _{l},\rho _{u}]}$, ${\displaystyle \phi \in [\phi _{l},\phi _{u}]}$, ${\displaystyle z=z_{u}}$, the area can be approximated by ${\displaystyle \Delta \rho \cdot \rho _{l}\Delta \phi }$, ${\displaystyle \Delta \rho \cdot \rho _{c}\Delta \phi }$, or ${\displaystyle \Delta \rho \cdot \rho _{u}\Delta \phi }$ since ${\displaystyle \Delta \rho }$ is already a factor, and the differences between ${\displaystyle \rho _{l}\Delta \rho }$, ${\displaystyle \rho _{c}\Delta \rho }$, and ${\displaystyle \rho _{u}\Delta \rho }$ relative to the infinitesimal ${\displaystyle \Delta \rho }$ do approach 0 as ${\displaystyle \Delta \rho \rightarrow 0^{+}}$.

### The divergence in spherical coordinates

Let ${\displaystyle \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 ${\displaystyle \mathbf {F} }$, consider an infinitesimal volume ${\displaystyle R}$ defined by all points ${\displaystyle (r,\theta ,\phi )}$ where ${\displaystyle r\in [r_{l},r_{u}]}$, ${\displaystyle \theta \in [\theta _{l},\theta _{u}]}$, and ${\displaystyle \phi \in [\phi _{l},\phi _{u}]}$. Note that ${\displaystyle R}$ is not a rectangular prism. Let ${\displaystyle \Delta r=r_{u}-r_{l}}$, ${\displaystyle \Delta \theta =\theta _{u}-\theta _{l}}$, and ${\displaystyle \Delta \phi =\phi _{u}-\phi _{l}}$. Let ${\displaystyle (r_{c},\theta _{c},\phi _{c})\in R}$ be an arbitrary point from ${\displaystyle R}$.

The volume of ${\displaystyle R}$ is approximately ${\displaystyle \Delta r\cdot r_{c}\Delta \theta \cdot r_{c}\sin \theta _{c}\Delta \phi }$. The 6 surfaces bounding ${\displaystyle R}$ are shown in the following table:

Surface approximate area direction approximate flow density
${\displaystyle r=r_{u}}$, ${\displaystyle \theta \in [\theta _{l},\theta _{u}]}$, ${\displaystyle \phi \in [\phi _{l},\phi _{u}]}$ ${\displaystyle r_{u}\Delta \theta \cdot r_{u}\sin \theta _{c}\Delta \phi }$ ${\displaystyle +{\hat {\mathbf {r} }}}$ ${\displaystyle \mathbf {F} (r_{u},\theta _{c},\phi _{c})}$
${\displaystyle r=r_{l}}$, ${\displaystyle \theta \in [\theta _{l},\theta _{u}]}$, ${\displaystyle \phi \in [\phi _{l},\phi _{u}]}$ ${\displaystyle r_{l}\Delta \theta \cdot r_{l}\sin \theta _{c}\Delta \phi }$ ${\displaystyle -{\hat {\mathbf {r} }}}$ ${\displaystyle \mathbf {F} (r_{l},\theta _{c},\phi _{c})}$
${\displaystyle r\in [r_{l},r_{u}]}$, ${\displaystyle \theta =\theta _{u}}$, ${\displaystyle \phi \in [\phi _{l},\phi _{u}]}$ ${\displaystyle \Delta r\cdot r_{c}\sin \theta _{u}\Delta \phi }$ ${\displaystyle +{\hat {\mathbf {\theta } }}}$ ${\displaystyle \mathbf {F} (r_{c},\theta _{u},\phi _{c})}$
${\displaystyle r\in [r_{l},r_{u}]}$, ${\displaystyle \theta =\theta _{l}}$, ${\displaystyle \phi \in [\phi _{l},\phi _{u}]}$ ${\displaystyle \Delta r\cdot r_{c}\sin \theta _{l}\Delta \phi }$ ${\displaystyle -{\hat {\mathbf {\theta } }}}$ ${\displaystyle \mathbf {F} (r_{c},\theta _{l},\phi _{c})}$
${\displaystyle r\in [r_{l},r_{u}]}$, ${\displaystyle \theta \in [\theta _{l},\theta _{u}]}$, ${\displaystyle \phi =\phi _{u}}$ ${\displaystyle \Delta r\cdot r_{c}\Delta \theta }$ ${\displaystyle +{\hat {\mathbf {\phi } }}}$ ${\displaystyle \mathbf {F} (r_{c},\theta _{c},\phi _{u})}$
${\displaystyle r\in [r_{l},r_{u}]}$, ${\displaystyle \theta \in [\theta _{l},\theta _{u}]}$, ${\displaystyle \phi =\phi _{l}}$ ${\displaystyle \Delta r\cdot r_{c}\Delta \theta }$ ${\displaystyle -{\hat {\mathbf {\phi } }}}$ ${\displaystyle \mathbf {F} (r_{c},\theta _{c},\phi _{l})}$

The total outwards flow through the surface ${\displaystyle \partial R}$ of ${\displaystyle R}$ is:

${\displaystyle \iint _{\mathbf {q} \in \partial R}\mathbf {F} (\mathbf {q} )\cdot \mathbf {dS} \approx }$

${\displaystyle \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} }})+}$

${\displaystyle \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 } }})+}$

${\displaystyle \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 } }})=}$

${\displaystyle \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 }$

${\displaystyle \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 )=}$

${\displaystyle \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 }$

${\displaystyle \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 ${\displaystyle \Delta r,\Delta \theta ,\Delta \phi \rightarrow 0^{+}}$

The divergence (flow generation density) is therefore: