TExcelTAD
Home › Electromagnetic Theory: Maxwell's Equations to Waves › Vectors and Coordinate Systems for Fields

Vectors and Coordinate Systems for Fields

A circuit has a handful of node voltages; a field has a value at every point of space. To describe the electric field around a coaxial cable, the magnetic field inside a toroid or the wave leaving an antenna, you need three things this lesson sets up: vectors written in components, the three coordinate systems that match the shapes engineers build (boxes, cylinders, spheres), and the small length, area and volume elements that every field integral in the course is built from. The maths is in Vectors, The Dot Product, The Cross Product, Cylindrical Coordinates and Spherical Coordinates; here we use it the way field problems need it.

Vectors in components

A vector field assigns a vector to every point, for example E(x,y,z)\mathbf{E}(x, y, z) in volts per metre. In Cartesian coordinates

A=Axx^+Ayy^+Azz^,∣A∣=Ax2+Ay2+Az2\mathbf{A} = A_x \hat{\mathbf{x}} + A_y \hat{\mathbf{y}} + A_z \hat{\mathbf{z}}, \qquad \lvert \mathbf{A} \rvert = \sqrt{A_x^2 + A_y^2 + A_z^2}

Two products appear in every chapter. The dot product A⋅B=AxBx+AyBy+AzBz=∣A∣∣B∣cos⁡θAB\mathbf{A} \cdot \mathbf{B} = A_x B_x + A_y B_y + A_z B_z = \lvert \mathbf{A} \rvert \lvert \mathbf{B} \rvert \cos\theta_{AB} takes the component of one vector along another: work F⋅dl\mathbf{F} \cdot d\mathbf{l}, flux D⋅dS\mathbf{D} \cdot d\mathbf{S}, power S⋅n^\mathbf{S} \cdot \hat{\mathbf{n}}. The cross product A×B\mathbf{A} \times \mathbf{B} is perpendicular to both, with magnitude ∣A∣∣B∣sin⁡θAB\lvert \mathbf{A} \rvert \lvert \mathbf{B} \rvert \sin\theta_{AB} and the right-hand rule for its direction: the magnetic force qv×Bq\mathbf{v} \times \mathbf{B}, the Biot–Savart law dl×R^d\mathbf{l} \times \hat{\mathbf{R}}, the Poynting vector E×H\mathbf{E} \times \mathbf{H}.

The vector you will write most often is the distance vector from a source point r′\mathbf{r}' (where a charge or current sits) to a field point r\mathbf{r} (where you want the field):

R=r−r′,R=∣R∣,R^=RR\mathbf{R} = \mathbf{r} - \mathbf{r}', \qquad R = \lvert \mathbf{R} \rvert, \qquad \hat{\mathbf{R}} = \frac{\mathbf{R}}{R}

Primed coordinates mark the source, unprimed the observer. Getting the order wrong flips every field you compute.

Three coordinate systems

xyz phi rho z rho-hatphi-hatz-hat P cylindrical (rho, phi, z) xyz phi r theta r-hattheta-hatphi-hat P spherical (r, theta, phi)

Cylindrical (ρ,ϕ,z)(\rho, \phi, z): ρ\rho is the distance from the zz axis, ϕ\phi the angle from the xx axis in the xyxy-plane, zz the height. Use it for wires, coaxial cables, solenoids and anything with an axis. Spherical (r,θ,ϕ)(r, \theta, \phi): rr is the distance from the origin, θ\theta the polar angle measured from the +z+z axis (00 to π\pi), ϕ\phi the same azimuth as in cylindrical. Use it for point charges, spheres and antennas far away. The conversions are

x=ρcos⁡ϕ,y=ρsin⁡ϕ,ρ=x2+y2,ϕ=atan2⁡(y,x)ρ=rsin⁡θ,z=rcos⁡θ,r=x2+y2+z2,θ=arccos⁡(z/r)\begin{aligned} x &= \rho\cos\phi, & y &= \rho\sin\phi, & \rho &= \sqrt{x^2 + y^2}, & \phi &= \operatorname{atan2}(y, x) \\ \rho &= r\sin\theta, & z &= r\cos\theta, & r &= \sqrt{x^2 + y^2 + z^2}, & \theta &= \arccos(z/r) \end{aligned}

