Skip to main content

Vector Algebra and Coordinate Systems

Electromagnetics is a field theory, so most quantities have direction as well as magnitude. The electric field E⃗\vec E, magnetic field intensity H⃗\vec H, flux densities D⃗\vec D and B⃗\vec B, current density J⃗\vec J, force F⃗\vec F, and area vector dS⃗d\vec S are all vectors. Before differentiating or integrating fields, we need reliable notation for positions, distances, unit vectors, dot products, cross products, and coordinate transformations.

The practical reason to learn multiple coordinate systems is symmetry. A line charge is natural in cylindrical coordinates, a point charge is natural in spherical coordinates, and a rectangular waveguide is natural in Cartesian coordinates. Choosing coordinates that match the geometry usually turns a hard integral into a short calculation. This page supports the vector calculus page and connects directly to vector differential calculus.

A cylindrical coordinate system marks radius, azimuth, and height around a vertical axis.

Figure: Cylindrical coordinates fit wires, coaxial cables, waveguides, and rotational symmetry. Image: Wikimedia Commons, Svjo, CC BY-SA 3.0.

A spherical coordinate system marks radial distance, polar angle, and azimuth angle on a sphere.

Figure: Spherical coordinates fit radiation, central forces, and three-dimensional angular structure. Image: Wikimedia Commons, SharkD, CC BY-SA 4.0.

Definitions​

A vector A⃗\vec A has magnitude ∣A⃗∣\vert \vec A\vert and direction. In Cartesian coordinates,

A⃗=Axx^+Ayy^+Azz^.\vec A=A_x\hat x+A_y\hat y+A_z\hat z.

The dot product measures projection:

A⃗⋅B⃗=∣A⃗∣∣B⃗∣cos⁡θ=AxBx+AyBy+AzBz.\vec A\cdot \vec B=|\vec A||\vec B|\cos\theta=A_xB_x+A_yB_y+A_zB_z.

The cross product creates a vector normal to the plane of A⃗\vec A and B⃗\vec B:

A⃗×B⃗=∣x^y^z^AxAyAzBxByBz∣.\vec A\times \vec B= \begin{vmatrix} \hat x & \hat y & \hat z\\ A_x & A_y & A_z\\ B_x & B_y & B_z \end{vmatrix}.

Its magnitude is ∣A⃗∣∣B⃗∣sin⁡θ\vert \vec A\vert \vert \vec B\vert \sin\theta, and its direction follows the right-hand rule.

The position vector in Cartesian coordinates is

r⃗=xx^+yy^+zz^.\vec r=x\hat x+y\hat y+z\hat z.

In cylindrical coordinates (ρ,ϕ,z)(\rho,\phi,z),

r⃗=ρρ^+zz^,x=ρcos⁡ϕ,y=ρsin⁡ϕ.\vec r=\rho\hat \rho+z\hat z,\qquad x=\rho\cos\phi,\qquad y=\rho\sin\phi.

In spherical coordinates (r,θ,ϕ)(r,\theta,\phi), where θ\theta is measured from +z+z and ϕ\phi in the xx-yy 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 differential lengths are

dl⃗cart=dxx^+dyy^+dzz^,dl⃗cyl=dρρ^+ρdϕϕ^+dzz^,dl⃗sph=drr^+rdθθ^+rsin⁡θdϕϕ^.\begin{aligned} d\vec l_{\text{cart}} &= dx\hat x+dy\hat y+dz\hat z,\\ d\vec l_{\text{cyl}} &= d\rho\hat\rho+\rho d\phi\hat\phi+dz\hat z,\\ d\vec l_{\text{sph}} &= dr\hat r+r d\theta\hat\theta+r\sin\theta d\phi\hat\phi. \end{aligned}

The corresponding volume elements are

dvcart=dx dy dz,dvcyl=ρ dρ dϕ dz,dvsph=r2sin⁡θ dr dθ dϕ.dv_{\text{cart}}=dx\,dy\,dz,\qquad dv_{\text{cyl}}=\rho\,d\rho\,d\phi\,dz,\qquad dv_{\text{sph}}=r^2\sin\theta\,dr\,d\theta\,d\phi.

These extra factors are scale factors. Cartesian coordinates have scale factors 1,1,11,1,1. Cylindrical coordinates have 1,ρ,11,\rho,1, because moving through a small azimuthal angle dϕd\phi traces an arc length ρdϕ\rho d\phi. Spherical coordinates have 1,r,rsin⁡θ1,r,r\sin\theta, because angular motion traces arcs whose radii depend on position. Whenever an integral looks suspiciously too simple in cylindrical or spherical coordinates, the missing scale factor is the first thing to check.

