Skip to main content

Vector fields and their flow lines

A vector field puts an arrow at every point of the plane, and a flow line is the path that always moves along the arrow under its feet. Draw fields by hand, solve their flow lines exactly and by Euler steps, and see gradient descent as one such path.
M05.10.1L2 Intermediate25 min
In 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.

Before this lesson: M05.2 Partial derivatives and the gradient M05.4 Jacobians and the multivariable chain rule M04.9 Differential equations, a first look

What you will be able to do
  • Draw a vector field from R^2 to R^2 by hand on a grid, and read off where it points out, in or round.
  • Solve the flow-line equation x’(t) = F(x(t)) exactly for the source (x, y), the rotation (-y, x) and gradient descent on the running bowl.
  • Trace a flow line by Euler steps, and prove that on the rotation field each step multiplies the distance from the origin by the square root of 1 + (Delta t)^2.
  • Explain why gradient descent is Euler’s method on the field -grad L, and why simultaneous descent and ascent on the game x y circles instead of settling.

The question

A loss gives a gradient at every setting of the weights, and gradient descent moves the weights a little way along the arrow under its feet, again and again. What path does that make? And when two players each follow their own arrow, as the two networks of a GAN do, why can the pair circle for ever instead of settling down?

Intuition

A vector field on the plane attaches an arrow to every point. Wind on a weather map is one: at each place, an arrow says which way the air moves and how fast. The gradient of a function is another: at each point it says which way is steepest uphill.

Drop a cork into the wind and it drifts, always moving along the arrow at its current spot. Its path is a flow line of the field.

Two square panels of arrows on a grid. Left, titled Source (x, y), green arrows point straight away from the origin and grow longer further out; four black lines start at orange dots near the centre and run straight outwards as rays, each with an arrowhead. Right, titled Rotation (minus y, x), blue arrows point anticlockwise round the origin, longer further out; two black circles of radius 0.9 and 1.8 start at orange dots on the positive x-axis and carry anticlockwise arrowheads. Notes underneath read: arrows point straight out, flow lines are rays; arrows point round, flow lines are circles.
M05.10.1-F1

Two running fields of the module. The source \({(x, y)}\) points away from the origin, so a cork runs straight out along a ray. The rotation \({(-y, x)}\) points round the origin, so a cork goes round a circle and comes back to where it started.

The two pictures already show the two behaviours that the rest of the module measures. Arrows that spread out push things apart: that will be the divergence (lesson M05.10.3). Arrows that turn round carry things in loops: that will be the curl (lesson M05.10.4). This lesson is about the arrows themselves and the paths they make.

Build it up

Step 1. An arrow at each point. A vector field on the plane is a rule \({\vect{F}(x, y) = (P(x, y),\, Q(x, y))}\): two functions, one for each component of the arrow. To draw it, pick points, work out the arrow there and draw it with its tail, or its middle, at the point. At \({(1, 0.5)}\) the source gives \({(1, 0.5)}\), the rotation gives \({(-0.5, 1)}\), and the gradient field \({(2x, 4y)}\) of the running bowl \({f(x, y) = x^2 + 2y^2}\) gives \({(2, 2)}\).

Step 2. Scale the arrows together. True lengths overlap and clutter the page, so every arrow is drawn shrunk by the same factor. Lengths then stay in proportion: twice as long still means twice as strong.

Two panels. Left, titled By hand: nine arrows, black dots at the nine points with coordinates minus 1, 0 and 1. From each a green arrow points in the direction (2x, 4y): at (1, 1) up and to the right, labelled (2, 4); at (0, 1) straight up, labelled (0, 4); at (minus 1, 0) to the left, labelled (minus 2, 0); the origin has no arrow and is labelled (0, 0). A note reads arrows drawn at 0.12 times their length. Right, titled Many arrows, scaled, blue contour ellipses of the bowl with shaded bands and many short green arrows pointing outwards, longer at the top and bottom than at the sides. A note reads each arrow crosses its contour at a right angle.
M05.10.1-F2

The gradient field of the running bowl. By hand, nine arrows are enough to see the pattern; a computer draws many, scaled together. Each arrow is perpendicular to the contour through its point.

