Vector Calculus · Fields · ODEs

The Gradient,
Conservative Fields &
Exact Equations

From first principles — how the derivative generalizes to many dimensions, what that means geometrically, and the deep bridge to differential equations.

Warm-up: What the 1D Derivative Really Means

Before we climb to multiple dimensions, let's nail down what a derivative actually is — not just the formula, but the physical idea.

Imagine a hiker walking along a one-dimensional trail. Their altitude at position \(x\) is given by some function \(f(x)\). The derivative answers: how steeply is the terrain rising or falling at this exact spot?

The 1D Derivative — First Principles
\[ f'(x) \;=\; \lim_{\Delta x \to 0} \frac{f(x + \Delta x) - f(x)}{\Delta x} \]

We take a tiny step \(\Delta x\), measure how much the function changes, and divide to get the rate. The limit makes it exact — infinitely small step, infinitely precise slope.

🏔️

Physical intuition: \(f'(x) > 0\) means "go right, go uphill." \(f'(x) < 0\) means "go right, go downhill." \(f'(x) = 0\) means "you're at a peak, valley, or flat."

The derivative is a single number because you only have one direction to travel. In higher dimensions, you can travel in infinitely many directions — and you need a new object to capture all of them at once. That object is the gradient.

The Gradient — Derivative in Every Direction

Now our hiker is on a real mountain. Altitude depends on both East-West position \(x\) and North-South position \(y\): we write it \(f(x, y)\). At any point, the terrain has a slope in the \(x\)-direction and a slope in the \(y\)-direction. These are the partial derivatives.

Partial Derivatives: Holding One Variable Fixed

The partial derivative \(\frac{\partial f}{\partial x}\) asks: if I freeze \(y\) and only move in the \(x\)-direction, how fast does \(f\) change?

Partial Derivative — Definition
\[ \frac{\partial f}{\partial x}\bigg|_{y\,\text{fixed}} \;=\; \lim_{\Delta x \to 0} \frac{f(x + \Delta x,\; y) - f(x, y)}{\Delta x} \]

Same limit as before — we just hold all other variables constant. It's exactly the 1D derivative in the \(x\)-direction.

Assembling Them Into a Vector

Instead of giving you two separate numbers, the gradient packages all partial derivatives into a single vector:

The Gradient — Definition
\[ \nabla f \;=\; \left\langle \frac{\partial f}{\partial x},\;\frac{\partial f}{\partial y} \right\rangle \quad \text{(in 2D)} \] \[ \nabla f \;=\; \left\langle \frac{\partial f}{\partial x},\;\frac{\partial f}{\partial y},\;\frac{\partial f}{\partial z} \right\rangle \quad \text{(in 3D)} \]

The symbol \(\nabla\) (nabla or "del") is a vector of partial derivative operators: \(\nabla = \left\langle \frac{\partial}{\partial x}, \frac{\partial}{\partial y}, \frac{\partial}{\partial z} \right\rangle\). It acts on \(f\) component by component.

Worked Example — Gradient of a Paraboloid

Let \(f(x,y) = x^2 + y^2\) (a bowl shape). Then:

\[ \frac{\partial f}{\partial x} = 2x \qquad \frac{\partial f}{\partial y} = 2y \] \[ \nabla f = \langle 2x,\; 2y \rangle \]

At the point \((1, 1)\): \(\nabla f = \langle 2, 2 \rangle\) — pointing diagonally away from the origin (outward and upward). At the origin \((0,0)\): \(\nabla f = \langle 0, 0 \rangle\) — the flat bottom of the bowl.

SymbolNameWhat It Tells You
\(\nabla f\)Gradient of \(f\)A vector field; at each point, a vector pointing uphill
\(\partial f / \partial x\)Partial w.r.t. \(x\)Slope in the \(x\)-direction, \(y\) frozen
\(\partial f / \partial y\)Partial w.r.t. \(y\)Slope in the \(y\)-direction, \(x\) frozen
\(|\nabla f|\)MagnitudeSteepness — how fast \(f\) rises in the steepest direction
\(\hat{\nabla f}\)Unit gradientDirection of steepest ascent (direction only)

The Geometric Picture — Contours and Arrows

Here is the most important geometric fact about the gradient. Imagine drawing level curves (contour lines) of \(f\) — curves along which \(f\) is constant, like elevation lines on a topographic map.

📐

Key Theorem: The gradient \(\nabla f\) at any point is always perpendicular to the level curve through that point, and it points in the direction of steepest increase of \(f\).

Why? Because along a level curve, \(f\) doesn't change — so there's no "slope" in that direction. All the slope is perpendicular to it. The gradient captures exactly that perpendicular component.

Fig. 1 — Gradient vectors (gold arrows) perpendicular to level curves of \(f(x,y) = x^2 + 0.5y^2\)

Notice in the diagram: each arrow points outward from the center — away from the minimum — and is perpendicular to the elliptical contour it sits on. Arrows are longer where the terrain is steeper (farther from center).

Mountain Analogy

Stand on a hillside. The contour line through your feet runs along the hill — no elevation change that way. The gradient arrow points straight uphill: perpendicular to the contour, in the direction that climbs fastest. That's exactly \(\nabla f\) in real life.

The Directional Derivative — Slope in Any Direction

Given a unit vector \(\hat{u} = \langle u_x, u_y \rangle\), the directional derivative answers: if I walk in the direction \(\hat{u}\), how fast does \(f\) change?

Directional Derivative
\[ D_{\hat{u}} f \;=\; \nabla f \cdot \hat{u} \;=\; |\nabla f|\,|\hat{u}|\cos\theta \;=\; |\nabla f|\cos\theta \]

This is just the dot product of the gradient with your direction of travel. Since \(|\hat{u}| = 1\), the formula reduces to \(|\nabla f|\cos\theta\), where \(\theta\) is the angle between \(\hat{u}\) and \(\nabla f\).

1
Walk parallel to \(\nabla f\) (\(\theta = 0\)): \(D_{\hat{u}} f = |\nabla f|\) — maximum rate of increase. This is steepest ascent.
2
Walk perpendicular to \(\nabla f\) (\(\theta = 90°\)): \(D_{\hat{u}} f = 0\) — no change. You're walking along a level curve.
3
Walk opposite to \(\nabla f\) (\(\theta = 180°\)): \(D_{\hat{u}} f = -|\nabla f|\) — steepest descent. This is the direction of fastest downhill.

The gradient is the master object: once you have it, you know the slope in every possible direction via one dot product. That's why it's so powerful.

Conservative Fields — When a Field Has a "Source Function"

Now we step from scalar functions to vector fields. A vector field \(\mathbf{F}(x,y)\) assigns an arrow (a vector) to every point in space. Think of gravity, electric fields, or fluid flow.

A vector field \(\mathbf{F}\) is called conservative if there exists a scalar function \(f\) such that:

Conservative Field — Definition
\[ \mathbf{F} \;=\; \nabla f \qquad \Longleftrightarrow \qquad F_x = \frac{\partial f}{\partial x},\quad F_y = \frac{\partial f}{\partial y} \]

The function \(f\) is called the potential function (or scalar potential) of \(\mathbf{F}\). In physics, if \(\mathbf{F}\) is a force field, then \(-f\) is the potential energy.

Why "Conservative"?

The name comes from energy conservation. If you move an object through a conservative force field from point \(A\) to point \(B\), the work done depends only on the endpoints — not on the path taken. Energy is conserved: whatever you "spent" getting there is recoverable by coming back.

Path Independence — The Key Property
\[ \int_C \mathbf{F} \cdot d\mathbf{r} \;=\; f(B) - f(A) \qquad \text{(same for ALL paths } C \text{ from } A \text{ to } B\text{)} \]

This is the Fundamental Theorem of Calculus for Line Integrals. It says: plug the endpoints into the potential function, subtract, done — you don't need to do the integral at all if you know \(f\).

Electric field analogy: The electric field \(\mathbf{E} = -\nabla V\) is conservative. Moving a charge from \(A\) to \(B\) always costs the same energy \(q(V_A - V_B)\) regardless of the path. That's why we can talk about "voltage" as a single number at each point.

Fig. 2 — Conservative field: all paths from A to B give the same line integral

Visually, conservative fields look like they "flow outward from a source" or "toward a sink" — they don't curl or spiral. Every field line is the steepest-descent path of the potential.

Non-Conservative Fields — When Paths Matter

Not every vector field has a potential function. A non-conservative field is one where the work done depends on which path you take — and in particular, going around a closed loop can give nonzero work.

Non-Conservative — Closed Loop Test
\[ \oint_C \mathbf{F} \cdot d\mathbf{r} \;\neq\; 0 \qquad \text{for some closed path } C \]

If you walk in a closed loop and the field does net work on you — you've gained or lost energy from the loop itself — the field is not conservative. There is no potential function \(f\) that could produce it.

Classic Non-Conservative Example

Consider the "swirling" field:

\[ \mathbf{F}(x,y) = \left\langle -y,\; x \right\rangle \]

This field rotates counterclockwise. Walk around a circle of radius \(r\) — the field pushes you the whole way around, and the line integral over the closed loop equals \(2\pi r^2 \neq 0\). No potential function can produce this field.

Fig. 3 — Non-conservative (rotational) field \(\mathbf{F} = \langle -y, x \rangle\): arrows swirl, path integral around the loop ≠ 0
Conservative ✓
  • Has potential function \(f\)
  • Path-independent integrals
  • Closed loop → zero work
  • Curl = 0 everywhere
  • Example: gravity, \(\mathbf{E}\)
Non-Conservative ✗
  • No potential function exists
  • Path matters
  • Closed loop → nonzero work
  • Curl ≠ 0 somewhere
  • Example: friction, swirl

The Curl Test — How to Check Conservativeness

Given \(\mathbf{F} = \langle M(x,y),\; N(x,y) \rangle\), how do we quickly check if it's conservative (i.e., if \(\mathbf{F} = \nabla f\) for some \(f\))?

If \(\mathbf{F} = \nabla f\), then \(M = \frac{\partial f}{\partial x}\) and \(N = \frac{\partial f}{\partial y}\). Now take cross-partials:

Cross-Partial (Clairaut's Theorem)
\[ \frac{\partial M}{\partial y} \;=\; \frac{\partial}{\partial y}\!\left(\frac{\partial f}{\partial x}\right) \;=\; \frac{\partial^2 f}{\partial y\,\partial x} \;=\; \frac{\partial^2 f}{\partial x\,\partial y} \;=\; \frac{\partial}{\partial x}\!\left(\frac{\partial f}{\partial y}\right) \;=\; \frac{\partial N}{\partial x} \]

Mixed partial derivatives are equal (for smooth \(f\)). So if \(\mathbf{F} = \nabla f\), we must have:

Conservative Test in 2D
\[ \frac{\partial M}{\partial y} \;=\; \frac{\partial N}{\partial x} \]

This is the 2D version of saying the curl of \(\mathbf{F}\) is zero. In 3D, the curl is \(\nabla \times \mathbf{F} = \mathbf{0}\). In 2D, it reduces to just this single scalar equation.

🌀

What curl measures: Place a tiny paddle wheel in the field. If it spins, the curl is nonzero — the field has rotation. A conservative field has zero curl everywhere: no spinning, no net circulation around any loop.

Worked Example — Testing Conservativeness

Field A: \(\mathbf{F} = \langle 2xy,\; x^2 + 3y^2 \rangle\). Let \(M = 2xy\), \(N = x^2 + 3y^2\).

\[ \frac{\partial M}{\partial y} = 2x \qquad \frac{\partial N}{\partial x} = 2x \quad \checkmark \]

Equal! Field A is conservative. The potential is \(f(x,y) = x^2 y + y^3 + C\).


Field B: \(\mathbf{F} = \langle -y,\; x \rangle\). Let \(M = -y\), \(N = x\).

\[ \frac{\partial M}{\partial y} = -1 \qquad \frac{\partial N}{\partial x} = 1 \quad \times \]

Not equal! Field B is non-conservative. No potential function exists.

Exact Differential Equations — The Same Idea, Reframed

Now here's where it gets beautiful. In ODEs, you'll encounter equations written as:

Exact ODE — Standard Form
\[ M(x,y)\,dx \;+\; N(x,y)\,dy \;=\; 0 \]

The equation is called exact if there exists a function \(F(x,y)\) such that:

Exactness Condition
\[ \frac{\partial F}{\partial x} = M \qquad \text{and} \qquad \frac{\partial F}{\partial y} = N \]

And the solution is simply \(F(x,y) = C\) (a constant) — a level curve of \(F\).

Why Is This the Same Thing?

Notice: the condition \(\frac{\partial F}{\partial x} = M\) and \(\frac{\partial F}{\partial y} = N\) says exactly that \(\mathbf{F} = \langle M, N \rangle = \nabla F\). The vector field \(\langle M, N \rangle\) is the gradient of \(F\).

The test for exactness is identically the conservative field test:

Exactness Test (same as conservative test!)
\[ \frac{\partial M}{\partial y} \;=\; \frac{\partial N}{\partial x} \]

How to Solve an Exact Equation — Step by Step

1
Verify exactness: Compute \(\partial M/\partial y\) and \(\partial N/\partial x\). If equal, proceed.
2
Integrate \(M\) with respect to \(x\): \[F(x,y) = \int M\,dx + g(y)\] The "+\(g(y)\)" is crucial — it's an arbitrary function of \(y\) alone (the "constant" of integration when treating \(x\) as the variable).
3
Use the \(N\) condition to find \(g(y)\): Differentiate your \(F\) with respect to \(y\), set it equal to \(N\), and solve for \(g'(y)\): \[\frac{\partial F}{\partial y} = N \quad \Rightarrow \quad g'(y) = N - \frac{\partial}{\partial y}\!\int M\,dx\] Then integrate to get \(g(y)\).
4
Write the solution: \(F(x,y) = C\). This is an implicit equation whose level curves are the solution trajectories.
Worked Example — Full Exact ODE Solution

Solve: \((2xy)\,dx + (x^2 + 3y^2)\,dy = 0\)

Step 1 — Exactness check:

\[ M = 2xy,\quad N = x^2 + 3y^2 \qquad \frac{\partial M}{\partial y} = 2x \;=\; \frac{\partial N}{\partial x} = 2x \quad \checkmark \]

Step 2 — Integrate \(M\) in \(x\):

\[ F = \int 2xy\,dx = x^2 y + g(y) \]

Step 3 — Use \(\partial F/\partial y = N\):

\[ \frac{\partial F}{\partial y} = x^2 + g'(y) \;=\; x^2 + 3y^2 \quad\Rightarrow\quad g'(y) = 3y^2 \quad\Rightarrow\quad g(y) = y^3 \]

Step 4 — Solution:

\[ \boxed{F(x,y) = x^2 y + y^3 = C} \]

Each value of \(C\) gives a different solution curve. The family of all solution curves are the level curves of \(F\).

Fig. 4 — Level curves of \(F(x,y) = x^2 y + y^3 = C\) are the solution curves of the exact ODE

The Grand Bridge

⚡ Unified View — Everything Is the Same Idea

Here is the core insight that ties everything together. These three statements are mathematically identical:

Vector Calculus Language
The vector field \(\mathbf{F} = \langle M, N \rangle\) is conservative with potential \(f\). \[\mathbf{F} = \nabla f, \qquad \frac{\partial M}{\partial y} = \frac{\partial N}{\partial x}\]
ODE Language
The equation \(M\,dx + N\,dy = 0\) is exact with potential \(F\). \[\frac{\partial F}{\partial x} = M,\quad \frac{\partial F}{\partial y} = N, \qquad \frac{\partial M}{\partial y} = \frac{\partial N}{\partial x}\]
Geometric Language
\(F(x,y) = C\) describes a family of level curves, each perpendicular to \(\nabla F\). The ODE solution trajectories are those level curves.

Why the Solutions Are Level Curves

The ODE \(M\,dx + N\,dy = 0\) can be read as a dot product:

Geometric Interpretation of the ODE
\[ \langle M, N \rangle \cdot \langle dx, dy \rangle = 0 \qquad \Longleftrightarrow \qquad \nabla F \cdot d\mathbf{r} = 0 \]

This says: the vector \(d\mathbf{r} = \langle dx, dy \rangle\) (your direction of motion along the solution) is perpendicular to \(\nabla F\). But what direction is perpendicular to the gradient? The tangent to a level curve! So the solution trajectories are exactly the level curves of \(F\).

🗺️

The ODE tells you which curves to walk along. The gradient tells you which direction is "uphill." Walking perpendicular to uphill means walking along a contour — constant altitude. That's your solution curve.

The Full Structural Map

Fig. 5 — The unified structure: scalar function → gradient → conservative field → exact equation → level-curve solutions

What About Non-Exact Equations?

If \(\partial M/\partial y \neq \partial N/\partial x\), the equation is not exact — same as the field being non-conservative. Just like non-conservative fields have no potential, non-exact ODEs have no \(F(x,y) = C\) form directly. The fix is an integrating factor \(\mu(x,y)\): multiply the whole equation by \(\mu\) so that the new \(\mu M\) and \(\mu N\) pass the exactness test. This is the ODE equivalent of "finding a potential by modifying the field."

Integrating Factor — Sketch

If \(\frac{\partial M}{\partial y} \neq \frac{\partial N}{\partial x}\), seek \(\mu(x)\) (function of \(x\) only) such that after multiplying:

\[ \frac{\partial(\mu M)}{\partial y} = \frac{\partial(\mu N)}{\partial x} \]

This simplifies to the ODE \(\mu' = \mu \cdot \frac{M_y - N_x}{N}\), which is solvable when the right side is purely a function of \(x\). Same strategy applies for \(\mu(y)\).

Interactive Gradient Field Explorer

Choose a scalar function below. The canvas shows its level curves and gradient field. Notice how gradient arrows are always perpendicular to the contours.

⬡ Vector Field Visualizer

Gold contours = level curves of f. Teal arrows = ∇f vectors. Note: arrows always ⊥ to contours.

The Complete Picture

Everything You've Learned
ConceptCore FormulaKey Insight
Gradient \(\nabla f\)\(\langle \partial f/\partial x,\; \partial f/\partial y \rangle\)Points uphill; ⊥ to level curves
Directional deriv.\(D_{\hat{u}} f = \nabla f \cdot \hat{u}\)Slope in any direction via dot product
Conservative field\(\mathbf{F} = \nabla f\)Path-independent; has potential
Conservative test\(\partial M/\partial y = \partial N/\partial x\)Zero curl = no rotation
Exact ODE\(M\,dx + N\,dy = 0\), same testSame math as conservative field
ODE solution\(F(x,y) = C\)Level curves of potential function
Non-exact fixIntegrating factor \(\mu\)Make non-conservative → conservative
💡

The gradient is the heart of it all. Once you see that "exact ODE" is just "conservative vector field" in different notation — and that solutions are level curves of the potential — the whole subject clicks into place as one coherent geometric idea.