---
title: Vector Fields and Line Integrals
module: Multiple Integrals and Vector Calculus
moduleNumber: 12
lessonNumber: 3
order: 1203
summary: >
  A vector field assigns a vector to every point of space; the line integral of
  a field along a curve accumulates its tangential component, measuring work.
  Conservative fields are gradients of a potential, and for them the
  Fundamental Theorem for Line Integrals makes the integral depend only on the
  endpoints. Path independence, closed-loop integrals of zero, and the
  component test for a potential are three faces of the same property.
topics: [Multiple Integrals and Vector Calculus]
draft: false
sources:
  - book: Stewart
    ref: "Ch. 16 — Vector Calculus; §16.1 Vector Fields, §16.2 Line Integrals"
  - book: Stewart
    ref: "§16.3 The Fundamental Theorem for Line Integrals"
---

A **vector field** attaches a vector to every point of space: fluid velocity,
gravitational pull, and electric force all have this form. The quantities that
matter about a field — the work done moving through it, the flow across a
boundary — are integrals along curves and across surfaces rather than over
regions. The **line integral** accumulates a field's tangential component along a
path. For the special class of **conservative** fields it collapses to a
difference of endpoint values, the exact analog of the
[Fundamental Theorem of Calculus](/calculus/integrals/the-fundamental-theorem-of-calculus).

## Vector fields

> **Definition (Vector field).** A **vector field** on a region $D \subseteq \mathbb{R}^2$
> is a function $\vec{F}$ that assigns to each point $(x,y)$ in $D$ a
> two-dimensional vector $\vec{F}(x,y) = P(x,y)\,\hat\imath + Q(x,y)\,\hat\jmath$.
> A vector field on $\mathbb{R}^3$ assigns to each point a three-dimensional vector
> $\vec{F}(x,y,z) = P\,\hat\imath + Q\,\hat\jmath + R\,\hat{k}$. The functions
> $P, Q, R$ are the **component functions**.

The picture is an arrow drawn at each point, its tail at the point and its
direction and length given by $\vec{F}$ there. A velocity field of a flowing
fluid, the gravitational field of a mass, and the electric field of a charge all
have this form.