Step 3. A path that follows the arrows. A flow line is a path \({\vect{x}(t)}\) whose velocity at every moment is the arrow where it is:

\[ \vect{x}'(t) = \vect{F}(\vect{x}(t)) . \]

This is a system of two differential equations, \({x' = P(x, y)}\) and \({y' = Q(x, y)}\), of exactly the kind M04.9 solved for one unknown. A starting point picks out one flow line.

Step 4. When no formula solves it, take small steps. Euler’s method from M04.9.4 works unchanged with vectors: from \({\vect{x}_k}\), follow the arrow there for a short time \({\Delta t}\), then look again.

\[ \vect{x}_{k+1} = \vect{x}_k + \Delta t\, \vect{F}(\vect{x}_k) . \]

The formal statement

NoteDefinitions: vector field and flow line

A vector field on a region \({D \subseteq \R^2}\) is a function \({\vect{F} : D \to \R^2}\), written \({\vect{F} = (P, Q)}\). A flow line (or integral curve) of \(\vect{F}\) is a differentiable path \({\vect{x}(t)}\) in \(D\) with \({\vect{x}'(t) = \vect{F}(\vect{x}(t))}\) for every \(t\). A field \({\vect{F} = \nabla f}\) is a gradient field, and \(f\) is its potential.

When \(P\) and \(Q\) have continuous partial derivatives, exactly one flow line passes through each starting point, so flow lines never cross. That uniqueness theorem is proved in M12.1; here we solve three cases by hand.

The source \({(x, y)}\). The equations are \({x' = x}\) and \({y' = y}\). They do not interact, and each is the growth equation of M04.9.2, so from \({(x_0, y_0)}\)

\[ x(t) = x_0\,e^{t}, \qquad y(t) = y_0\,e^{t} . \]

The point is always \({e^t}\) times its start: it runs straight out along a ray, and its distance from the origin grows exponentially.

The rotation \({(-y, x)}\). Now the equations are coupled: \({x' = -y}\) and \({y' = x}\). First show that the distance from the origin cannot change. Differentiate its square with the chain rule:

\[ \begin{aligned} \frac{d}{dt}\big(x^2 + y^2\big) &= 2x\,x' + 2y\,y' \\ &= 2x(-y) + 2y(x) = 0 . \end{aligned} \]

So the path stays on the circle through its start. Try \({x = r_0\cos(t + \varphi)}\) and \({y = r_0\sin(t + \varphi)}\): then \({x' = -r_0\sin(t + \varphi) = -y}\) and \({y' = r_0\cos(t + \varphi) = x}\), as required. The point goes anticlockwise round the circle at unit angular speed and returns after time \({2\pi}\).

Gradient descent on the bowl. Descent follows the field \({-\nabla f = (-2x, -4y)}\). Again the equations separate, giving \({x = x_0e^{-2t}}\) and \({y = y_0e^{-4t}}\). Since \({e^{-4t} = (e^{-2t})^2}\), every flow line is part of the parabola \({y = y_0\,(x / x_0)^2}\): from \({(1, 1)}\) it is \({y = x^2}\).

Two panels over the blue contour ellipses of the running bowl, with pale green arrows of minus the gradient pointing inwards. Left, titled Flow lines of minus nabla f, eight black curves start at orange dots round the edge and bend into the minimum, marked by a star; a note says all arrive along the x-axis. Right, titled Euler steps of 0.1, the black flow line y equals x squared from (1, 1) to the minimum, with a vermillion chain of dots beside it starting at a ringed point (1, 1); the second and third points are labelled (0.8, 0.6) and (0.64, 0.36).
M05.10.1-F5

Gradient descent on the bowl. Left: the exact flow lines are parabolas, and they enter the minimum along the flat \({x}\)-direction, where the bowl curves least. Right: gradient descent with learning rate 0.1 is a chain of Euler steps that stays close to the flow line.

Gradient descent is Euler’s method. Put \({\vect{F} = -\nabla L}\) into Euler’s step:

\[ \vect{w}_{k+1} = \vect{w}_k - \Delta t\, \nabla L(\vect{w}_k) . \]

That is the gradient-descent update with learning rate \({\eta = \Delta t}\), as M04.9.4 found in one variable. On the bowl from \({(1, 1)}\) with \({\eta = 0.1}\), the first step is \({(1, 1) - 0.1\,(2, 4)} = {(0.8, 0.6)}\) and the second \({(0.8, 0.6) - 0.1\,(1.6, 2.4)} = {(0.64, 0.36)}\).

Go deeper: why each coordinate of the bowl's descent shrinks by its own factor

In each step the \({x}\)-coordinate is multiplied by \({1 - 2\eta}\) and the \({y}\)-coordinate by \({1 - 4\eta}\), because the gradient’s components are \({2x}\) and \({4y}\). With \({\eta = 0.1}\) the factors are 0.8 and 0.6, so after \(k\) steps the point is \({(0.8^k, 0.6^k)}\). The exact flow multiplies by \({e^{-0.2} \approx 0.819}\) and \({e^{-0.4} \approx 0.670}\) per unit of 0.1 in time: close, which is why the chain hugs the parabola. If \({\eta > 0.5}\), then \({1 - 4\eta < -1}\) and the \(y\)-coordinate flips sign and grows: the step-size limit of M04.9.4, now set by the steeper direction.

Worked example

Four Euler steps round the rotation. Start at \({\vect{x}_0 = (1, 0)}\) on the rotation field and take steps of \({\Delta t = 0.5}\). The exact flow line is the unit circle. Each step adds half the arrow \({(-y, x)}\) at the current point.

\[ \begin{aligned} \vect{x}_1 &= (1, 0) + 0.5\,(0, 1) \\ &= (1,\ 0.5) , \\ \vect{x}_2 &= (1, 0.5) \\ &\quad + 0.5\,(-0.5, 1) \\ &= (0.75,\ 1) , \\ \vect{x}_3 &= (0.75, 1) \\ &\quad + 0.5\,(-1, 0.75) \\ &= (0.25,\ 1.375) , \\ \vect{x}_4 &= (0.25, 1.375) \\ &\quad + 0.5\,(-1.375, 0.25) \\ &= (-0.4375,\ 1.5) . \end{aligned} \]

Left, a panel titled Euler steps of delta t equals 0.5: pale blue rotation arrows, the black unit circle labelled exact path, and a chain of four vermillion arrows from an orange dot x0 at (1, 0) up through x1, x2 and x3 to x4 at (minus 0.44, 1.5), well outside the circle; a hollow black dot on the circle is labelled exact at t equals 2. Right, a table with columns k, point x k and distance: 0, (1, 0), 1; 1, (1, 0.5), 1.118; 2, (0.75, 1), 1.25; 3, (0.25, 1.375), 1.3975; 4, (minus 0.4375, 1.5), 1.5625, the last row shaded yellow. A note reads each step multiplies the distance by root 1.25, about 1.118.
M05.10.1-F3

The worked example as a trace. The exact path stays on the unit circle; Euler’s chain spirals outwards, ending at distance 1.5625 when the true point \({(\cos 2, \sin 2)}\) is at distance 1.

After time \({4 \times 0.5 = 2}\) the exact point is \({(\cos 2, \sin 2) \approx (-0.416, 0.909)}\), on the circle. Euler’s point is at distance \({\sqrt{0.4375^2 + 1.5^2} = 1.5625}\). The distances in the table go 1, 1.118, 1.25, 1.398, 1.5625: each is the one before times \({\sqrt{1.25}}\).

Why. For one step from \({(x, y)}\) the new point is \({(x - \Delta t\,y,\; y + \Delta t\,x)}\). Its squared distance from the origin is

\[ \begin{aligned} &(x - \Delta t\,y)^2 + (y + \Delta t\,x)^2 \\ &\quad= x^2 + y^2 + \Delta t^2\,(x^2 + y^2) \\ &\quad= (1 + \Delta t^2)\,(x^2 + y^2) , \end{aligned} \]

because the cross terms \({-2\Delta t\,xy}\) and \({+2\Delta t\,xy}\) cancel. So every step multiplies the distance by \({\sqrt{1 + \Delta t^2}}\), here \({\sqrt{1.25} \approx 1.118}\). However small the step, Euler’s method spirals out of the circle; a smaller step only slows the spiral.

The same field in a game. Two players share the payoff \({f(x, y) = xy}\): the first picks \(x\) and wants \(f\) small, the second picks \(y\) and wants it large. Simultaneous gradient play moves \({x}\) down its partial derivative and \({y}\) up its own:

\[ \begin{aligned} x' &= -\pd{f}{x} = -y , \\ y' &= +\pd{f}{y} = x . \end{aligned} \]

That is the rotation field. The exact flow circles the balance point \({(0, 0)}\) for ever, and the discrete steps a computer takes spiral away from it, as the trace shows. Balduzzi and colleagues use this example (with a matrix in place of the single number) to explain why gradient play on games such as GANs can cycle.

Code

Euler’s method for a field takes three lines. Then the same flow lines with SciPy’s general solver, which adapts its steps to meet an error tolerance.

import numpy as np

def rotation(p):
    x, y = p
    return np.array([-y, x])

def euler(field, start, dt, steps):
    """Euler steps x_{k+1} = x_k + dt F(x_k); returns all the points as rows."""
    points = [np.asarray(start, dtype=float)]
    for _ in range(steps):
        points.append(points[-1] + dt * field(points[-1]))
    return np.array(points)

trace = euler(rotation, (1.0, 0.0), 0.5, 4)
print(trace)
print("distances:", np.round(np.hypot(trace[:, 0], trace[:, 1]), 4))

# Gradient descent on the bowl f = x^2 + 2y^2 is Euler's method on -grad f.
descent = lambda p: -np.array([2 * p[0], 4 * p[1]])
print("descent:", euler(descent, (1.0, 1.0), 0.1, 2)[1:])
[[ 1.      0.    ]
 [ 1.      0.5   ]
 [ 0.75    1.    ]
 [ 0.25    1.375 ]
 [-0.4375  1.5   ]]
distances: [1.     1.118  1.25   1.3975 1.5625]
descent: [[0.8  0.6 ]
 [0.64 0.36]]

Now scipy.integrate.solve_ivp, which wants the right-hand side as fun(t, y) with the time first. Its answer sol.y has one row per coordinate and one column per stored time.

from scipy.integrate import solve_ivp

sol = solve_ivp(lambda t, p: rotation(p), (0, 2 * np.pi), [1.0, 0.0], rtol=1e-10, atol=1e-12,
                t_eval=[2.0, 2 * np.pi])
print("at t = 2:  ", np.round(sol.y[:, 0], 4), "  exact:", np.round([np.cos(2), np.sin(2)], 4))
print("at t = 2pi:", np.round(sol.y[:, 1], 6))

src = solve_ivp(lambda t, p: p, (0, 1), [0.5, 0.25], rtol=1e-10, atol=1e-12)
print("source after t = 1:", np.round(src.y[:, -1], 4), " = e times the start")
at t = 2:   [-0.4161  0.9093]   exact: [-0.4161  0.9093]
at t = 2pi: [1. 0.]
source after t = 1: [1.3591 0.6796]  = e times the start

The solver closes the circle to within \({10^{-8}}\) after one full turn, where four Euler steps had already drifted 0.56 too far from the origin. The difference is the size of the steps it takes and the higher-order method it uses, not a different idea: it still follows the arrows.

Frontier note: the score field of a density

For a probability density \({p}\) on the plane, the field \({\nabla \log p}\) is called its score. It points uphill in probability. For the standard Gaussian, \({\log p = -(x^2 + y^2)/2 + \text{const}}\), so the score is \({-(x, y)}\): the source reversed, every arrow pointing at the mode. Song and Ermon (2019) train a network to estimate the score of a data distribution from samples and then generate new samples by following it with small noisy steps (Langevin dynamics). Diffusion models (DL07, M12.6) are built on this idea: learn a vector field, then follow its flow lines.

Explore

This module’s interactive, the field explorer, lives in lesson M05.10.3. Choose the rotation there, click near the centre to drop a particle and watch its Euler path spiral slowly outwards; set the step slider larger and the spiral opens up, as the worked example predicts.

Pitfalls

Two panels over the contour ellipses of the bowl with green arrows of minus the gradient. Left, marked with a cross and titled Follows the first arrow: a straight vermillion line from an orange dot at (1, 1) runs in the direction of the first arrow and passes below the minimum, marked by a star; a dashed purple segment from the star to the nearest point on the line is labelled misses by 0.45. Right, marked with a tick and titled Follows every arrow: a black curve y equals x squared from (1, 1) bends with the arrows into the star; notes read turns with the arrows and reaches the minimum.
M05.10.1-F4

Wrong beside right. A flow line is not the straight line along the first arrow: that line misses the minimum by about 0.45. The true path turns as the arrows turn and arrives exactly.

“The path goes where the first arrow points.”

Only for an instant. From \({(1, 1)}\) the descent arrow is \({(-2, -4)}\), and the straight line along it comes no nearer the minimum than \({(0.4, -0.2)}\), about 0.45 away. The flow line asks the field again at every point, so it turns towards the flatter \(x\)-direction and reaches \({(0, 0)}\). A long gradient step makes the same mistake, which is why the learning rate must be small.

“With a small enough step, Euler’s path round a circle closes.”

It never does. Each step multiplies the distance by \({\sqrt{1 + \Delta t^2}}\), which is more than 1 for every non-zero step. With \({\Delta t = 0.01}\) a full turn takes about 628 steps and ends about 3.2% too far out. In a two-player game the same growth makes plain simultaneous gradient steps drift away from the balance point.

“An arrow tells you where the point is going to end up.”

An arrow is a velocity at one place, not a destination. Arrows of the source near the origin are tiny, yet every flow line except the one at the origin runs off to infinity. Read a field’s long-run behaviour from its flow lines, not from one arrow.

Check yourself

Recall

1. What does a vector field on the plane assign to each point, and how is it written?

Show answer

An arrow, a vector in \(\R^2\). It is written \({\vect{F}(x, y) = (P(x, y), Q(x, y))}\), one function for each component.

2. What equation defines a flow line of \(\vect{F}\)?

Show answer

\({\vect{x}'(t) = \vect{F}(\vect{x}(t))}\): the velocity of the path at each moment is the arrow at its current point.

3. Describe the flow lines of the source \({(x, y)}\) and of the rotation \({(-y, x)}\).

Show answer

Source: rays out from the origin, \({\vect{x}(t) = e^t\,\vect{x}_0}\). Rotation: circles round the origin, traversed anticlockwise once every \({2\pi}\).

4. Write Euler’s step for a vector field, and say what it becomes on \({-\nabla L}\).

Show answer

\({\vect{x}_{k+1} = \vect{x}_k + \Delta t\,\vect{F}(\vect{x}_k)}\). On \({\vect{F} = -\nabla L}\) it is gradient descent with learning rate \({\eta = \Delta t}\).

5. By what factor does one Euler step on the rotation field change the distance from the origin?

Show answer

\({\sqrt{1 + \Delta t^2}}\), always more than 1, so Euler’s path spirals outwards.

Exercises

1. ★ Compute the arrows of \({\vect{F}(x, y) = (y, -x)}\) at \({(1, 0)}\), \({(0, 1)}\) and \({(-1, 0)}\). Which way do its flow lines go round?

Show solution

\({\vect{F}(1, 0) = (0, -1)}\), \({\vect{F}(0, 1) = (1, 0)}\) and \({\vect{F}(-1, 0) = (0, 1)}\). At \({(1, 0)}\) the arrow points down, at the top it points right: the flow goes round the origin clockwise. It is the rotation field reversed.

2. ★★ Find the flow line of \({\vect{F}(x, y) = (x, -y)}\) through \({(1, 2)}\), and show that it lies on the curve \({xy = 2}\).

Show solution

The equations \({x' = x}\) and \({y' = -y}\) separate, so \({x = e^{t}}\) and \({y = 2e^{-t}}\). Their product is \({xy = 2e^{t}e^{-t} = 2}\) for every \(t\). The point runs out along the \(x\)-direction and in along the \(y\)-direction, tracing one branch of the hyperbola: the flow of a saddle.

3. ★★★ Take Euler steps of size \(\eta\) on the descent-ascent field \({(-y, x)}\) of the game \({xy}\), but let each player also shrink its own variable: \({\vect{F} = (-y - \varepsilon x,\; x - \varepsilon y)}\) with \({\varepsilon > 0}\). Show that the squared distance is multiplied by \({(1 - \eta\varepsilon)^2 + \eta^2}\) per step, and find the condition for the steps to spiral in.

Show solution

One step sends \({(x, y)}\) to \({((1 - \eta\varepsilon)x - \eta y,\; \eta x + (1 - \eta\varepsilon)y)}\). Write \({a = 1 - \eta\varepsilon}\). The squared distance of the new point is

\[ \begin{aligned} &(ax - \eta y)^2 + (\eta x + ay)^2 \\ &\quad= (a^2 + \eta^2)(x^2 + y^2) , \end{aligned} \]

since the cross terms \({-2a\eta xy}\) and \({+2a\eta xy}\) cancel. The steps spiral in when \({(1 - \eta\varepsilon)^2 + \eta^2 < 1}\), that is \({\eta^2 + \eta^2\varepsilon^2 < 2\eta\varepsilon}\), or \({\eta\,(1 + \varepsilon^2) < 2\varepsilon}\). With \({\varepsilon = 0.1}\) and \({\eta = 0.1}\) the factor is \({0.99^2 + 0.01 = 0.9901}\): a slow inward spiral. With \({\varepsilon = 0}\) no step size works.

Summary card

A field is an arrow at every point; a flow line follows them.

The anchor figure again: the source field with straight rays running out from the centre, beside the rotation field with circular flow lines round the origin.
M05.10.1-F1

Rays for the source, circles for the rotation.

  • Field: \({\vect{F}(x, y) = (P, Q)}\). Flow line: \({\vect{x}'(t) = \vect{F}(\vect{x}(t))}\).
  • Source: \({\vect{x}(t) = e^t\vect{x}_0}\). Rotation: circles of period \({2\pi}\).
  • Euler: \({\vect{x}_{k+1} = \vect{x}_k + \Delta t\,\vect{F}(\vect{x}_k)}\); on \({-\nabla L}\) it is gradient descent.
  • On the rotation each Euler step multiplies the distance by \({\sqrt{1 + \Delta t^2}}\).

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 (OpenStax), Section 6.1: the definition of a vector field \({\vect{F} = (P, Q)}\), radial and rotational fields (its worked rotational example is \({\langle y, -x \rangle}\), this lesson’s rotation reversed), gradient fields with their potential functions, and, in the exercises, flow lines as curves with \({\vect{r}'(t) = \vect{F}(\vect{r}(t))}\).
  • SciPy developers, scipy.integrate.solve_ivp: the call fun(t, y), the default method RK45 with rtol \({10^{-3}}\) and atol \({10^{-6}}\), t_eval, and the solution array y of shape (n, n_points).
  • Yang Song and Stefano Ermon, Generative Modeling by Estimating Gradients of the Data Distribution, NeurIPS 2019, Section 2: the score of a density defined as \({\nabla_{\vect{x}} \log p(\vect{x})}\), a network trained to estimate it, and sampling by Langevin dynamics (Section 2.2).
  • David Balduzzi and five co-authors, The Mechanics of n-Player Differentiable Games, ICML 2018, Example 1: in the zero-sum game with losses \({\vect{x}\T\mat{A}\vect{y}}\) and \({-\vect{x}\T\mat{A}\vect{y}}\), the simultaneous gradient rotates round the equilibrium (Figure 1).

Next. M05.10.2 Line integrals and conservative fields adds up how much a field pushes along a path, and finds which fields are gradients.

This lesson unlocks

M05.10.2 Line integrals and conservative fields

Your progress is saved in this browser only. No account, no tracking.
Back to top