Coordinate singularities are not physical singularities by themselves. At ρ=0\rho=0, the unit vectors ρ^\hat\rho and ϕ^\hat\phi are not uniquely defined because every azimuth points to the same axis. At r=0r=0, spherical angular directions are undefined. A field may be perfectly finite at these locations even if the coordinate description is awkward, so distinguish coordinate artifacts from actual point sources or infinite field values.

Key results​

Coordinate unit vectors in curvilinear systems depend on position. In cylindrical coordinates,

ρ^=cos⁡ϕx^+sin⁡ϕy^,ϕ^=−sin⁡ϕx^+cos⁡ϕy^.\hat \rho=\cos\phi\hat x+\sin\phi\hat y,\qquad \hat \phi=-\sin\phi\hat x+\cos\phi\hat y.

In spherical coordinates,

r^=sin⁡θcos⁡ϕx^+sin⁡θsin⁡ϕy^+cos⁡θz^,θ^=cos⁡θcos⁡ϕx^+cos⁡θsin⁡ϕy^−sin⁡θz^,ϕ^=−sin⁡ϕx^+cos⁡ϕy^.\begin{aligned} \hat r &= \sin\theta\cos\phi\hat x+\sin\theta\sin\phi\hat y+\cos\theta\hat z,\\ \hat \theta &= \cos\theta\cos\phi\hat x+\cos\theta\sin\phi\hat y-\sin\theta\hat z,\\ \hat \phi &= -\sin\phi\hat x+\cos\phi\hat y. \end{aligned}

Distance vectors should be built carefully. If a source point is r⃗′\vec r' and an observation point is r⃗\vec r, the separation vector is

R⃗=r⃗−r⃗′,\vec R=\vec r-\vec r',

with magnitude R=∣R⃗∣R=\vert \vec R\vert and direction R^=R⃗/R\hat R=\vec R/R. Coulomb and Biot-Savart integrals repeatedly use this construction. A common error is to subtract coordinates in cylindrical or spherical form without accounting for changing unit vectors; when in doubt, convert to Cartesian components, subtract, then convert back if useful.

For areas, the vector direction is essential. Examples include

dS⃗ρ=ρdϕdz ρ^,dS⃗r=r2sin⁡θdθdϕ r^.d\vec S_{\rho}=\rho d\phi dz\,\hat\rho,\qquad d\vec S_{r}=r^2\sin\theta d\theta d\phi\,\hat r.

The sign of flux integrals depends on choosing the outward normal for closed surfaces or the normal specified by the right-hand rule for open surfaces bounded by a contour.

The unit-vector transformations also provide a reliable way to transform vector components. A physical vector does not change when coordinates change, but its component list does. For example, a vector in the xx direction has cylindrical components that vary with ϕ\phi because

x^=cos⁡ϕρ^−sin⁡ϕϕ^.\hat x=\cos\phi\hat\rho-\sin\phi\hat\phi.

This position dependence explains why differentiating vector fields in cylindrical and spherical coordinates is more complicated than differentiating their scalar component functions.

Triple products appear often in force and power manipulations:

A⃗⋅(B⃗×C⃗)=B⃗⋅(C⃗×A⃗),\vec A\cdot(\vec B\times\vec C)=\vec B\cdot(\vec C\times\vec A),

and

A⃗×(B⃗×C⃗)=B⃗(A⃗⋅C⃗)−C⃗(A⃗⋅B⃗).\vec A\times(\vec B\times\vec C)=\vec B(\vec A\cdot\vec C)-\vec C(\vec A\cdot\vec B).

These identities are not decorative; they simplify torque, magnetic force, and Poynting vector expressions.

As a final check, every coordinate choice should preserve physical length, area, volume, and direction. If two coordinate descriptions give different distances or fluxes for the same geometry, the error is in the representation, not in the physics.

Visual​

Coordinate systemBest forLength elementVolume element
Cartesianplanes, rectangular cavities, waveguidesdxx^+dyy^+dzz^dx\hat x+dy\hat y+dz\hat zdx dy dzdx\,dy\,dz
Cylindricalwires, coax, circular loopsdρρ^+ρdϕϕ^+dzz^d\rho\hat\rho+\rho d\phi\hat\phi+dz\hat zρ dρ dϕ dz\rho\,d\rho\,d\phi\,dz
Sphericalpoint charges, spheres, radiation distancedrr^+rdθθ^+rsin⁡θdϕϕ^dr\hat r+r d\theta\hat\theta+r\sin\theta d\phi\hat\phir2sin⁡θ dr dθ dϕr^2\sin\theta\,dr\,d\theta\,d\phi