The important difference from Cartesian coordinates is that ρ^\hat{\boldsymbol{\rho}}, ϕ^\hat{\boldsymbol{\phi}}, r^\hat{\mathbf{r}} and θ^\hat{\boldsymbol{\theta}} change direction from point to point. They are still orthonormal at each point, so dot products work component by component, but you cannot pull them out of an integral as constants: ∫ρ^ dϕ\int \hat{\boldsymbol{\rho}}\, d\phi around a circle is zero, not 2πρ^2\pi\hat{\boldsymbol{\rho}}. Convert to x^,y^,z^\hat{\mathbf{x}}, \hat{\mathbf{y}}, \hat{\mathbf{z}} before integrating a vector.

Converting a vector (not just a point) means projecting it on the new unit vectors at that point:

Aρ=Axcos⁡ϕ+Aysin⁡ϕ,Aϕ=−Axsin⁡ϕ+Aycos⁡ϕAr=Aρsin⁡θ+Azcos⁡θ,Aθ=Aρcos⁡θ−Azsin⁡θ\begin{aligned} A_\rho &= A_x\cos\phi + A_y\sin\phi, & A_\phi &= -A_x\sin\phi + A_y\cos\phi \\ A_r &= A_\rho\sin\theta + A_z\cos\theta, & A_\theta &= A_\rho\cos\theta - A_z\sin\theta \end{aligned}

Length, area and volume elements

Integrals of fields add up contributions over small pieces of a path, surface or volume. A small step in a coordinate does not always move you the same distance: a step dϕd\phi moves you ρ dϕ\rho\,d\phi in cylindrical and rsin⁡θ dϕr\sin\theta\,d\phi in spherical coordinates. These scale factors appear in every element:

System dld\mathbf{l} dVdV Typical dSdS
Cartesian dx x^+dy y^+dz z^dx\,\hat{\mathbf{x}} + dy\,\hat{\mathbf{y}} + dz\,\hat{\mathbf{z}} dx dy dzdx\,dy\,dz dx dydx\,dy on a plane $z = $ const
Cylindrical dρ ρ^+ρ dϕ ϕ^+dz z^d\rho\,\hat{\boldsymbol{\rho}} + \rho\,d\phi\,\hat{\boldsymbol{\phi}} + dz\,\hat{\mathbf{z}} ρ dρ dϕ dz\rho\,d\rho\,d\phi\,dz ρ dϕ dz\rho\,d\phi\,dz on a cylinder $\rho = $ const
Spherical dr r^+r dθ θ^+rsin⁡θ dϕ ϕ^dr\,\hat{\mathbf{r}} + r\,d\theta\,\hat{\boldsymbol{\theta}} + r\sin\theta\,d\phi\,\hat{\boldsymbol{\phi}} r2sin⁡θ dr dθ dϕr^2\sin\theta\,dr\,d\theta\,d\phi r2sin⁡θ dθ dϕr^2\sin\theta\,d\theta\,d\phi on a sphere $r = $ const

A vector surface element dS=n^ dSd\mathbf{S} = \hat{\mathbf{n}}\,dS points along the outward normal of a closed surface. Check any element by integrating it over a familiar shape: ∫02π∫0πr2sin⁡θ dθ dϕ=4πr2\int_0^{2\pi}\int_0^{\pi} r^2\sin\theta\,d\theta\,d\phi = 4\pi r^2, the area of a sphere.

Worked example

Given: a field point PP at (x,y,z)=(1,2,2) m(x, y, z) = (1, 2, 2)\ \text{m} and, at PP, the vector A=3x^+4y^\mathbf{A} = 3\hat{\mathbf{x}} + 4\hat{\mathbf{y}} (in any unit, say V/m\text{V/m}). A point charge sits at r′=(0,0,1) m\mathbf{r}' = (0, 0, 1)\ \text{m}.

Find: the cylindrical and spherical coordinates of PP, the components of A\mathbf{A} in both systems, and the unit vector from the charge to PP.

Solve:

