Vector analysis and coordinate systems

Vectors, the three coordinate systems, and gradient, divergence and curl with the divergence and Stokes' theorems that every field law is written in.

Drafted with Aria, reviewed by the AiCanCode.org team. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Every law in electromagnetics — Coulomb, Gauss, Ampere, Faraday, Maxwell — is written in the language of vectors and vector calculus. If you can pick the coordinate system that matches the symmetry of a problem and handle dot products, cross products, gradient, divergence and curl without slips, most field problems reduce to a few lines of algebra. Instrumentation work (capacitive and inductive sensors, coaxial cables, Hall probes) uses exactly these tools.

Key ideas

Scalars and vectors. A scalar has magnitude only (charge, potential V, energy). A vector has magnitude and direction (E, D, H, B, force). A unit vector a_A = A / |A| has magnitude 1 and carries only direction.

Dot product gives a scalar: the product of one vector's magnitude and the projection of the other onto it. A·B = 0 means the vectors are perpendicular. It is used for work (F·dl), flux (D·dS) and the component of a vector along a direction (A·a_n).

Cross product gives a vector perpendicular to both, with direction from the right-hand rule: fingers along A, curl them towards B, the thumb points along A × B. It is anti-commutative: B × A = −(A × B). A × B = 0 for parallel vectors. |A × B| is the area of the parallelogram formed by A and B. Used for force on a current (I dl × B), torque (r × F) and the Biot–Savart law.

Coordinate systems. Choose the one whose surfaces match the geometry:

  • Cartesian (x, y, z): planes, sheets of charge, rectangular plates.
  • Cylindrical (ρ, φ, z): line charges, wires, coaxial cables. ρ is the perpendicular distance from the z-axis, φ is measured from the x-axis.
  • Spherical (r, θ, φ): point charges, spheres. r is the distance from the origin, θ is the polar angle from the +z axis (0 to π), φ the azimuth (0 to 2π).

Unit vectors a_x, a_y, a_z are constant everywhere; a_ρ, a_φ, a_r, a_θ change direction from point to point, so they cannot be pulled outside an integral without first converting to Cartesian components.

Differential elements. Line, surface and volume elements carry the scale factors (1, ρ, r, r sin θ). Forgetting the ρ in ρ dφ or the r² sin θ in the spherical volume element is the most common integration error.

Vector calculus.

  • Gradient ∇V: a vector pointing in the direction of the fastest increase of a scalar field; its magnitude is that maximum rate. In electrostatics E = −∇V.
  • Divergence ∇·A: a scalar giving the net outward flux per unit volume at a point (a source or sink density). ∇·D = ρv.
  • Curl ∇×A: a vector giving the circulation per unit area about a point (rotation). ∇×H = J. A field with zero curl everywhere is conservative (irrotational); a field with zero divergence is solenoidal.
  • Divergence theorem: ∮ A·dS = ∫ (∇·A) dv — converts a closed-surface flux into a volume integral.
  • Stokes' theorem: ∮ A·dl = ∫ (∇×A)·dS — converts a closed-line integral into a surface integral.
  • Two identities that hold for any smooth field: ∇×(∇V) = 0 and ∇·(∇×A) = 0.