Worked example 1: Distance vector in cylindrical coordinates​

Problem: A source point is at (ρ′,ϕ′,z′)=(2,30∘,1)(\rho',\phi',z')=(2,30^\circ,1) m and an observation point is at (ρ,ϕ,z)=(5,120∘,4)(\rho,\phi,z)=(5,120^\circ,4) m. Find R⃗=r⃗−r⃗′\vec R=\vec r-\vec r' and RR.

Step 1: Convert each point to Cartesian coordinates. For the observation point,

x=5cos⁡120∘=−2.5,y=5sin⁡120∘=4.330,z=4.\begin{aligned} x&=5\cos120^\circ=-2.5,\\ y&=5\sin120^\circ=4.330,\\ z&=4. \end{aligned}

For the source point,

x′=2cos⁡30∘=1.732,y′=2sin⁡30∘=1.000,z′=1.\begin{aligned} x'&=2\cos30^\circ=1.732,\\ y'&=2\sin30^\circ=1.000,\\ z'&=1. \end{aligned}

Step 2: Subtract coordinates:

R⃗=(−2.5−1.732)x^+(4.330−1.000)y^+(4−1)z^.\vec R=(-2.5-1.732)\hat x+(4.330-1.000)\hat y+(4-1)\hat z.

Thus

R⃗=−4.232x^+3.330y^+3z^ m.\vec R=-4.232\hat x+3.330\hat y+3\hat z\ \mathrm{m}.

Step 3: Compute magnitude:

R=(−4.232)2+(3.330)2+32=6.16 m.R=\sqrt{(-4.232)^2+(3.330)^2+3^2}=6.16\ \mathrm{m}.

Check: The vertical difference alone is 33 m, so a total distance of 6.166.16 m is plausible.

Worked example 2: Surface area of a spherical cap​

Problem: Find the area of the spherical surface r=ar=a between 0≤θ≤θ00\le\theta\le\theta_0 and 0≤ϕ≤2π0\le\phi\le2\pi.

Step 1: Use the spherical area element normal to r^\hat r:

dS=a2sin⁡θ dθ dϕ.dS=a^2\sin\theta\,d\theta\,d\phi.

Step 2: Integrate over the cap:

S=∫02π∫0θ0a2sin⁡θ dθ dϕ.S=\int_0^{2\pi}\int_0^{\theta_0}a^2\sin\theta\,d\theta\,d\phi.

Step 3: Evaluate the inner integral:

∫0θ0sin⁡θ dθ=[−cos⁡θ]0θ0=1−cos⁡θ0.\int_0^{\theta_0}\sin\theta\,d\theta =\left[-\cos\theta\right]_0^{\theta_0} =1-\cos\theta_0.

Step 4: Evaluate the outer integral:

S=2πa2(1−cos⁡θ0).S=2\pi a^2(1-\cos\theta_0).

Check: If θ0=π\theta_0=\pi, the cap is the full sphere and S=2πa2(1−cos⁡π)=4πa2S=2\pi a^2(1-\cos\pi)=4\pi a^2.

Code​

import numpy as np

def cyl_to_cart(rho, phi_deg, z):
phi = np.deg2rad(phi_deg)
return np.array([rho * np.cos(phi), rho * np.sin(phi), z], dtype=float)

source = cyl_to_cart(2, 30, 1)
obs = cyl_to_cart(5, 120, 4)
R_vec = obs - source
R_mag = np.linalg.norm(R_vec)

print("source =", source)
print("observer =", obs)
print("R vector =", R_vec)
print("R magnitude =", R_mag)

Common pitfalls​

  • Treating ρ^\hat\rho, ϕ^\hat\phi, r^\hat r, and θ^\hat\theta as constant everywhere. They rotate with position.
  • Omitting metric factors such as ρ\rho, rr, and rsin⁡θr\sin\theta from differential lengths, areas, or volumes.
  • Using θ\theta as the azimuth angle in spherical coordinates. In the convention used here, θ\theta is measured down from +z+z and ϕ\phi is azimuth.
  • Forgetting that dS⃗d\vec S has direction. Flux signs depend on the chosen normal.
  • Subtracting curvilinear coordinate triples directly to form distance vectors.
  • Reversing cross-product order. A⃗×B⃗=−(B⃗×A⃗)\vec A\times\vec B=-(\vec B\times\vec A).
  • Assuming a coordinate transformation changes the physical vector. Only the basis and component representation change.

Connections​