ρ=1+4=2.236 m,ϕ=atan2⁡(2,1)=63.43∘,r=1+4+4=3 m,θ=arccos⁡(2/3)=48.19∘Aρ=3⋅1+4⋅25=4.919,Aϕ=−3⋅2+4⋅15=−0.894,Az=0Ar=4.919⋅53+0=3.667,Aθ=4.919⋅23−0=3.279R=(1,2,2)−(0,0,1)=(1,2,1) m,R=6=2.449 m,R^=(0.408,0.816,0.408)\begin{aligned} \rho &= \sqrt{1 + 4} = 2.236\ \text{m}, \quad \phi = \operatorname{atan2}(2, 1) = 63.43^\circ, \quad r = \sqrt{1 + 4 + 4} = 3\ \text{m}, \quad \theta = \arccos(2/3) = 48.19^\circ \\ A_\rho &= \frac{3 \cdot 1 + 4 \cdot 2}{\sqrt{5}} = 4.919, \qquad A_\phi = \frac{-3 \cdot 2 + 4 \cdot 1}{\sqrt{5}} = -0.894, \qquad A_z = 0 \\ A_r &= 4.919 \cdot \frac{\sqrt{5}}{3} + 0 = 3.667, \qquad A_\theta = 4.919 \cdot \frac{2}{3} - 0 = 3.279 \\ \mathbf{R} &= (1, 2, 2) - (0, 0, 1) = (1, 2, 1)\ \text{m}, \qquad R = \sqrt{6} = 2.449\ \text{m}, \qquad \hat{\mathbf{R}} = (0.408, 0.816, 0.408) \end{aligned}

Check: the length of a vector does not depend on the coordinates: 4.9192+0.8942=5.000\sqrt{4.919^2 + 0.894^2} = 5.000 and 3.6672+3.2792+0.8942=5.000\sqrt{3.667^2 + 3.279^2 + 0.894^2} = 5.000, equal to 32+42\sqrt{3^2 + 4^2}.

In Python

The conversions are a few lines of NumPy. The second part checks the volume element by adding up ρ Δρ Δϕ Δz\rho\,\Delta\rho\,\Delta\phi\,\Delta z over the dielectric of a coaxial cable (inner radius aa, outer radius bb) and comparing with the exact π(b2−a2)L\pi(b^2 - a^2)L.

python · try it yourself
import numpy as np

def to_cyl(x, y, z):
    return np.hypot(x, y), np.arctan2(y, x), z

def to_sph(x, y, z):
    r = np.sqrt(x*x + y*y + z*z)
    return r, np.arccos(z / r), np.arctan2(y, x)

def vec_cart_to_cyl_sph(A, x, y, z):
    rho, phi, _ = to_cyl(x, y, z)
    r, th, _ = to_sph(x, y, z)
    Ax, Ay, Az = A
    Arho = Ax*np.cos(phi) + Ay*np.sin(phi)
    Aphi = -Ax*np.sin(phi) + Ay*np.cos(phi)
    Ar = Arho*np.sin(th) + Az*np.cos(th)
    Ath = Arho*np.cos(th) - Az*np.sin(th)
    return (Arho, Aphi, Az), (Ar, Ath, Aphi)

P = (1.0, 2.0, 2.0)
rho, phi, z = to_cyl(*P)
r, th, _ = to_sph(*P)
print(f"cylindrical: rho = {rho:.3f} m, phi = {np.degrees(phi):.2f} deg, z = {z:.1f} m")
print(f"spherical:   r = {r:.3f} m, theta = {np.degrees(th):.2f} deg")
cyl, sph = vec_cart_to_cyl_sph((3.0, 4.0, 0.0), *P)
print("A cylindrical:", [round(float(v), 3) for v in cyl])
print("A spherical:  ", [round(float(v), 3) for v in sph])
print(f"|A| in both: {np.linalg.norm(cyl):.4f}, {np.linalg.norm(sph):.4f}")

R = np.array(P) - np.array([0.0, 0.0, 1.0])
print("R-hat =", np.round(R / np.linalg.norm(R), 3))

