Ma · Mathematics

How to Calculate Divergence in Curvilinear Coordinates

Published By the 9to5Science editorial team

At a glance

  1. 1. Identify the coordinates

    Determine the coordinate variables and whether the system is orthogonal.

  2. 2. Find scale factors

    Compute the metric scale factors h₁, h₂, and h₃ from the coordinate transformation.

  3. 3. Insert components

    Use physical vector components with the orthogonal-coordinate divergence formula.

  4. 4. Differentiate and simplify

    Differentiate each flux term, include the scale factors, and combine the results.

Divergence measures the net outward flux of a vector field per unit volume. In Cartesian coordinates, its familiar form is

∇⋅A=∂Ax∂x+∂Ay∂y+∂Az∂z.\nabla\cdot\mathbf A=\frac{\partial A_x}{\partial x}+\frac{\partial A_y}{\partial y}+\frac{\partial A_z}{\partial z}.

In curvilinear coordinates, coordinate surfaces may have different spacings and different areas. The scale factors that describe this geometry must therefore appear in the formula. This article gives the general formula, the especially useful orthogonal-coordinate version, and worked cylindrical and spherical examples.

The general coordinate formula

Let (q1,q2,q3)(q^1,q^2,q^3) be coordinates, and let gijg_{ij} be the metric tensor. Write

g=det⁡(gij).g=\det(g_{ij}).

If the vector field is expressed using contravariant components AiA^i, then its divergence is

∇⋅A=1g∂∂qi(g Ai)\boxed{\nabla\cdot\mathbf A =\frac{1}{\sqrt{g}}\frac{\partial}{\partial q^i}\left(\sqrt{g}\,A^i\right)}

where repeated indices are summed over i=1,2,3i=1,2,3. Written without index summation notation, this is

∇⋅A=1g[∂∂q1(gA1)+∂∂q2(gA2)+∂∂q3(gA3)].\nabla\cdot\mathbf A =\frac{1}{\sqrt{g}} \left[ \frac{\partial}{\partial q^1}(\sqrt{g}A^1) +\frac{\partial}{\partial q^2}(\sqrt{g}A^2) +\frac{\partial}{\partial q^3}(\sqrt{g}A^3) \right].

The components AiA^i here are contravariant coordinate components. They are not always the same as the components measured along unit vectors. This distinction is the source of many errors in curvilinear-coordinate calculations.

Orthogonal coordinates and scale factors

Most physics and vector-calculus applications use orthogonal coordinates. Let the line element be

ds2=h12(dq1)2+h22(dq2)2+h32(dq3)2,ds^2=h_1^2(dq^1)^2+h_2^2(dq^2)^2+h_3^2(dq^3)^2,

where h1,h2,h3h_1,h_2,h_3 are the scale factors. In this case,

g=h1h2h3.\sqrt{g}=h_1h_2h_3.

If A1,A2,A3A_1,A_2,A_3 denote the physical components of the vector field along the corresponding local unit vectors, then

∇⋅A=1h1h2h3[∂∂q1(h2h3A1)+∂∂q2(h3h1A2)+∂∂q3(h1h2A3)]\boxed{ \nabla\cdot\mathbf A =\frac{1}{h_1h_2h_3} \left[ \frac{\partial}{\partial q^1}(h_2h_3A_1) +\frac{\partial}{\partial q^2}(h_3h_1A_2) +\frac{\partial}{\partial q^3}(h_1h_2A_3) \right] }

This is the standard divergence formula for an orthogonal curvilinear coordinate system.

The physical and contravariant components are related by

Ai=Aihi.A^i=\frac{A_i}{h_i}.

Thus, if you use the scale-factor formula above, use physical components AiA_i consistently.

Cylindrical coordinates

Cylindrical coordinates (r,ϕ,z)(r,\phi,z) are defined by

x=rcos⁡ϕ,y=rsin⁡ϕ,z=z.x=r\cos\phi,\qquad y=r\sin\phi,\qquad z=z.

Their scale factors are

hr=1,hϕ=r,hz=1.h_r=1,\qquad h_\phi=r,\qquad h_z=1.

For

A=Ar er+Aϕ eϕ+Az ez,\mathbf A=A_r\,\mathbf e_r+A_\phi\,\mathbf e_\phi+A_z\,\mathbf e_z,

the divergence is therefore

∇⋅A=1r∂∂r(rAr)+1r∂Aϕ∂ϕ+∂Az∂z\boxed{ \nabla\cdot\mathbf A =\frac{1}{r}\frac{\partial}{\partial r}(rA_r) +\frac{1}{r}\frac{\partial A_\phi}{\partial\phi} +\frac{\partial A_z}{\partial z} }

Cylindrical example

Take

A=r2 er+rsin⁡ϕ eϕ+z2 ez.\mathbf A=r^2\,\mathbf e_r+r\sin\phi\,\mathbf e_\phi+z^2\,\mathbf e_z.