$$
% caption: A vector field draws an arrow at each grid point; here a rotational
% field $\mathbf{F}=-y\,\mathbf{i}+x\,\mathbf{j}$ whose arrows circulate
% counterclockwise, longer far from the origin.
\begin{tikzpicture}[scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\draw[->, black] (-2.6,0) -- (2.6,0) node[right, font=\small] {$x$};
\draw[->, black] (0,-2.6) -- (0,2.6) node[above, font=\small] {$y$};
\foreach \x in {-2,-1,0,1,2} {
  \foreach \y in {-2,-1,0,1,2} {
    \pgfmathsetmacro{\dx}{-0.28*\y}
    \pgfmathsetmacro{\dy}{0.28*\x}
    \draw[acc, thick, ->] (\x,\y) -- ({\x+\dx},{\y+\dy});
  }
}
\end{tikzpicture}
$$

A special and central class of vector fields comes from scalar functions.

> **Definition (Gradient / conservative field).** The **gradient field** of a
> scalar function $f$ is $\nabla f = f_x\,\hat\imath + f_y\,\hat\jmath$ (plus
> $f_z\,\hat{k}$ in space). A field $\vec{F}$ is **conservative** if it is
> the gradient of some scalar function: $\vec{F} = \nabla f$. That function $f$
> is a **potential function** for $\vec{F}$.

The [gradient](/calculus/partial-derivatives/directional-derivatives-and-the-gradient)
points in the direction of steepest increase of $f$ and is perpendicular to the
level curves $f = \text{const}$. Gravitational and electrostatic fields are
conservative; a potential exists because the force derives from a
potential-energy function. Not every field is conservative; deciding which are
comes down to a test on the component functions, developed below.

## Line integrals of scalar functions

Before integrating a field, integrate a scalar function along a curve. Let $C$ be
a smooth curve parametrized by $\vec{r}(t) = \langle x(t), y(t)\rangle$,
$a \le t \le b$. Cut $C$ into short arcs of length $\Delta s_i$, sample $f$ on
each, and sum $f\,\Delta s_i$. The limit is the line integral with respect to arc
length.

> **Definition (Line integral of a scalar function).** For $f$ defined on a smooth
> curve $C$,
> $$
> \int_C f(x,y)\,\d s = \lim_{n\to\infty} \sum_{i=1}^{n} f(x_i^\ast, y_i^\ast)\,\Delta s_i .
> $$

Because arc length satisfies $\d s = \sqrt{[x'(t)]^2 + [y'(t)]^2}\,\d t = |\vec{r}\,'(t)|\,\d t$,
the integral reduces to an ordinary integral in $t$:

$$
\int_C f(x,y)\,\d s = \int_a^b f\big(x(t), y(t)\big)\sqrt{[x'(t)]^2 + [y'(t)]^2}\;\d t .
$$

The value does not depend on the parametrization, as long as $C$ is traced once as
$t$ goes from $a$ to $b$. If the density of a wire bent along $C$ is $\rho(x,y)$,
then $\int_C \rho\,\d s$ is its mass; with $f = 1$ it is the length of $C$. Scalar
line integrals are the base case; the vector version measures work.

## Line integrals of vector fields: work

A force $\vec{F}$ pushing an object along a path does work equal to the
distance times the component of force **along** the direction of motion. Along a
curve, the component of $\vec{F}$ in the direction of travel is
$\vec{F}\cdot\hat{T}$, where $\hat{T}$ is the unit tangent. Summing over
the curve gives the work.

> **Definition (Line integral of a vector field).** For a continuous field
> $\vec{F}$ and a smooth curve $C$ given by $\vec{r}(t)$, $a \le t \le b$,
> the **line integral** of $\vec{F}$ along $C$ is
> $$
> \int_C \vec{F}\cdot \d\vec{r} = \int_a^b \vec{F}(\vec{r}(t))\cdot \vec{r}\,'(t)\,\d t = \int_C \vec{F}\cdot\hat{T}\,\d s .
> $$
> When $\vec{F}$ is a force field, this integral is the **work** done moving a
> particle along $C$.

The middle expression is the working formula: substitute the parametrization into
$\vec{F}$, dot with the velocity $\vec{r}\,'(t)$, and integrate over $t$. In
components with $\vec{F} = P\,\hat\imath + Q\,\hat\jmath$ and
$\d\vec{r} = \langle \d x, \d y\rangle$, the same integral is written

$$
\int_C \vec{F}\cdot \d\vec{r} = \int_C P\,\d x + Q\,\d y .
$$

$$
% caption: The line integral accumulates the tangential component
% $\vec F\cdot\hat T$ along the curve, giving the work
% $\int_C \vec F\cdot\hat T\,\d s$; where the field aligns with the path it
% adds positively, where it opposes it subtracts.
\begin{tikzpicture}[scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\definecolor{grn}{HTML}{2E7D32}
% the curve C: a shallow sine wave y = 1.3 + 0.6 sin(x)
\draw[black, very thick] plot[smooth, domain=0.3:5.9, samples=120] (\x, {1.3+0.6*sin(\x r)});
\node[font=\small, anchor=north] at (0.35,1.15) {$C$};
% anchor points ON the curve, with tangent (grn) along the curve and force (acc)
% point 1: x=1.1, y=1.835, slope 0.272
\fill[black] (1.1,1.835) circle (1.8pt);
\draw[grn, thick, ->] (1.1,1.835) -- (1.872,2.045);
\draw[acc, thick, ->] (1.1,1.835) -- (1.88,2.875);
\node[acc, font=\small, anchor=west] at (2.02,2.72) {$\mathbf{F}$};
\node[grn, font=\small, anchor=west] at (1.95,1.99) {$\mathbf{T}$};
% point 2: x=3.0, y=1.385, slope -0.594
\fill[black] (3.0,1.385) circle (1.8pt);
\draw[grn, thick, ->] (3.0,1.385) -- (3.688,0.976);
\draw[acc, thick, ->] (3.0,1.385) -- (3.78,2.425);
% point 3: x=4.9, y=0.710, slope 0.112
\fill[black] (4.9,0.710) circle (1.8pt);
\draw[grn, thick, ->] (4.9,0.710) -- (5.695,0.799);
\draw[acc, thick, ->] (4.9,0.710) -- (5.68,1.751);
\end{tikzpicture}
$$

> **Worked example.** Find the work done by $\vec{F}(x,y) = \langle x^2, xy\rangle$
> along the quarter-circle $\vec{r}(t) = \langle\cos t, \sin t\rangle$,
> $0 \le t \le \tfrac{\pi}{2}$. Here $\vec{r}\,'(t) = \langle -\sin t, \cos t\rangle$
> and $\vec{F}(\vec{r}(t)) = \langle\cos^2 t, \cos t\sin t\rangle$, so
>
> $$
> \int_C \vec{F}\cdot \d\vec{r} = \int_0^{\pi/2}\big(-\cos^2 t\sin t + \cos^2 t\sin t\big)\,\d t = \int_0^{\pi/2} 0\,\d t = 0 .
> $$

The two terms cancel identically; the field does no net work along this arc. A
different field would give a nonzero value, and reversing the orientation of $C$
flips the sign of a vector line integral (though not of a scalar one, since arc
length is unsigned).

## The Fundamental Theorem for Line Integrals

For a conservative field the line integral has a shortcut. If
$\vec{F} = \nabla f$, then along a curve
$\vec{F}(\vec{r}(t))\cdot\vec{r}\,'(t) = \nabla f(\vec{r}(t))\cdot\vec{r}\,'(t)$,
which by the [chain rule](/calculus/partial-derivatives/tangent-planes-and-the-chain-rule)
is exactly $\tfrac{d}{dt} f(\vec{r}(t))$. Integrating a derivative recovers the
endpoint values.

> **Theorem (Fundamental Theorem for Line Integrals).** Let $C$ be a smooth curve
> from point $A$ to point $B$ given by $\vec{r}(t)$, $a \le t \le b$, and let
> $f$ be differentiable with continuous gradient $\nabla f$ along $C$. Then
> $$
> \int_C \nabla f\cdot \d\vec{r} = f(\vec{r}(b)) - f(\vec{r}(a)) = f(B) - f(A) .
> $$

This is the multivariable version of the evaluation form of the Fundamental
Theorem of Calculus: the line integral of a gradient depends only on the values
of the potential at the two endpoints, not on the route between them. Computing
work then requires no parametrization at all — only $f$ at $A$ and $B$.

> **Worked example.** The field $\vec{F} = \langle 2xy, x^2\rangle$ is the
> gradient of $f(x,y) = x^2 y$ (check: $f_x = 2xy$, $f_y = x^2$). The work along any
> path from $(1,1)$ to $(3,2)$ is
>
> $$
> \int_C \vec{F}\cdot \d\vec{r} = f(3,2) - f(1,1) = (9)(2) - (1)(1) = 18 - 1 = 17,
> $$
>
> with no reference to which path $C$ was taken.

## Path independence, closed loops, and the component test

The theorem has three equivalent consequences that together characterize
conservative fields on a suitable domain.

> **Definition (Path independence).** The integral $\int_C \vec{F}\cdot \d\vec{r}$
> is **independent of path** in a domain $D$ if
> $\int_{C_1}\vec{F}\cdot \d\vec{r} = \int_{C_2}\vec{F}\cdot \d\vec{r}$
> for every pair of paths $C_1, C_2$ in $D$ with the same start and end points.

Since a gradient integral is $f(B) - f(A)$ regardless of $C$, conservative fields
are path independent. The converse holds on connected domains: a path-independent
field is conservative. A closed curve returns to its start, so a path-independent
integral around any closed loop is zero.

$$
% caption: Two paths from $A$ to $B$ in a conservative field give the same
% integral $f(B)-f(A)$; going out along $C_1$ and back along $C_2$ is a closed
% loop with integral zero.
\begin{tikzpicture}[scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\definecolor{alt}{HTML}{B05A2E}
\fill[black] (0.3,1.4) circle (2.2pt) node[left, font=\small] {$A$};
\fill[black] (5.0,1.4) circle (2.2pt) node[right, font=\small] {$B$};
% C1: wavy upper path with two bumps
\draw[acc, very thick, ->] (0.3,1.4)
  .. controls (1.1,3.2) and (2.0,2.7) .. (2.65,2.25)
  .. controls (3.3,1.8) and (4.2,3.3) .. (5.0,1.4);
\node[acc, font=\small, anchor=south] at (1.35,2.9) {$C_1$};
% C2: lower path with a deep dip then a rise
\draw[alt, very thick, ->] (0.3,1.4)
  .. controls (1.0,0.1) and (2.0,-0.15) .. (2.65,0.15)
  .. controls (3.5,0.55) and (4.1,-0.55) .. (5.0,1.4);
\node[alt, font=\small, anchor=north] at (2.05,-0.2) {$C_2$};
\end{tikzpicture}
$$

To test whether a given field is conservative without hunting for a potential,
compare cross-partials. If $\vec{F} = \nabla f$ then $P = f_x$ and $Q = f_y$,
so $P_y = f_{xy}$ and $Q_x = f_{yx}$, equal by
[Clairaut's Theorem](/calculus/partial-derivatives/partial-derivatives). This
gives a necessary condition, and on a simply connected domain it is sufficient.

> **Theorem (Component test in the plane).** If
> $\vec{F} = P\,\hat\imath + Q\,\hat\jmath$ has continuous first partials on an
> open **simply connected** region $D$, then $\vec{F}$ is conservative if and
> only if
> $$
> \frac{\partial P}{\partial y} = \frac{\partial Q}{\partial x} \quad\text{throughout } D .
> $$

"Simply connected" means the domain has no holes, so any closed loop can be shrunk
to a point. The condition can fail on a domain with a hole — the field
$\vec{F} = \tfrac{1}{x^2+y^2}\langle -y, x\rangle$ satisfies $P_y = Q_x$
everywhere it is defined yet is not conservative on the punctured plane, because a
loop around the origin cannot be contracted.

The four statements are equivalent for a $C^1$ field on a simply connected domain:

| Statement | Meaning |
| --- | --- |
| $\vec{F} = \nabla f$ | a potential $f$ exists |
| path independent | integral depends only on endpoints |
| $\oint\limits_C \vec{F}\cdot \d\vec{r} = 0$ | zero around every closed loop |
| $P_y = Q_x$ (simply connected) | cross-partials agree |

### Recovering the potential

When the component test passes, build $f$ by partial integration. From $f_x = P$,
integrate in $x$ treating $y$ as constant, picking up an unknown function of $y$;
then differentiate in $y$ and match $f_y = Q$ to pin it down.

> **Worked example.** Is $\vec{F} = \langle 3 + 2xy,\ x^2 - 3y^2\rangle$
> conservative, and if so find $f$. Check: $P_y = 2x$ and $Q_x = 2x$, equal on all
> of $\mathbb{R}^2$ (simply connected), so yes. Integrate $f_x = 3 + 2xy$ in $x$:
>
> $$
> f(x,y) = 3x + x^2 y + g(y) .
> $$
>
> Differentiate in $y$: $f_y = x^2 + g'(y)$, and setting this equal to
> $Q = x^2 - 3y^2$ gives $g'(y) = -3y^2$, so $g(y) = -y^3 + K$. A potential is
> $f(x,y) = 3x + x^2 y - y^3$, and the work between any two points is the
> difference of $f$ at them.

## The quantity behind the component test

The component test sets $Q_x - P_y$ to zero. That same quantity measures a
field's tendency to circulate, and integrating it over a plane region recovers
the loop integral of $\vec{F}$ around the region's boundary. That identity is
[Green's Theorem](/calculus/multiple-integrals-and-vector-calculus/greens-theorem-curl-and-divergence),
which turns a line integral around a closed curve into a double integral and
accounts for why $P_y = Q_x$ detects conservativeness.[^stewart16]

[^stewart16]: Stewart, §16.1 — Vector Fields; §16.2 — Line Integrals; §16.3 — The Fundamental Theorem for Line Integrals. Conservative fields, path independence, the equivalence of vanishing closed-loop integrals with the existence of a potential, and the cross-partial test on simply connected domains.