# volume of a coax dielectric per metre by summing rho*drho*dphi*dz (midpoint rule)
a, b, L = 0.45e-3, 1.475e-3, 1.0
n = 200
rho_mid = a + (np.arange(n) + 0.5) * (b - a) / n
V_sum = np.sum(rho_mid * (b - a) / n) * 2*np.pi * L
V_exact = np.pi * (b**2 - a**2) * L
print(f"dielectric volume: sum {V_sum*1e6:.4f} cm^3, exact {V_exact*1e6:.4f} cm^3")
cylindrical: rho = 2.236 m, phi = 63.43 deg, z = 2.0 m
spherical:   r = 3.000 m, theta = 48.19 deg
A cylindrical: [4.919, -0.894, 0.0]
A spherical:   [3.667, 3.28, -0.894]
|A| in both: 5.0000, 5.0000
R-hat = [0.408 0.816 0.408]
dielectric volume: sum 6.1988 cm^3, exact 6.1988 cm^3

The sum of ρ Δρ\rho\,\Delta\rho over thin rings gives the exact area, because the midpoint rule is exact for a linear integrand; leave out the factor ρ\rho (a common slip) and the result is off by a factor equal to the mean radius, and in square metres instead of cubic metres.

Guided lab: the dielectric of a coaxial cable

The coaxial cable comes back in Gauss's Law for Symmetric Charge Distributions, Capacitance of Common Geometries and the mini project, so it is worth measuring one now.

Hand calculation. For a thin 50 Ω50\ \Omega cable with a 0.90 mm0.90\ \text{mm} centre conductor and a 2.95 mm2.95\ \text{mm} solid polyethylene dielectric, the cross-section of the dielectric is ∫02π∫abρ dρ dϕ=π(b2−a2)=6.20 mm2\int_0^{2\pi}\int_a^b \rho\,d\rho\,d\phi = \pi(b^2 - a^2) = 6.20\ \text{mm}^2, so 10 cm10\ \text{cm} of it holds 0.620 cm30.620\ \text{cm}^3. With polyethylene at about 0.92 g/cm30.92\ \text{g/cm}^3 that is 0.57 g0.57\ \text{g}.

Simulation. The Python sum above reproduces the volume to four figures.

What you would measure. Cut 10.0 cm10.0\ \text{cm} of cable, strip the jacket and braid, and measure both diameters with a caliper at three places (resolution 0.01 mm0.01\ \text{mm}; expect a scatter of about ±0.01\pm 0.01 to 0.02 mm0.02\ \text{mm}). Pull the centre conductor out and weigh the dielectric on a 0.01 g0.01\ \text{g} scale. A ±0.01 mm\pm 0.01\ \text{mm} uncertainty in each radius gives about ±1.6 %\pm 1.6\ \% in the area; the scale's ±0.01 g\pm 0.01\ \text{g} is another ±2 %\pm 2\ \%, so agreement within about 3 %3\ \% is the expected result. Foamed dielectrics weigh much less: if your sample comes in at a half or a third of the prediction, it is foam, and its permittivity will be lower too.

Hazards and safe setup. No electricity is involved. Use a cable stripper or cut away from your hand, and wear eye protection when snipping braid strands.

Pitfalls

  • Unit vectors that move. ρ^\hat{\boldsymbol{\rho}} at ϕ=0\phi = 0 is x^\hat{\mathbf{x}}; at ϕ=90∘\phi = 90^\circ it is y^\hat{\mathbf{y}}. Never integrate a vector field written in ρ^\hat{\boldsymbol{\rho}}, ϕ^\hat{\boldsymbol{\phi}}, r^\hat{\mathbf{r}}, θ^\hat{\boldsymbol{\theta}} without first asking whether the unit vector is constant over the region.
  • Two different ρ\rho. In this course ρ\rho alone is the cylindrical radius; charge densities always carry a subscript: ρv\rho_v (volume), ρs\rho_s (surface), ρℓ\rho_\ell (line).
  • θ\theta and ϕ\phi swapped. Engineering and physics books use θ\theta from the zz axis and ϕ\phi for the azimuth, as here; many mathematics texts swap them. Check before copying a formula.
  • atan instead of atan2. arctan⁡(y/x)\arctan(y/x) loses the quadrant: the point (−1,−1)(-1, -1) is at ϕ=225∘\phi = 225^\circ, not 45∘45^\circ.

