Gradient Flows
Eleven ideas from the theory of gradient flows, first in metric spaces and then in the Wasserstein space of probability measures, ending with the heat and Fokker–Planck equations as gradient flows of entropy. Run the schemes, drag the points, edit the histograms, draw a density, then check yourself with concept questions and practice problems.
Follows the chapter order of L. Ambrosio, N. Gigli and G. Savaré, Gradient Flows in Metric Spaces and in the Space of Probability Measures (Birkhäuser, Lectures in Mathematics ETH Zürich, 2005). Modules 1–4 follow Part I (Chapters 1–4) and modules 5–11 follow Part II (Chapters 5–11); the technical appendix (Chapter 12) is not covered. Chapter numbers refer to that book; the questions and examples here are written for this page.
Curves of maximal slope
In
The idea
In
Equality in Cauchy–Schwarz forces
Below, the curve follows
Explore
Worked example
Take
Compute the local slope
at every , including .For
, is differentiable with , so the slope is 1. At : for every , so . The minimum has slope zero even though has a corner there.Check that
satisfies the energy inequality on , first for and then for .For
: energy lost ; speed 1 and slope 1 give . Equality.For
: energy lost ; the integrals are , because after time 1 both speed and slope are zero. Equality again.Try the curve that moves twice as fast,
, on .Energy lost
. Right side: . The inequality fails: going faster costs more in than it gains in energy.What about the curve that never moves,
?Energy lost
, but the slope term is . It fails too. The slope term is what forces the curve to move; the speed term is what stops it moving too fast. Only balances them, and it is exactly the solution of the differential inclusion .
Check your understanding
Give
That is the Euclidean speed. The metric derivative is computed with the distance you are given. Each coordinate moves at speed 1, and the distance adds the two.
In
- Yes, this is the energy identity.Try
: the energy falls at rate . - No. It forces
to point along , but not the speed. - No. It does not even fix the direction.Equality in Cauchy–Schwarz,
, does force to be a nonnegative multiple of .
On
, since is a critical point.The slope measures descent. From you can go down at rate 1 in either direction.- Undefined, since
is not differentiable at 0.The slope is a limsup of difference quotients and is defined at every point of the domain.
Practice
The inequality implies the equationThe smooth case in
Let
Hint
Write
Solution
Pointwise,
A space with no moving curvesThe snowflake metric
On
Hint
From
Solution
Split
Minimizing movements
To build a gradient flow where there are no gradients, take small steps, each of which lowers the energy without moving too far. This is implicit Euler written as a minimization problem, and it makes sense in any metric space.
The idea
In
Explore
Worked example
Run the minimizing-movement scheme for
Solve one step: minimize
for given .The optimality condition is
. If this says , which is consistent when . If it says , i.e. . SoWrite out
from and compare it with the exact flow from the previous module. . The scheme is exact at the grid times, and in particular it lands on the minimum and stays there.Now explicit Euler with
: . What happens? It never settles: it oscillates around the minimum with amplitude of order , and goes up on every other step.Check the discrete energy inequality for the implicit step when
. . The energy drops by at least the "kinetic" term , which is the discrete version of .
Check your understanding
For
That is explicit Euler. Set the derivative of to zero. That is the exact flow after time , which the scheme only approximates.
Why is the minimizing-movement scheme, and not explicit Euler, the right starting point in a metric space?
- It only uses
and ; there is no vector to step along. - It is more accurate.Both are first-order methods. The point is that one of them can be written down at all.
- Its minimizer is always unique.Not for nonconvex
: see the next question. That is why the theory speaks of generalized minimizing movements.
Double well
, since .Compare values: , while .- Either
or : there are two minimizers and the scheme must choose. , the bottom of a well.At , , which is beaten by .
Practice
A discrete Hölder estimateWhere compactness comes from
Let
Hint
Sum the discrete energy inequality (it telescopes), then use Cauchy–Schwarz on
Solution
Summing
A concave energyWhen does a step exist?
Let
Solution
The Moreau–Yosida envelope
The value of one minimizing-movement step, seen as a function of the starting point, is a smoothed version of the energy. How it changes with
The idea
The picture: lower the downward parabola
Integrate the derivative from
the discrete counterpart of the energy inequality of Module 1, with both the speed and the slope terms. Passing to the limit in it is the heart of Chapter 3.
Explore
Worked example
Compute
What is
? (You solved this in the previous module.)Soft thresholding:
.Compute
.If
, and . If , . This is the Huber function: a parabola near the corner, joined to two lines. It is with .Check
in both regimes.For
: , and gives . For : , and . Both match.Check the slope estimate
. When is it an equality?For
: slope at is 1, and . Equality. For : has slope 0, while can be up to 1. Strict inequality (unless ). The step ends at a point with less slope than its speed suggests; this slack is why Chapter 3 gets an inequality in general and needs extra structure for equality.
Check your understanding
Fix
- It is nonincreasing in
, and tends to as (for l.s.c. ). - It is nondecreasing in
.Larger makes the penalty smaller for every , so the infimum can only go down. - It can go either way, depending on
.The monotonicity holds for every : compare the two infima competitor by competitor.
A step from
The estimate is at the endpoint . At the start the slope can be anything; for the jump function in the explorer it can even be at both ends. Equality holds for energies in , where . In general only the inequality survives: see the worked example with .
You can also jump to , where , at cost . For large it is cheaper to stay put and pay .
Practice
The envelope of a quadraticEverything explicit
For
Solution
The discrete energy inequality with slopesDe Giorgi's interpolation
Assuming the derivative formula and
Hint
Solution
λ-convexity and contraction
Without convexity, gradient flows can split (Module 1, quiz 3). With
The idea
In
Explore
Worked example
Prove the contraction estimate for a
What inequality does
give for ?Integrate the Hessian along the segment:
, soLet
be two gradient flows. Differentiate .Conclude.
With
, , so and . For the flows merge; for they never separate; for they may separate, but at a controlled rate, which is still enough for uniqueness.Show the bound is sharp.
For
the flow is , so exactly. In the explorer, the saddle with both points on a vertical line shows equality with .
Check your understanding
What is the largest
That is the -direction. In the -direction the second derivative vanishes at .- None:
is not convex.Both terms are convex functions, so is convex.
- at most 1.
- exactly 1.Contraction is an upper bound. In the corner example, two points on the same side of the corner come together as they stick to it.
- possibly more than 1, because of the corners.The EVI needs no smoothness: convexity alone gives contraction. Try the corner in the explorer.
For the saddle
: flows separate at most exponentially, so they are still unique.- Nothing: uniqueness needs
.Any real gives uniqueness. Non-uniqueness needs a failure of semiconvexity, like at the origin. - The distance still decreases.Two points separated vertically move apart like
.
Practice
Exponential decay of the energyλ > 0 and the Łojasiewicz inequality
Let
Hint
Minimize the right side of
Solution
The minimum over
Step size and convexityWhen is one step convex?
For the double well
Solution
Push-forwards and narrow convergence
Part II moves from points to probability measures. Two tools carry most of the weight: pushing a measure forward through a map (how mass is moved), and narrow convergence (how measures are compared in the limit).
The idea
Chapter 5 also covers disintegration (writing a plan on
Explore
Worked example
Let
Show
narrowly, whatever is.For bounded continuous
, , and . So the integrals converge to .Take
. Compute and . and , while has both equal to 0. The moments do not converge: the escaping mass carries a fixed amount of first moment to infinity, so the moments are not uniformly integrable.The only plan from
to sends everything to 0. Compute and for . and . Neither tends to 0, even though the narrow limit is .For which powers
does ? iff . At it stays equal to 1: narrow convergence holds, convergence fails, and the second moments are bounded but not uniformly integrable.
Check your understanding
Does
- Yes.
- No:
for every , but .Narrow convergence asks about integrals of continuous functions, not about the mass of every set. Mass may pile up on the boundary of a set in the limit.
Each has two preimages, , and both contribute. (uniform) compresses intervals near (its derivative vanishes there), so mass piles up near .
Which sequence in
It is tight (all mass in ); the even and odd subsequences converge.- the Gaussians
They converge to .
Practice
Affine images of GaussiansPush-forward in practice
Show that if
Solution
By change of variables,
Moments are lower semicontinuousTruncation
Show that if
Hint
Solution
Optimal transport
Moving one distribution of mass onto another costs something; the cheapest way to do it is the optimal transport problem. Optimal plans are recognised by a simple local test: no small rearrangement of who goes where can save anything.
The idea
For quadratic cost, the two-point test reads
Explore
Worked example
Let
Compute both costs for
.Translation:
. Flip: . Equal.Show that no plan does better than 1 for
.For any
, . So both maps are optimal: with linear cost the optimal plan need not be unique.Now
. Compute both costs.Translation: 1. Flip:
. The translation is cheaper.Show the translation is the unique optimal plan for
.By Jensen,
, with equality iff is -a.e. constant, i.e. is concentrated on . That plan is the translation. Strict convexity of the cost is what buys uniqueness, and the optimal map is monotone, as the two-point test predicts.
Check your understanding
- No: some optimal plan is a permutation (a perfect matching).
- Yes, in general.The plans form a polytope of doubly stochastic matrices (divided by
); a linear cost attains its minimum at a vertex, and the vertices are permutations. - Only for quadratic cost is there an optimal permutation.The vertex argument works for any cost.
For
- When
. - When the segments
and do not cross.Not crossing is what optimality forces for . Press "Crossing example": for squared cost the crossing pairing is the optimal one. - When
.Expand both costs: the squared norms cancel and only inner products remain.
, a rotation by It also pushes to , but it is not the gradient of a convex function. Its cost is , versus for .- There are many optimal maps.
is absolutely continuous, so Brenier's theorem gives uniqueness.
Practice
Monotone means optimal on the lineThe two-point test in 1-D
On
Solution
The test says
When mass must splitThree atoms to two
Let
Hint
By the previous problem the plan is monotone: fill the targets from left to right.
Solution
The Wasserstein distance
The optimal cost turns the probability measures into a metric space, the space where Part II's gradient flows live. On the line everything is explicit: sort the mass, and compare quantiles.
The idea
Explore
Worked example
Let
Write down the quantile functions and
. , . So , and .Find the displacement midpoint
and check . : uniform on . Then . The midpoint is a single interval of intermediate length, not two bumps.Find the quantile function of the mixture
. has mass spread on and on . So for and for .Is
on a geodesic between and ? , and . Then . The triangle inequality is strict, so lies on no geodesic between them. Load the "Split" preset and compare the two modes.
Check your understanding
, since they have the same mean. only for equal measures. Matching the mean is not enough. There is only one plan, and every unit of mass moves distance 1.
Along the mixture
That is along the displacement geodesic , where all the mass moves a distance . Here mass moves distance 1. The squared cost is , and is its square root, not its square.
, for every- at most
, and smaller when is spread outSome other plan might move mass less far on average? Jensen says no: . - it depends on the shape of
The lower bound from the means is attained by the translation itself, whatever is.
Practice
Gaussians on the lineA closed form
Show
Solution
Quantiles are
as an areaCDFs versus quantiles
Explain why
Solution
Both are the area of the region between the graphs of
The continuity equation
A curve of probability measures moves because its mass moves, with some velocity field. Many velocity fields can produce the same curve; the cheapest one is a gradient, and its kinetic energy is the curve's speed in
The idea
Watch
- A probability measure
: a Gaussian, drawn as a sample of particles with its density level sets. - Move every particle with the constant field
, a gradient (of ). The measure slides: . - Start again with
, the rotation by . Particles now swirl around the moving centre. - Yet the rings match: the swirl is divergence-free against the radial density,
. Same curve , two velocity fields. - The kinetic energies differ:
versus . The curve's speed is , achieved by the gradient field, which is the tangent vector.
Worked example
On
Write
as a push-forward of and read off a velocity. pushes to . A particle at moves with speed , so .Check the weak form of the continuity equation.
With
, .Compute the kinetic energy
. Is tangent? . And is a gradient, so it is the tangent field and .Compare the length of the curve with
.Length
, and by the Gaussian formula of Module 7. Length equals distance, so the curve is a geodesic, and the Benamou–Brenier action is minimal.
Check your understanding
On
- Exactly one.
- Infinitely many, as with the swirl.In one dimension
means is constant, and integrability forces the constant to be 0. - None, unless the curve is a geodesic.Every absolutely continuous curve has velocity fields; geodesics are the ones whose tangent field has constant norm and is "straight".
, because a Dirac mass has no density to move. , so the curve moves exactly as fast as the point.- It is undefined: there is no velocity field on the complement of the support.Only the values of
on the support of matter, since only sees them.
A curve on
Add a swirl: the kinetic energy goes up and the curve stays the same. The kinetic energy bounds the speed from above, not below.
Practice
The swirl is invisibleA divergence-free perturbation
Let
Solution
The velocity on the lineFrom the CDF
On
Solution
Integrate
Displacement convexity
Chapter 4 needs
The idea
The model examples (Ch. 9.3), with
- Potential energy
is -convex iff is -convex. Along mixtures it is always affine. - Interaction energy
is convex if is convex. With on it is the variance, which is concave along mixtures. - Internal energy
is convex if and is convex and nonincreasing on (McCann's condition). This covers the entropy and for . - Relative entropy with respect to
is -convex iff is -convex (Ch. 9.4): the entropy of a log-concave reference measure.
Explore
Worked example
Compute the entropy
Compute
. , and the second term averages to . So .Along the geodesic from
to , what is ?By Module 7 the geodesic is
with . So .Is it convex in
? Is it -convex for some ? , so it is convex. But if and (a translation) it is constant along a geodesic of positive length, so no works: the entropy is exactly 0-convex.Why is the entropy convex along every 1-D geodesic, Gaussian or not?
With quantile
, (because ). Along a geodesic is affine in for each , and is convex. In the explorer, the entropy curve is convex for every preset.
Check your understanding
For which
- Exactly the convex
. - Every
, since is linear.It is linear along mixtures. Along the geodesic between two Dirac masses it equals , which is convex only if is. - Every
bounded below.Try the double well across the origin in the explorer.
Is the entropy
- No: it is constant along translations, which are geodesics.
- Yes, with
.That is the entropy relative to the standard Gaussian, where the added potential supplies the 1-convexity. - No, it is not even convex.It is convex (0-convex) by McCann's condition:
is convex and nonincreasing.
- Along the displacement interpolation only.
- Along both.Along the mixture
the variance is . - Along the mixture only.The displacement interpolation is
, with variance 0 throughout: that is convex.
Practice
Entropy relative to a GaussianWhere λ = 1 comes from
Let
Solution
The quadratic internal energyQuantiles again
On
Hint
Solution
The Wasserstein gradient
On
The idea
For smooth densities the recipe is: take the first variation
- potential energy
: ; - interaction energy
( even): ; - internal energy
: with , which is for smooth . For the entropy, .
The first-variation identity behind all of this:
Explore
Worked example
On
What is
for a general smooth positive ?The first variation is
, so .Evaluate it for
. , so : an affine field.Compute
.Write
with , . Then , and . Sowhich vanishes only for , the reference measure.Move every particle with velocity
. What happens to and ?A particle at
moves with velocity . Matching the parts with and without : and . So Gaussians stay Gaussian, and , i.e. . This is the Ornstein–Uhlenbeck flow you will run in the next module.
Check your understanding
What is the Wasserstein gradient of the potential energy
- The vector field
, viewed in . - The function
. is the first variation (the gradient). The Wasserstein gradient is a velocity, so it is . - The measure
.That is the flux in the continuity equation, not the velocity .
What is the slope of the entropy at
, because inside the interval.The jumps at 0 and 1 matter: . The heat flow spreads them at infinite initial speed. There is no finite subgradient: any finite would make the entropy change at a finite rate under the heat flow, but it drops infinitely fast at first.
For the relative entropy with respect to
- Exactly when
. - When
is a Dirac mass at a minimum of .A Dirac mass has infinite entropy; it is not in the domain. - Never: the entropy always pushes mass outward.The potential pushes inward. They balance when
.
Practice
The gradient of an interaction energyA first-variation computation
Let
Solution
Fisher information of a GaussianAnd the entropy's decay rate
Compute
Solution
Heat and Fokker–Planck by JKO
Everything comes together: the minimizing-movement scheme of Module 2, run in the Wasserstein space with the free energy of Modules 9 and 10, produces the heat equation and the Fokker–Planck equation. Here it runs on particles, one minimization per step.
The idea
With the free energy
How the simulation works. On the line, a measure made of
Explore
Worked example
Do one JKO step for the heat equation (
Write the JKO functional as a function of
. (Module 7) and (Module 9). So minimize .Solve for
.The derivative is
, i.e. , so .Compare
with the exact heat flow, .From
and : . One step is first-order accurate. In fact is implicit Euler for , the exact ODE for the standard deviation.Why is assuming a Gaussian minimizer harmless here?
The entropy is convex along generalized geodesics, so the JKO functional is strictly convex along them and any critical point is the global minimizer. The Gaussian candidate satisfies the optimality condition
, where is the optimal map back to : it reads , which is the equation of step 2.
Check your understanding
Which functional has
The Dirichlet energy gives the heat equation as its gradient flow, not as a one. In it gives a fourth-order equation. Check the sign: the velocity is , so mass flows down .
Two solutions of the heat equation on
That needs , as for Ornstein–Uhlenbeck. Two heat flows from translated data stay translates of each other, at constant distance.- It may grow, since diffusion spreads mass.The entropy is 0-convex, so the flow is 0-contracting.
Can the heat flow start from
- Yes:
lies in the -closure of the domain, and the flow is . - No: the first JKO step needs
.The step itself is fine: the minimization over only needs for some competitor. Chapter 4's theory covers initial data in the closure of the domain. - Yes, but it stays at
.The slope term in the energy inequality forces it to move, as in Module 1.
Practice
Exponential contraction for Ornstein–UhlenbeckChecking λ = 1 by hand
With
Hint
Solution
The mean term is
The porous medium equationA different internal energy
Show that the
Solution
The first variation is