Thus Ar=r2A_r=r^2, Aϕ=rsin⁡ϕA_\phi=r\sin\phi, and Az=z2A_z=z^2. Substitute into the formula:

∇⋅A=1r∂∂r(r⋅r2)+1r∂∂ϕ(rsin⁡ϕ)+∂∂z(z2)=1r∂∂r(r3)+1r(rcos⁡ϕ)+2z=3r+cos⁡ϕ+2z.\begin{aligned} \nabla\cdot\mathbf A &=\frac{1}{r}\frac{\partial}{\partial r}(r\cdot r^2) +\frac{1}{r}\frac{\partial}{\partial\phi}(r\sin\phi) +\frac{\partial}{\partial z}(z^2)\\ &=\frac{1}{r}\frac{\partial}{\partial r}(r^3) +\frac{1}{r}(r\cos\phi)+2z\\ &=3r+\cos\phi+2z. \end{aligned}

The answer is

∇⋅A=3r+cos⁡ϕ+2z.\boxed{\nabla\cdot\mathbf A=3r+\cos\phi+2z.}

Spherical coordinates

Use the convention (r,θ,ϕ)(r,\theta,\phi) in which rr is radius, θ\theta is the polar angle measured from the positive zz-axis, and ϕ\phi is the azimuthal angle in the xyxy-plane:

x=rsin⁡θcos⁡ϕ,y=rsin⁡θsin⁡ϕ,z=rcos⁡θ.x=r\sin\theta\cos\phi,\qquad y=r\sin\theta\sin\phi,\qquad z=r\cos\theta.

The scale factors are

hr=1,hθ=r,hϕ=rsin⁡θ.h_r=1,\qquad h_\theta=r,\qquad h_\phi=r\sin\theta.

For

A=Ar er+Aθ eθ+Aϕ eϕ,\mathbf A=A_r\,\mathbf e_r+A_\theta\,\mathbf e_\theta+A_\phi\,\mathbf e_\phi,

the divergence becomes

∇⋅A=1r2∂∂r(r2Ar)+1rsin⁡θ∂∂θ(sin⁡θAθ)+1rsin⁡θ∂Aϕ∂ϕ\boxed{ \nabla\cdot\mathbf A =\frac{1}{r^2}\frac{\partial}{\partial r}(r^2A_r) +\frac{1}{r\sin\theta}\frac{\partial}{\partial\theta}(\sin\theta A_\theta) +\frac{1}{r\sin\theta}\frac{\partial A_\phi}{\partial\phi} }

Spherical example

Consider the radial field

A=r2 er.\mathbf A=r^2\,\mathbf e_r.

Here Ar=r2A_r=r^2 and Aθ=Aϕ=0A_\theta=A_\phi=0. Therefore

∇⋅A=1r2∂∂r(r2r2)=1r2∂∂r(r4)=1r2(4r3)=4r.\begin{aligned} \nabla\cdot\mathbf A &=\frac{1}{r^2}\frac{\partial}{\partial r}(r^2r^2)\\ &=\frac{1}{r^2}\frac{\partial}{\partial r}(r^4)\\ &=\frac{1}{r^2}(4r^3)=4r. \end{aligned}

Hence

∇⋅(r2er)=4r.\boxed{\nabla\cdot(r^2\mathbf e_r)=4r.}

More generally, for a purely radial spherical field A=f(r)er\mathbf A=f(r)\mathbf e_r,

∇⋅A=1r2ddr(r2f(r)).\nabla\cdot\mathbf A =\frac{1}{r^2}\frac{d}{dr}\left(r^2f(r)\right).

For example, A=er/r2\mathbf A=\mathbf e_r/r^2 has zero divergence wherever r≠0r\ne0, although it has a singular source at the origin in the distributional sense.

Common mistakes

Differentiating components without scale factors

The expression ∂Ar/∂r+∂Aθ/∂θ+∂Aϕ/∂ϕ\partial A_r/\partial r+\partial A_\theta/\partial\theta+\partial A_\phi/\partial\phi is not the divergence in spherical coordinates. The coordinate directions and area elements change with position.

Confusing angle conventions

Some books call the azimuthal angle θ\theta and the polar angle ϕ\phi, reversing the names used above. The formula must follow the definitions of the coordinates, not merely their symbols.

Mixing component types

The orthogonal formula uses components along unit vectors, such as Ar,Aθ,AϕA_r,A_\theta,A_\phi. The metric-determinant formula uses contravariant components AiA^i. Substituting one type into the other without the appropriate scale factors gives an incorrect result.

Ignoring singular coordinate locations

Cylindrical formulas contain 1/r1/r, and spherical formulas contain 1/(rsin⁡θ)1/(r\sin\theta). These factors reflect coordinate singularities at the axis or origin. A formula valid away from those locations may need separate analysis there, especially for fields with point or line sources.

References

  1. Mathematical Methods for Physicists, George B. Arfken, Hans J. Weber, and Frank E. Harris
  2. Mathematical Methods in the Physical Sciences, Mary L. Boas

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.