Learning Objectives
By the end of this section you will be able to:
- Read a vector field as a function that assigns one arrow to every point of the plane.
- Recognise the four canonical 2-D patterns — constant, radial, rotational, and saddle — and predict what their arrows look like before you plot them.
- Build a gradient field from any smooth scalar potential and explain why is perpendicular to the level curves of .
- Test whether a given field is conservative using .
- Interpret streamlines as solutions of the ODE and compute them by hand for separable fields.
- Connect the picture to gradient descent: training a neural network is flowing through the field .
The Big Picture: A Vector at Every Point
Stand outside on a windy day. At every spot around you, the air has a velocity — a direction and a speed. The collection of all those velocity arrows, one per location, is a vector field.
Calculus has been climbing a ladder. Single-variable calculus handled functions — one number in, one number out. Multivariable calculus added scalar fields — a temperature at every point on a map. Now we take the next rung:
A function whose input is a point of the plane and whose output is a vector. Once you can see this, you start seeing it everywhere.
🌊 Velocity of a fluid
At each point in a river, water has a velocity . The map of all those arrows is the flow field.
⚡ Electric field
tells you the force a unit charge would feel if placed at that point. The whole field is the function.
🏔️ Gravity near a planet
— a vector at every point telling a test mass which way to fall.
🤖 Loss gradient in ML
is a vector at every point of parameter space. Gradient descent is flowing along .
Scalar field vs vector field
A scalar field assigns a number to each point: . A vector field assigns a 2-D (or 3-D) arrow to each point: . The gradient operator is the bridge that turns a scalar field into a vector field.
From One Vector to a Whole Field
Up to now you have thought of a vector as one arrow living somewhere in space. A vector field is the leap from that single arrow to a whole choreography: a rule that gives you a different arrow at every location.
Here is the mental model in three steps.
- Pick a point. Drop a pin at on the plane.
- Look up two numbers. The field gives you (the horizontal component) and (the vertical component).
- Draw the arrow. Start at , go units right and units up. That arrow is the value .
Repeat this at thousands of points and you get the pictures matplotlib calls quiver plots. The direction of an arrow says where the field is pushing; the length says how strongly.
The field is not the arrows
The arrows are a picture of the field. The field itself is the function . We just happen to draw a finite sample of values because we cannot fit infinitely many arrows on a page.
Definition of a Vector Field
Definition (2-D vector field)
Let . A vector field on D is a function that assigns to each point a 2-D vector
The scalar functions and are called the component functions of .
Three equivalent notations
| Notation | How to read it |
|---|---|
| Components along the standard unit vectors | |
| Angle brackets — emphasises 'this is a vector' | |
| Shorthand when (x, y) is clear from context |
Continuity
The field is continuous at a point exactly when both components and are continuous there. We will usually deal with smooth fields, except at isolated singular points where the field blows up or is not defined (origin of a radial field, the wire in a magnetic field, etc.).
The Four Canonical 2D Fields
Almost every example you will meet is built from these four building blocks — possibly added, scaled, or composed. Learn them once and you can recognise pieces of them in every other picture.
1. Constant field — uniform wind
. Every arrow is identical. Same direction, same length, everywhere. Think of a uniform wind, or the gravitational field near Earth's surface treated locally as constant .
2. Radial field — explosion or shrink toward a point
. The arrow at point is simply the position vector itself — it points directly away from the origin and grows linearly in length. Replace with and the field points inward (a sink).
3. Rotational field — pure spin
. This is the position vector rotated by counter-clockwise. At every point, the arrow is perpendicular to the line from the origin — exactly the velocity field of a rigid disc spinning about the origin with angular speed 1.
Quick check: try four points
At , (points up). At , (points left). At , (points down). At , (points right). The arrows trace a CCW circle.
4. Saddle field — push along x, pull along y
. This is the gradient of the saddle surface . The field pushes outward along the x-axis and pulls inward along the y-axis. The origin is an unstable equilibrium — perturbations along x grow, perturbations along y shrink.
Interactive Playground
Time to play. Pick a field, then drag the white dot to position your probe anywhere on the plane. The amber arrow shows at the probe; the readout in the top-left gives the exact value of , , , and the angle in degrees.
Toggle equal-length arrows to see direction information without magnitude bias (great for the radial field, where corner arrows would otherwise be huge and central ones nearly invisible).
Three experiments to try right now
(1) On the radial field, drag the probe to (3, 0): the readout should be , , angle . (2) On the rotational field, drag along the unit circle: the magnitude stays at 1, the angle rotates with you. (3) On the saddle field, drag along the line : components have equal magnitude but opposite signs, so the arrow always points along .
Worked Example: Tracing by Hand
The rotational field is the single most useful 2-D example. Let's evaluate it at seven points, find the magnitude and angle of each, and verify the deep geometric fact that every arrow is tangent to a circle centred at the origin.
Try each row yourself first; the worked solution is hidden in the collapsible box below.
▶ Show full hand-worked solution (7 points + tangency proof)
Step 1 — Evaluate F at each point
Just plug each into :
| angle (deg) | tangent to circle? | |||
|---|---|---|---|---|
| 1 | ✓ tangent to | |||
| 1 | ✓ tangent to | |||
| 1 | ✓ tangent to | |||
| 1 | ✓ tangent to | |||
| 2 | ✓ tangent to (faster) | |||
| ✓ tangent to | ||||
| ✓ tangent to |
Step 2 — Verify tangency at one point
The circle of radius centred at the origin is the level set . A tangent to that circle at is perpendicular to the radial vector . Check:
The dot product is identically zero, for every . So is perpendicular to the position vector everywhere — which is the same as saying it is tangent to the circle of radius .
Step 3 — Magnitude grows linearly with r
From the table: at , ; at , ; at , . In general,
Physical reading: this is the velocity field of a rigid disc spinning about the origin with angular speed rad/s. A point at radius moves at linear speed .
Step 4 — Sanity-check on the interactive viewer
Pop open the playground above, select Rotational, then drag the probe to each of the seven points in the table. The on-screen , and angle should match these values to two decimals.
Stepping Up to 3D
Definition (3-D vector field)
A vector field on is a function with three component functions:
Three 3-D examples that run physics
| Field | Formula ( = position vector) | What it does |
|---|---|---|
| Gravity (point mass M) | Pulls a test mass m toward M; inverse-square magnitude | |
| Coulomb (point charge q) | Radial, away from charge / toward charge | |
| Magnetic (straight wire) | Circles around the wire at distance | |
| Uniform flow | Same arrow everywhere — bulk transport |
The inverse-square law
Many 3-D fields share the family form . The magnitude falls off as because the field spreads over a sphere of surface area — the further you are, the more dilute the flux. This single picture explains gravity, electrostatics, and how a flashlight grows dimmer with distance.
Gradient Fields: From Hills to Arrows
Take a scalar potential — think of it as the height of a hill. The gradient packages its two partial derivatives into one vector:
Evaluated at every point, is itself a vector field — the gradient field of .
💡 Why the gradient is perpendicular to level curves
Move along a level curve : does not change, so the directional derivative along the curve is 0. But the directional derivative along a unit tangent is . The only way that dot product can be zero for the tangent direction is if . Conclusion: is normal to the level set, and it points uphill (toward higher ).
Quick examples
Example 1. Let . Then — the radial outward field scaled by 2. The level sets are circles, and the gradient points radially outward, perpendicular to them. ✓
Example 2. Let . Then — the saddle field. Level sets are hyperbolas ; the gradient is perpendicular to each branch.
Interactive: potential gradient field
The left panel shows the scalar potential as a coloured contour map. The right panel overlays the gradient arrows. Watch how the arrows are always normal to the level curves, and how they grow longer where the surface is steeper.
When is a Field a Gradient?
Not every vector field comes from a potential. The rotational field emphatically does not. How can we tell?
Test (mixed-partials condition)
If is on a simply-connected region and , then by equality of mixed partials,
The converse is true on simply-connected regions: if the equality holds, the field is conservative and a potential exists.
Applying the test
Radial field : , . Equal — conservative. (Indeed, works.)
Rotational field : , . Not equal — the field is not a gradient of any scalar potential.
Curl appears here in disguise
The difference is the 2-D curl (or scalar curl) of . Conservative fields are exactly those with zero curl. We will study curl as its own operator in Section 19.5.
Flow Lines: A Field is a Recipe for Motion
Drop a tiny massless particle into a vector field and let it ride. At every instant, the particle's velocity equals the field at its current location. The path it traces is called a flow line or streamline.
Definition (flow line)
A flow line of the vector field is a parametrised curve satisfying the system of ODEs
For a 2-D field this is the coupled system .
Solving for the rotational streamlines by hand
For , the ODE system is . Eliminate by computing the slope:
Separate variables: . Integrate both sides:
Streamlines are circles centred at the origin — exactly what the tangency calculation in the worked example predicted, and exactly what the playground will show you.
Interactive: streamlines for five different fields
Below you can scrub through five fields and watch the streamline pattern change. Hit Animate Particles to spawn massless dots that flow along the streamlines in real time.
Streamlines never cross (except at fixed points)
At any point where there is exactly one streamline through it — uniqueness of ODE solutions guarantees this. Two streamlines can only meet at a singular point where (the velocity vanishes and any direction is consistent).
Real-World Applications
1. Fluid dynamics
Wind, water, and traffic-flow models all live on a velocity field . The divergence measures local expansion or compression; the curl measures local rotation (vorticity). Both are introduced in §19.5.
2. Electromagnetism
Maxwell's equations are statements about how two vector fields, and , couple in time and space. One of them, , says a changing magnetic field induces an electric one — the principle behind every electric generator.
3. Weather and climate
Forecasters work simultaneously with the wind vector field, the temperature scalar field, and the pressure scalar field. Pressure gradients drive wind: .
4. Computer graphics
Fluid simulation, fur shading, and texture synthesis all rely on advecting particles through pre-computed vector fields. The same math as a streamline integration.
Machine Learning Connection
Training a neural network is gradient flow on a giant loss surface. Make the connection explicit:
- The loss is a scalar field on parameter space .
- The loss gradient is its gradient vector field — built by backprop in deep learning.
- Gradient descent is forward-Euler integration of the ODE . The training trajectory is a discretised streamline of the field .
Saddle points
Where but the Hessian has mixed signs. Vanilla SGD can stall here exactly like a marble on a horse's saddle — stable in some directions, unstable in others.
Learning rate
The integrator step size. Too large and the discrete trajectory diverges from the true streamline; too small and you take forever to reach a minimum.
Momentum
Replaces the velocity with a damped second-order ODE. The trajectory smooths out, can escape narrow saddle valleys, and behaves like a ball rolling under gravity with friction.
Neural ODEs
Replace a stack of layers with the ODE . Now the hidden state is a particle drifting through a learned vector field — vector calculus is the architecture.
Python Implementation
Four short Python programs make every idea in this section runnable. Read each snippet, then expand the cards below to walk through it line by line.
1. Plot the four canonical 2-D fields
2. Streamlines two ways: streamplot and odeint
3. Build a gradient field from a scalar potential
4. Gradient descent as flow on a loss vector field
PyTorch: Gradient Fields via Autograd
For toy potentials like the gradient is easy by hand. For a 50-million-parameter neural network it is not. PyTorch's autograd computes mechanically by walking the computation graph backwards. The snippet below uses it to rediscover the radial field on a grid and compares it against the closed-form answer.
Why this is the real point of the section
Every gradient field you care about in deep learning — every weight update of every transformer ever trained — is computed by exactly this autograd mechanism. The calculus you learned in this chapter is what the library is doing behind the scenes.
Test Your Understanding
Summary
A vector field is a function that paints every point with an arrow. Two components tell you the arrow at . Four canonical patterns — constant, radial, rotational, saddle — are the alphabet from which most fields are built.
| Concept | Definition | Key fact |
|---|---|---|
| Vector field | Visualised by a quiver plot | |
| Gradient field | for some scalar potential | Perpendicular to level curves of ; conservative |
| Conservative test | on simply-connected region | is gradient |
| Streamline | Curve with | Solutions of an ODE; never cross at regular points |
| Singular point | Point where | Streamlines can meet here; equilibria of the ODE |
| ML connection | Loss defines on parameter space | Gradient descent = forward-Euler streamline of |
Coming next: §19.2 introduces line integrals — integrating a function or a vector field along a curve. We will compute the work done by a force field along a path, and discover that for gradient fields the answer depends only on the endpoints. That is the fundamental theorem of line integrals — the multivariable analogue of FTC Part 2.