The work of a field along a path adds up its push in the direction of travel. Compute it for the rotation round a circle and the bowl’s gradient along three paths, prove that a gradient’s work is the change in its potential, and use a loop to show a field is no gradient at all.
M05.10.2L2 Intermediate25 minIn review (what this means)
The maths and code on this page are checked by automated tests on every change, but an independent reader has not signed it off yet. Spot a mistake or a confusing step? Tell us.
Compute the line integral of F(r(t)) . r’(t) dt along a parametrised path, and explain it as a limit of sums of F . (chord).
Prove that the line integral of a gradient is f(end) - f(start), using the chain rule along the path.
Conclude that gradient fields are path-independent and give zero round every closed loop, and use a loop to show that the rotation field is not a gradient.
Compute line integrals numerically with scipy.integrate.quad along parametrised paths.
The question
Push a point along a path through a field and add up how much the field helped at every step. Training does this: the loss drops by the help the descent field gave along the route the weights took. When does the total depend only on where you start and stop, and what does it mean when two routes between the same two points disagree?
From the last lesson
1. What equation defines a flow line of a field \(\vect{F}\)?
Show answer
\({\vect{x}'(t) = \vect{F}(\vect{x}(t))}\): the velocity of the path is the arrow at its current point.
2. By what factor does one Euler step of size \({\Delta t}\) on the rotation \({(-y, x)}\) change the distance from the origin?
Show answer
\({\sqrt{1 + \Delta t^2}}\), so Euler’s path spirals outwards, however small the step.
Intuition
Walk along a path while the field pushes on you. Where the arrow points along your direction of travel, it helps; where it points against you, it hinders; where it points across your path, it does nothing. The total help, added up along the whole path, is the work of the field along the path, also called its line integral.
M05.10.2-F1
Left: on the unit circle the rotation always pushes straight along the path, so it helps all the way round, and the work is \({2\pi}\). Right: the bowl’s gradient does the same work, 3, along two different paths between the same two points.
The two panels hold the two facts of this lesson. A field can do work round a closed loop, and come back to the start having helped all the way. A gradient field cannot: its work depends only on the two ends, and a loop has the same start and end.
Build it up
Step 1. One straight piece. Over a short straight piece \({\Delta\vect{r}}\) of path, the field is nearly constant, so its help is the dot product \({\vect{F} \cdot \Delta\vect{r}}\): the component of the arrow along the piece, times the piece’s length. Pointing across the path gives 0.
Step 2. Add the pieces. Cut the path at points \({\vect{r}_0, \vect{r}_1, \dots, \vect{r}_n}\) and add \({\vect{F}(\vect{r}_k) \cdot (\vect{r}_{k+1} - \vect{r}_k)}\). For the rotation on the unit circle, put \({\vect{r}_k = (\cos\theta_k, \sin\theta_k)}\) with \({\theta_k = 2\pi k / n}\). Then \({\vect{F}(\vect{r}_k) = (-\sin\theta_k, \cos\theta_k)}\), and each piece adds
The \({\sin\theta_k\cos\theta_k}\) terms cancel, and the last line is the subtraction formula for sine.
M05.10.2-F2
The work as a sum. With \(n\) chords the total is \({n\sin(2\pi/n)}\), which climbs to \({2\pi}\) as the chords shrink.
So the sum is \({n\sin(2\pi/n)}\): 5.657 for 8 chords, 6.243 for 32, and as \({n \to \infty}\) it tends to \({2\pi \approx 6.283}\), because \({\sin u / u \to 1}\) as \({u \to 0}\).
Step 3. Turn the sum into an integral. Describe the path by a parameter, \({\vect{r}(t)}\) for \({a \le t \le b}\). A small step \({\Delta t}\) moves the point by \({\Delta\vect{r} \approx \vect{r}'(t)\,\Delta t}\), so each piece adds about \({\vect{F}(\vect{r}(t)) \cdot \vect{r}'(t)\,\Delta t}\). Adding and letting \({\Delta t \to 0}\) gives an ordinary integral in one variable.
The formal statement
NoteDefinition: line integral of a vector field
Let \({\vect{r} : [a, b] \to D}\) be a path with a continuous derivative, tracing a curve \(C\), and let \(\vect{F}\) be continuous on \(D\). A path made of several such pieces, with corners, is allowed: the integrals over the pieces add. The line integral (the work) of \(\vect{F}\) along \(C\) is
When \(C\) is closed, \({\vect{r}(a) = \vect{r}(b)}\), it is the circulation round \(C\), written \({\oint_C \vect{F} \cdot d\vect{r}}\).
The parametrisation does not matter, but the direction does. Let \({t = \varphi(s)}\) with \(\varphi\) increasing from \(c\) to \(d\), and trace the same curve as \({\tilde{\vect{r}}(s) = \vect{r}(\varphi(s))}\). The chain rule gives \({\tilde{\vect{r}}'(s) = \vect{r}'(\varphi(s))\,\varphi'(s)}\), so
and the substitution \({t = \varphi(s)}\) turns this into the original integral. If \(\varphi\) decreases, so that the curve is run backwards, the substitution swaps the limits and the sign flips.
NoteTheorem: the fundamental theorem for gradients
If \({\vect{F} = \nabla f}\) where \(f\) has continuous partial derivatives, then for any path from \({\vect{r}(a)}\) to \({\vect{r}(b)}\)
Proof. Let \({g(t) = f(\vect{r}(t))}\), the height of \(f\) along the path. By the chain rule of M05.4.2, \({g'(t) = \nabla f(\vect{r}(t))\T\,\vect{r}'(t)}\), which is exactly the integrand. By the fundamental theorem of calculus (M04.6),
\[
\int_a^b g'(t)\,dt = g(b) - g(a) ,
\]
and \({g(b) - g(a)}\) is \({f(\vect{r}(b)) - f(\vect{r}(a))}\). ∎
M05.10.2-F5
The proof as a picture. Along the path the height \({f(\vect{r}(t))}\) rises at the rate \({\nabla f \cdot \vect{r}'(t)}\), so adding up that rate gives the total rise, here \({f(1, 1) - f(0, 0) = 3}\).
Three consequences follow at once.
Path independence. For a gradient, every path with the same two ends gives the same work.
Loops give zero. A closed path has \({\vect{r}(b) = \vect{r}(a)}\), so \({\oint_C \nabla f \cdot d\vect{r} = 0}\).
A test that a field is not a gradient. If any loop has non-zero circulation, or two paths with the same ends give different work, no \(f\) with \({\nabla f = \vect{F}}\) can exist.
A field that is a gradient is called conservative. The converse also holds: on an open connected region, a field whose work never depends on the path is a gradient, with potential \({f(\vect{x})}\) equal to the work from a fixed point to \(\vect{x}\) (stated here, not proved).
M05.10.2-F6
The rotation fails the test. Between the same two points, three paths do work \({\pi}\), \({-\pi}\) and 0.
The figure’s numbers: on the upper semicircle the field points along the path, as on the full circle, giving \({\pi}\). The lower semicircle runs clockwise, against the arrows, giving \({-\pi}\). Along the \(x\)-axis the arrow \({(0, x)}\) is perpendicular to the path, giving 0.
Worked example
The rotation round the unit circle. Take \({\vect{r}(t) = (\cos t, \sin t)}\) for \({0 \le t \le 2\pi}\). Then \({\vect{r}'(t) = (-\sin t, \cos t)}\) and \({\vect{F}(\vect{r}(t)) = (-\sin t, \cos t)}\), the same vector. So
A loop with circulation \({2\pi}\): the rotation is not a gradient. Neither is the descent-ascent field of the game \({xy}\), which is the same field.
The bowl’s gradient along three paths.\({\vect{F} = (2x, 4y) = \nabla f}\) with \({f = x^2 + 2y^2}\), from \({(0, 0)}\) to \({(1, 1)}\).
M05.10.2-F3
The worked example as a trace. Three different paths, three different integrands, one answer: the change in the potential.
Path A, the line \({\vect{r} = (t, t)}\): \({\vect{r}' = (1, 1)}\) and \({\vect{F}(\vect{r}) = (2t, 4t)}\), so the integrand is \({2t + 4t = 6t}\) and the work is \({\int_0^1 6t\,dt = 3}\).
Path B, the parabola \({\vect{r} = (t, t^2)}\): \({\vect{r}' = (1, 2t)}\) and \({\vect{F}(\vect{r}) = (2t, 4t^2)}\), so the integrand is \({2t + 8t^3}\) and the work is \({1 + 2 = 3}\).
Path C, across then up. Along \({y = 0}\) from \({x = 0}\) to 1, only the \(x\)-component counts: \({\int_0^1 2x\,dx = 1}\). Up \({x = 1}\) from \({y = 0}\) to 1, only the \(y\)-component counts: \({\int_0^1 4y\,dy = 2}\). Total 3.
And the theorem in one line: \({f(1, 1) - f(0, 0) = 3 - 0 = 3}\).
Code
A line integral is an ordinary integral once the path is parametrised, so scipy.integrate.quad does it. It returns the value and an estimate of its error.
import numpy as npfrom scipy.integrate import quaddef work(F, r, dr, a, b):"""Line integral of F along r(t), a <= t <= b, given r and its derivative dr.""" integrand =lambda t: np.dot(F(r(t)), dr(t)) value, error = quad(integrand, a, b)return valuerotation =lambda p: np.array([-p[1], p[0]])bowl_grad =lambda p: np.array([2* p[0], 4* p[1]])circle =lambda t: np.array([np.cos(t), np.sin(t)])circle_d =lambda t: np.array([-np.sin(t), np.cos(t)])print("rotation round the circle:", round(work(rotation, circle, circle_d, 0, 2* np.pi), 6))line = (lambda t: np.array([t, t]), lambda t: np.array([1.0, 1.0]))parabola = (lambda t: np.array([t, t **2]), lambda t: np.array([1.0, 2* t]))print("bowl, line:", round(work(bowl_grad, *line, 0, 1), 6)," parabola:", round(work(bowl_grad, *parabola, 0, 1), 6))print("bowl, round the circle:", round(work(bowl_grad, circle, circle_d, 0, 2* np.pi), 6))
rotation round the circle: 6.283185
bowl, line: 3.0 parabola: 3.0
bowl, round the circle: -0.0
Now a loss. The running loss \({L(w, b)}\) of M04.10 falls from 18.5 at the origin to its minimum 0.05 at \({(1.4, 0.5)}\). The work of \({\nabla L}\) along any route between them is the change in \(L\), \({0.05 - 18.5 = -18.45}\): the field \({-\nabla L}\) that descent follows does work \({+18.45}\), whichever way the weights travel.
If two players each follow the gradient of their own loss, the joint field is the gradient of a single function only in special cases. Balduzzi and colleagues split the Jacobian of a game’s field into a symmetric part and an antisymmetric part (their Lemma 1). Games with only the symmetric part, potential games, behave like ordinary descent on one function. Games with only the antisymmetric part, Hamiltonian games, such as the bilinear game of the last lesson, circle. A non-zero circulation round some loop is the line-integral way of saying the field has no potential. Lesson M05.10.4 measures that antisymmetric part pointwise: the curl.
Explore
This module’s interactive, the field explorer, lives in lesson M05.10.3. Choose the rotation and drag its small square: the circulation it reports is never 0, a sign that no potential exists. Switch to the bowl’s gradient and the circulation is 0 wherever the square goes.
Pitfalls
M05.10.2-F4
Wrong beside right. Coming back to the start does not cancel the work in general; it does for a gradient, whose work is a difference of heights.
“A closed path ends where it starts, so the work round it is 0.”
That is the fundamental theorem for gradients, and it needs a gradient. The rotation round the unit circle gives \({2\pi}\). In training terms: following \({-\nabla L}\) round a loop returns the same loss, but a two-player game’s field can do net work round a loop, and so can keep going round it.
“Use the direction of the path and forget its speed.”
The integrand is \({\vect{F}(\vect{r}(t)) \cdot \vect{r}'(t)}\), with the full velocity. On the circle of radius 2, \({\vect{r} = (2\cos t, 2\sin t)}\), the rotation gives \({\vect{F} \cdot \vect{r}' = 4}\) and work \({8\pi}\). Dotting with the unit tangent instead and integrating in \(t\) gives \({4\pi}\): wrong by the speed, 2. Either use \({\vect{r}'(t)\,dt}\), or use the unit tangent with arc length \({ds}\).
“The work along a path does not depend on which way I walk it.”
Reversing the path reverses every \({d\vect{r}}\) and flips the sign: the lower semicircle run clockwise gives \({-\pi}\), run anticlockwise \({+\pi}\). Always state the direction, and for loops use anticlockwise unless told otherwise.
Check yourself
Recall
1. Write the line integral of \(\vect{F}\) along a path \({\vect{r}(t)}\), \({a \le t \le b}\).
Show answer
\({\int_a^b \vect{F}(\vect{r}(t))\T\,\vect{r}'(t)\,dt}\), the limit of the sums of \({\vect{F} \cdot \Delta\vect{r}}\).
2. State the fundamental theorem for gradients.
Show answer
\({\int_C \nabla f \cdot d\vect{r}} = {f(\vect{r}(b)) - f(\vect{r}(a))}\): the work of a gradient is the change in its potential between the ends.
3. Which step of the proof uses the chain rule, and what does it give?
Show answer
Differentiating \({g(t) = f(\vect{r}(t))}\): \({g'(t) = \nabla f(\vect{r}(t))\T\vect{r}'(t)}\), which is the integrand.
4. What is the circulation of the rotation \({(-y, x)}\) round the unit circle, and what does it prove?
Show answer
\({2\pi}\). Since it is not 0, the rotation is not the gradient of any function.
5. What happens to a line integral when the path is run backwards?
Show answer
It changes sign.
Exercises
1.★ Compute the work of \({\vect{F} = (y, x)}\) along \({\vect{r}(t) = (t, t^2)}\), \({0 \le t \le 1}\). Then notice that \({\vect{F} = \nabla(xy)}\) and check your answer with the theorem.
Show solution
\({\vect{F}(\vect{r}) = (t^2, t)}\) and \({\vect{r}' = (1, 2t)}\), so the integrand is \({t^2 + 2t^2 = 3t^2}\) and the work is \({\int_0^1 3t^2\,dt = 1}\). With \({f = xy}\): \({f(1, 1) - f(0, 0) = 1}\).
2.★★ Show that the circulation of the rotation round the circle of radius \(a\) centred at the origin is \({2\pi a^2}\).
Show solution
With \({\vect{r} = (a\cos t, a\sin t)}\), \({\vect{r}' = (-a\sin t, a\cos t)}\) and \({\vect{F}(\vect{r}) = (-a\sin t, a\cos t)}\). Their dot product is \({a^2\sin^2 t + a^2\cos^2 t = a^2}\), so the circulation is \({\int_0^{2\pi} a^2\,dt = 2\pi a^2}\): twice the area of the disc, a fact that lesson M05.10.4 explains.
3.★★★ The field \({\vect{F} = (2xy + 1,\; x^2)}\) is conservative. Find a potential by computing the work from \({(0, 0)}\) to \({(x, y)}\) along the path that goes across and then up, and check that its gradient is \(\vect{F}\).
Show solution
Across, along the axis from \({(0, 0)}\) to \({(x, 0)}\): there the first component is \({2s \cdot 0 + 1 = 1}\), so the work is \({\int_0^x 1\,ds = x}\). Up, from \({(x, 0)}\) to \({(x, y)}\): only the second component, \({x^2}\), counts, giving \({\int_0^y x^2\,ds = x^2y}\). So \({f(x, y) = x + x^2y}\). Check: \({\pd{f}{x} = 1 + 2xy}\) and \({\pd{f}{y} = x^2}\), which is \(\vect{F}\).
Summary card
Work adds the push along the path; for a gradient it is the change in height.
Gradients: \({\int_C \nabla f \cdot d\vect{r}} = {f(\text{end}) - f(\text{start})}\).
So a gradient’s loops give 0; the rotation’s unit circle gives \({2\pi}\), so it has no potential.
Reversing the path flips the sign.
Sources and next steps
Sources. Each was opened and checked against this lesson on 15 November 2026.
Gilbert Strang and Edwin Herman, Calculus Volume 3, Section 6.2 (OpenStax): the vector line integral as a limit of sums and its parametric form (Equation 6.9), circulation round a closed curve, and the sign change on reversing orientation (Theorem 6.5).
Gilbert Strang and Edwin Herman, Calculus Volume 3, Section 6.3 (OpenStax): the fundamental theorem for line integrals (Theorem 6.7, Equation 6.12), conservative fields are independent of path (Theorem 6.8) and the converse on open connected domains (Theorem 6.9), and closed curves giving 0.
SciPy developers, scipy.integrate.quad: it returns the integral and an estimate of its absolute error, with default tolerances epsabs and epsrel of \({1.49 \times 10^{-8}}\).
David Balduzzi and five co-authors, The Mechanics of n-Player Differentiable Games, ICML 2018, Section 2: the generalised Helmholtz decomposition of a game’s Jacobian into symmetric and antisymmetric parts (Lemma 1), and potential and Hamiltonian games (Definition 2).