Formulas

  • A·B = |A||B| cos θ = AxBx + AyBy + AzBz — θ is the angle between A and B; the result is a scalar.
  • A × B = |A||B| sin θ a_n = (AyBz − AzBy) a_x + (AzBx − AxBz) a_y + (AxBy − AyBx) a_z — a_n is the unit normal given by the right-hand rule.
  • ρ = √(x² + y²), φ = tan⁻¹(y/x), z = z — Cartesian to cylindrical (pick the quadrant of φ from the signs of x and y).
  • r = √(x² + y² + z²), θ = cos⁻¹(z/r), φ = tan⁻¹(y/x) — Cartesian to spherical.
  • dv = dx dy dz = ρ dρ dφ dz = r² sin θ dr dθ dφ — volume elements (m³).
  • ∇V = ∂V/∂x a_x + ∂V/∂y a_y + ∂V/∂z a_z (Cartesian); ∇V = ∂V/∂ρ a_ρ + (1/ρ) ∂V/∂φ a_φ + ∂V/∂z a_z (cylindrical); ∇V = ∂V/∂r a_r + (1/r) ∂V/∂θ a_θ + (1/(r sin θ)) ∂V/∂φ a_φ (spherical).
  • ∇·A = ∂Ax/∂x + ∂Ay/∂y + ∂Az/∂z (Cartesian); ∇·A = (1/ρ) ∂(ρAρ)/∂ρ + (1/ρ) ∂Aφ/∂φ + ∂Az/∂z (cylindrical); ∇·A = (1/r²) ∂(r²Ar)/∂r + (1/(r sin θ)) ∂(sin θ Aθ)/∂θ + (1/(r sin θ)) ∂Aφ/∂φ (spherical).
  • ∇×A = (∂Az/∂y − ∂Ay/∂z) a_x + (∂Ax/∂z − ∂Az/∂x) a_y + (∂Ay/∂x − ∂Ax/∂y) a_z (Cartesian).
  • ∮ A·dS = ∫ (∇·A) dv (divergence theorem); ∮ A·dl = ∫ (∇×A)·dS (Stokes' theorem) — both need A and its derivatives continuous in the region.

Worked examples

Example 1 (standard). Given A = 3a_x + 4a_y + 5a_z and B = 2a_x − a_y + 3a_z, find A·B, A × B, the angle between them and the scalar component of A along B.

  1. A·B = AxBx + AyBy + AzBz = (3)(2) + (4)(−1) + (5)(3) = 6 − 4 + 15 = 17.
  2. A × B: x-component = (4)(3) − (5)(−1) = 17; y-component = (5)(2) − (3)(3) = 1; z-component = (3)(−1) − (4)(2) = −11. So A × B = 17a_x + a_y − 11a_z.
  3. |A| = √(9 + 16 + 25) = √50 = 7.071; |B| = √(4 + 1 + 9) = √14 = 3.742.
  4. cos θ = A·B / (|A||B|) = 17 / (7.071 × 3.742) = 0.6425, so θ = 50.0°.
  5. Scalar component of A along B = A·B / |B| = 17 / 3.742 = 4.54. Check: (A × B)·A = 51 + 4 − 55 = 0, so the cross product is perpendicular to A, as it must be.

Example 2 (GATE level). D = ρ² a_ρ C/m² in cylindrical coordinates. Verify the divergence theorem for the closed cylinder ρ ≤ 2 m, 0 ≤ z ≤ 1 m.

  1. Divergence: ∇·D = (1/ρ) ∂(ρ·ρ²)/∂ρ = (1/ρ)(3ρ²) = 3ρ C/m³.
  2. Volume integral: ∫ 3ρ · ρ dρ dφ dz over ρ from 0 to 2, φ from 0 to 2π, z from 0 to 1 = 3 × (2³/3) × 2π × 1 = 16π = 50.27 C.
  3. Surface integral. The top and bottom faces have normals ±a_z, and D has no z-component, so they contribute zero. On the curved face ρ = 2 m, dS = ρ dφ dz a_ρ, so ∮ D·dS = ρ² × ρ × 2π × h = 2³ × 2π × 1 = 16π = 50.27 C.
  4. Both sides agree, so the theorem is verified; by Gauss's law, 50.27 C is also the charge enclosed.

Example 3 (conversion). Express the point P(1, √3, 2) in cylindrical and spherical coordinates.

  1. ρ = √(1 + 3) = 2 m; φ = tan⁻¹(√3/1) = 60°; z = 2 m → P(2, 60°, 2).
  2. r = √(1 + 3 + 4) = √8 = 2.828 m; θ = cos⁻¹(2/2.828) = 45°; φ = 60° → P(2.828, 45°, 60°).

Common mistakes

  • Writing ∇·A in cylindrical or spherical form as ∂Aρ/∂ρ + … without the scale factors (1/ρ)∂(ρAρ)/∂ρ, (1/r²)∂(r²Ar)/∂r.
  • Treating a_ρ or a_r as constants and taking them outside an integral — for example, integrating a_ρ around a full circle gives zero, not 2π a_ρ.
  • Getting the cross-product sign wrong: a_x × a_y = a_z, a_y × a_z = a_x, a_z × a_x = a_y (cyclic order); reversing the order flips the sign.
  • Using the wrong quadrant for φ = tan⁻¹(y/x) when x < 0.
  • Confusing θ (spherical polar angle, from +z) with φ (azimuth, from +x).
  • Forgetting ρ in the surface element ρ dφ dz of a cylinder, or r² sin θ in the spherical surface element.

For GATE IN

Expect short MCQ/NAT questions on: divergence or curl of a given field (often in cylindrical or spherical form), checking whether a field is conservative or solenoidal, the gradient of a potential at a point, unit normals, the angle between vectors, and applying the divergence or Stokes' theorem to save effort on a flux or circulation integral. Practise the three del-operator forms until you can write them from memory, and always look for symmetry before integrating.

Quick check

  1. What is the dot product of two perpendicular vectors?
  2. What is ∇·(ρ a_ρ) in cylindrical coordinates?
  3. What is the curl of the gradient of any scalar field?
  4. Is B × A equal to A × B?
  5. What is |A × B| for A = 3a_x + 4a_y and B = 5a_z?

Answers: 1. Zero. 2. 2. 3. Zero (the null vector). 4. No, B × A = −(A × B). 5. 25.

Try answering each one aloud before you open it.

  1. 1.What is a vector, and how is it different from a scalar?Concept

    A vector is a quantity that has both magnitude and direction, such as velocity or force. In contrast, a scalar is a quantity that has only magnitude, such as temperature or mass. Vectors are often represented graphically by arrows, where the length of the arrow indicates the magnitude and the direction of the arrow indicates the direction of the vector.

  2. 2.Explain the Cartesian coordinate system and its importance in vector analysis.Concept

    The Cartesian system uses three mutually perpendicular axes x, y, z with unit vectors a_x, a_y, a_z that are the same at every point. Because the unit vectors are constant, vectors can be added, integrated and differentiated component by component, which is why other systems are often converted to Cartesian before integrating vector quantities. It is the natural choice for planar geometries such as infinite sheets of charge or parallel plates.

  3. 3.What is the dot product of two vectors, and what does it represent?Concept

    The dot product of two vectors is a scalar quantity obtained by multiplying the magnitudes of the vectors and the cosine of the angle between them. Mathematically, it is expressed as A·B = |A||B|cosθ. The dot product represents the projection of one vector onto another and is used to determine the angle between vectors or to check if they are perpendicular.

  4. 4.Describe the cross product of two vectors and its significance.Concept

    The cross product of two vectors results in a third vector that is perpendicular to the plane containing the original vectors. It is calculated as A×B = |A||B|sinθ n̂, where n̂ is the unit vector perpendicular to the plane. The cross product is significant in physics and engineering for determining torque, rotational motion, and magnetic force, among other applications.

  5. 5.Why is the right-hand rule used in vector analysis?Application

    The cross product is perpendicular to both vectors, but there are two opposite perpendicular directions; the right-hand rule picks one consistently. Point the fingers of the right hand along A and curl them towards B through the smaller angle; the thumb then points along A × B. The same convention fixes a_x × a_y = a_z, the direction of H around a current, and the positive normal of a surface bounded by a loop in Stokes' theorem.

  6. 6.What happens if two vectors are parallel when calculating their cross product?Application

    The cross product is the zero vector, because |A × B| = |A||B| sin θ and sin θ = 0 for θ = 0° or 180°. Geometrically, the parallelogram formed by the two vectors has zero area. In electromagnetics this is why a current element parallel to B feels no force (I dl × B = 0).

  7. 7.How are cylindrical coordinates used in vector analysis, and why are they preferred in certain situations?Application

    Cylindrical coordinates (ρ, φ, z) locate a point by its perpendicular distance ρ from the z-axis, the azimuth φ from the x-axis, and the height z. They are preferred for problems with symmetry about an axis — line charges, long wires, coaxial cables, solenoids — because the field then depends on ρ only and the Gaussian or Amperian surface is a simple cylinder or circle. Remember that a_ρ and a_φ change direction with φ, and the length element in the φ direction is ρ dφ.

  8. 8.Calculate the dot product of vectors A = 3i + 4j + 5k and B = 2i - j + 3k.Numerical

    The dot product A·B is calculated as (3)(2) + (4)(-1) + (5)(3) = 6 - 4 + 15 = 17. Therefore, the dot product of vectors A and B is 17.

  9. 9.Find the cross product of vectors A = i + 2j + 3k and B = 4i + 5j + 6k.Numerical

    The cross product A×B is calculated using the determinant of a matrix: |i j k| |1 2 3| |4 5 6|. This results in i(26 - 35) - j(16 - 34) + k(15 - 24) = i(12 - 15) - j(6 - 12) + k(5 - 8) = -3i + 6j - 3k.

  10. 10.Explain how spherical coordinates are used in vector analysis and provide an example of their application.Application

    Spherical coordinates (r, θ, φ) locate a point by its distance r from the origin, the polar angle θ from the +z axis (0 to π) and the azimuth φ from the x-axis (0 to 2π). They suit problems with point symmetry: the field of a point charge or charged sphere depends on r only, so a spherical Gaussian surface of area 4πr² gives E = Q/(4πε₀r²) a_r directly. The volume element is r² sin θ dr dθ dφ.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?