Practice

  1. Convert P(−2,2,1) mP(-2, 2, 1)\ \text{m} to cylindrical and spherical coordinates.
  2. At PP, the field is E=10ρ^ V/m\mathbf{E} = 10\hat{\boldsymbol{\rho}}\ \text{V/m}. Write it in Cartesian components.
  3. Using dVdV in spherical coordinates, find the volume between r=1r = 1 and r=2 mr = 2\ \text{m} inside the cone θ≤30∘\theta \le 30^\circ.
  4. A charge at (1,1,0) m(1, 1, 0)\ \text{m} and a field point at (4,5,0) m(4, 5, 0)\ \text{m}: find RR and R^\hat{\mathbf{R}}.
Answer
  1. ρ=8=2.828 m\rho = \sqrt{8} = 2.828\ \text{m}, ϕ=135∘\phi = 135^\circ, z=1 mz = 1\ \text{m}; r=3 mr = 3\ \text{m}, θ=arccos⁡(1/3)=70.53∘\theta = \arccos(1/3) = 70.53^\circ.
  2. ρ^=cos⁡ϕ x^+sin⁡ϕ y^=−0.707x^+0.707y^\hat{\boldsymbol{\rho}} = \cos\phi\,\hat{\mathbf{x}} + \sin\phi\,\hat{\mathbf{y}} = -0.707\hat{\mathbf{x}} + 0.707\hat{\mathbf{y}}, so E=−7.07x^+7.07y^ V/m\mathbf{E} = -7.07\hat{\mathbf{x}} + 7.07\hat{\mathbf{y}}\ \text{V/m}.
  3. ∫02π∫0π/6∫12r2sin⁡θ dr dθ dϕ=2π(1−cos⁡30∘)73=1.964 m3\int_0^{2\pi}\int_0^{\pi/6}\int_1^2 r^2\sin\theta\,dr\,d\theta\,d\phi = 2\pi(1 - \cos 30^\circ)\frac{7}{3} = 1.964\ \text{m}^3.
  4. R=(3,4,0) m\mathbf{R} = (3, 4, 0)\ \text{m}, R=5 mR = 5\ \text{m}, R^=(0.6,0.8,0)\hat{\mathbf{R}} = (0.6, 0.8, 0).

Test yourself

In spherical coordinates, a small step dϕd\phi in azimuth moves a point by a distance…

  1. dϕd\phi
  2. r dϕr\,d\phi
  3. rsin⁡θ dϕr\sin\theta\,d\phi
  4. r2sin⁡θ dϕr^2\sin\theta\,d\phi

Why can't you write ∫02πρ^ dϕ=2πρ^\int_0^{2\pi} \hat{\boldsymbol{\rho}}\,d\phi = 2\pi\hat{\boldsymbol{\rho}}?

  1. ρ^\hat{\boldsymbol{\rho}} is not a unit vector
  2. ρ^\hat{\boldsymbol{\rho}} changes direction with ϕ\phi, and the integral is actually zero
  3. the integral should be over ρ\rho, not ϕ\phi
  4. ρ^\hat{\boldsymbol{\rho}} has no zz component

A source charge sits at r′\mathbf{r}' and you want the field at r\mathbf{r}. The distance vector in Coulomb's law is…

  1. r′−r\mathbf{r}' - \mathbf{r}
  2. r−r′\mathbf{r} - \mathbf{r}'
  3. r+r′\mathbf{r} + \mathbf{r}'
  4. r×r′\mathbf{r} \times \mathbf{r}'

The point (x,y,z)=(0,3,4) m(x, y, z) = (0, 3, 4)\ \text{m} in spherical coordinates is…

  1. r=5 mr = 5\ \text{m}, θ=36.87∘\theta = 36.87^\circ, ϕ=90∘\phi = 90^\circ
  2. r=5 mr = 5\ \text{m}, θ=53.13∘\theta = 53.13^\circ, ϕ=0∘\phi = 0^\circ
  3. r=7 mr = 7\ \text{m}, θ=36.87∘\theta = 36.87^\circ, ϕ=90∘\phi = 90^\circ
  4. r=5 mr = 5\ \text{m}, θ=90∘\theta = 90^\circ, ϕ=36.87∘\phi = 36.87^\circ