Langevin Equation and Stochastic Differential Equations
The physical Langevin equation — a heavy particle in a fluid feeling friction plus a random force , with the fluctuation–dissipation lock tying noise to drag — is derived and owned by `langevin-equation`. This article takes the next step and treats that equation as a stochastic differential equation: a mathematical object driven by a Wiener process, to be manipulated, mapped to a Fokker–Planck equation, and above all integrated numerically. The physics of the noise lock and the velocity autocorrelation we recall by name; what we build is the calculus and the algorithms. A stochastic differential equation looks like an ordinary differential equation but is not, because the driving Wiener increment is not smooth: it scales as , so rather than the naive zero. This single rule — the quadratic variation of Brownian motion — is what forces a special calculus and gives stochastic integrals their Itô versus Stratonovich ambiguity. That calculus (Itô's lemma, the drift-shift between conventions) is derived and owned by `ito-stratonovich-calculus`; we cite its results and use them. The practical payoff is simulation. Discretising an SDE is not the same as discretising an ODE: the naive Euler step becomes the Euler–Maruyama scheme, whose random increment must be drawn as , and whose accuracy is characterised by two distinct convergence orders — strong (pathwise) order and weak (in distribution) order . Adding the Milstein correction restores strong order for multiplicative noise. These algorithms are the engine of Brownian and Langevin dynamics simulations, of Langevin Monte-Carlo samplers in Bayesian computation, and of the stochastic thermostats used in molecular dynamics. The SDE is where the physics of the Langevin equation becomes runnable code.
- This article treats the Langevin equation as a stochastic differential equation and covers its calculus and numerical integration; the physical friction+noise equation, the fluctuation–dissipation noise lock , and the velocity autocorrelation are owned by `langevin-equation` and recalled by name.
- An SDE is driven by Wiener increments with and — Brownian motion has non-vanishing quadratic variation.
- The SDE↔Fokker–Planck dictionary (Itô convention) reads drift , diffusion ; the Itô/Stratonovich distinction and Itô's lemma are owned by `ito-stratonovich-calculus`.
- Euler–Maruyama, , is the basic integrator; its strong (pathwise) order is and its weak (distributional) order is .
- The Milstein scheme adds to recover strong order for state-dependent (multiplicative) noise.
- Key idea: A stochastic differential equation is an Itô/Stratonovich object driven by with ; discretising it correctly (Euler–Maruyama, Milstein) turns the Langevin equation into a simulation whose stationary distribution is the target Boltzmann weight.
A stochastic differential equation is an Itô/Stratonovich object driven by with ; discretising it correctly (Euler–Maruyama, Milstein) turns the Langevin equation into a runnable simulation whose stationary distribution is the target Boltzmann weight.
Where this lives today
Euler–Maruyama and its refinements are the runtime of an enormous amount of computational science. In molecular dynamics, Langevin thermostats (BAOAB and related splittings) integrate an SDE to sample the canonical ensemble — the subject of `aq-sm-thermostats-md-ensembles`. In machine learning and Bayesian statistics, the unadjusted Langevin algorithm and its Metropolis-corrected cousin (MALA) discretise the overdamped Langevin SDE to draw samples from a posterior, and the same overdamped SDE is the continuous-time limit behind stochastic-gradient methods and diffusion generative models. In quantitative finance, SDE integrators price path-dependent derivatives by Monte-Carlo. In every case the correctness of the answer rests on the two things this article isolates: the noise scaling and the strong/weak order that tells you whether you may trust paths or only averages.
Origins · 1 minlangevin dynamics and how this was discovered
The physical picture
The whole subtlety lives in one fact: the driving noise is rough. A Wiener path is continuous but nowhere differentiable, and over a small time its increment is of order , not . Square it and average and you get — a first-order quantity, not the second-order thing you would expect for a smooth path. This is why is only a formal expression: the rigorous object is the integrated increment , and the equation must be written in differential (SDE) form.
Numerically the roughness has teeth. If you discretise an SDE with an ordinary Euler step but forget to scale the noise as , you get the wrong diffusion entirely. Even done right, the accuracy splits into two notions that coincide for ODEs but differ for SDEs: strong convergence tracks how close your simulated path stays to the true path driven by the same noise; weak convergence tracks how close the simulated distribution is to the true one. Euler–Maruyama is strong order but weak order — so it is twice as accurate for computing averages as for tracking individual trajectories. The punchline figure below shows the payoff: an Euler–Maruyama ensemble on an Ornstein–Uhlenbeck process, whose histogram converges onto the exact Gaussian stationary density — the algorithm reproducing the theory.
The core equations
The general Itô stochastic differential equation is written with a drift and a diffusion coefficient multiplying, respectively, the deterministic time increment and the Wiener increment. This is the mathematical form; the physical Langevin equation with friction, potential, and thermal noise is its instance owned by `langevin-equation`.
where: — drift coefficient; — diffusion (noise) coefficient; — Wiener increment. The defining property of the driving process is that its increments are Gaussian with zero mean and variance equal to the time step — the quadratic-variation rule that makes the calculus non-classical.
where: — increments of standard Brownian motion, independent over disjoint intervals. An Itô SDE maps to a Fokker–Planck equation for the density of its solutions, with the drift carrying straight over and the diffusion coefficient being the square of the noise amplitude. The convention-dependence of this map, and Itô's lemma behind it, are owned by `ito-stratonovich-calculus`.
where: — density of trajectories; — Fokker–Planck drift (Itô); — Fokker–Planck diffusion; the factor is the Itô convention. The Euler–Maruyama scheme is the stochastic analogue of the forward Euler method: advance the drift linearly and add a noise increment drawn with the correct scaling.
where: — time step; — independent standard-normal draws; realises the Wiener increment . Euler–Maruyama's accuracy is characterised by two convergence orders, and the Milstein correction upgrades the strong one for multiplicative noise.
where: strong order measures pathwise error at fixed noise; weak order measures error of distributions/expectations; the Milstein term restores strong order .
The core derivations
The goal is to establish that the Itô SDE describes the same process as the Fokker–Planck equation , by computing how the average of an arbitrary observable evolves and matching it to the density equation. The one non-classical ingredient — Itô's lemma, which keeps the term — is owned by `ito-stratonovich-calculus`; we invoke it and do the bookkeeping. This is the bridge that lets us switch freely between trajectory simulations and density calculations.
Step 1. For a smooth observable , Itô's lemma (owned by `ito-stratonovich-calculus`) gives
Why: the extra survives because is first order — this is the whole content of Itô calculus.
Step 2. Take expectations; the noise term drops because and is non-anticipating:
Why: the Itô integral of a non-anticipating integrand against has zero mean; averaging leaves only the drift and the Itô diffusion term.
Step 3. Also write the left side through the density, , so , and integrate the right side by parts:
Why: move the derivatives off onto (boundary terms vanish for confined densities), turning into and into .
Step 4. Since is arbitrary the integrands match, giving the Fokker–Planck equation of (3) with , . Why: two integrals equal for every test function force the bracketed expressions equal — the SDE and the Fokker–Planck equation are the trajectory and density faces of one process. Verified: the OU drift/diffusion identification and the resulting stationary variance (with zero probability current) are checked symbolically in verify_aq-sm-langevin-equation-sm11.py.
Go deeper · Derivation B · 1 minEuler–Maruyama and its convergence orders
The goal is to construct the basic SDE integrator and to explain why it has two different convergence orders — strong and weak — a phenomenon with no ODE analogue. Getting the noise scaling right (, not ) and understanding these orders is what separates a correct Langevin simulation from a subtly wrong one, and it sets the stage for the Milstein upgrade.
Step 1. Integrate the SDE over one step and freeze the coefficients at the left endpoint:
Why: the Itô convention evaluates the integrand at the start of the interval; approximating by their left-endpoint values is the first-order (Euler) truncation.
Step 2. Realise the Wiener increment as with :
Why: by equation (2) the increment has variance , so its standard deviation is — scaling the normal draw this way is mandatory; using would give diffusion .
Step 3. Strong (pathwise) error: the leading unaccounted term comes from the variation of over the step, of size , entering the position error as after summing steps with random signs.
Why: the missing Itô correction is per step but adds in quadrature over steps, leaving pathwise.
Step 4. Weak (distributional) error: for expectations the odd noise terms average out, and the leading systematic error is .
Why: averaging cancels the mean-zero fluctuation that limits strong convergence, so distributions converge one order faster than paths — the reason Euler–Maruyama is perfectly adequate for computing thermal averages. Verified: the strong-order- scaling (error ratio when ), the explicit one-step update , and Euler–Maruyama convergence of the OU variance to are all checked in verify_aq-sm-langevin-equation-sm11.py.
Limiting cases
The SDE and its integrators specialise by the form of the coefficients; the physical FDT lock behind the thermal case is owned by `langevin-equation`.
| Case | Result | Meaning |
|---|---|---|
| Additive noise (const) | Itô = Stratonovich; , | The thermal Langevin force; no spurious drift, either convention works. |
| Multiplicative noise () | Itô and Stratonovich drifts differ by | Convention matters; the drift-shift is owned by `ito-stratonovich-calculus`. |
| Overdamped Langevin | The Smoluchowski/Langevin-Monte-Carlo sampler; stationary state . | |
| Milstein scheme | Restores strong order for multiplicative noise; unnecessary for additive noise. |
Worked examples
Example 1 — One Euler–Maruyama step (a real number). Integrate the Ornstein–Uhlenbeck SDE with , , one step of from , given the realised Wiener increment .
Step 1. Drift term: .
Step 2. Noise term: .
Step 3. Update: . The particle drifted slightly toward the origin (restoring drift) but was pushed out by the noise on this step.
Example 2 — Long-run variance reproduces the theory. Run the same OU scheme to steady state. The theoretical stationary variance is .
Step 1. From the SDE↔FP dictionary, , , so the stationary Gaussian has variance (zero-current condition ).
Step 2. Numerically: .
Step 3. An Euler–Maruyama ensemble of thousands of walkers, sampled after burn-in, gives an empirical variance of — agreement to about as , exactly the punchline figure. The algorithm reproduces the theory, which is the entire point of a validated integrator.
Going further
Texts. Kloeden & Platen, Numerical Solution of Stochastic Differential Equations (the standard reference on strong/weak order, Euler–Maruyama, Milstein) · Gardiner, Handbook of Stochastic Methods, ch. 4 · Øksendal, Stochastic Differential Equations · Pathria & Beale, Statistical Mechanics, 3rd ed., ch. 15 · Leimkuhler & Matthews, Molecular Dynamics (Langevin integrators).
Provenance. The physical Langevin equation, the fluctuation–dissipation noise lock , the velocity autocorrelation, and the Green–Kubo diffusion constant are derived and owned by `langevin-equation`; the Itô/Stratonovich calculus, , Itô's lemma, and the drift-shift are owned by `ito-stratonovich-calculus`. This article recalls both by name and does not re-derive them. The SDE↔Fokker–Planck dictionary follows Gardiner ch. 4; Euler–Maruyama, its strong order /weak order , and the Milstein correction follow Kloeden & Platen. A verifier should: (i) confirm and non-vanishing quadratic variation; (ii) check the OU SDE↔FP identification and stationary variance ; (iii) confirm Euler–Maruyama reproduces and scales with strong order ; (iv) verify the one-step update .
Builds on: Markov Processes and the Markov Property · Fluctuation–Dissipation Theorem · Chapman–Kolmogorov Equation. Leads to: Fokker–Planck Equation · Thermostats and Ensemble Control in Molecular Dynamics · Molecular Dynamics Simulation · Detailed Balance and Microscopic Reversibility.
If `langevin-equation` owns the Langevin equation, what is left for this article?
The physics of the equation — friction plus thermal noise, the fluctuation–dissipation lock , the velocity autocorrelation, the Einstein/Green–Kubo diffusion constant — is owned by `langevin-equation`. This article owns the mathematical and computational object: how to write the equation as an Itô/Stratonovich SDE, how it maps to a Fokker–Planck equation, and above all how to integrate it numerically (Euler–Maruyama, Milstein, and the strong/weak convergence orders). It is the difference between knowing the physical law and being able to simulate it correctly.
Why is rather than zero?
Because Brownian motion is rough. Over a time the Wiener increment has standard deviation , so has mean — a first-order quantity. Summing over an interval gives its length (non-vanishing quadratic variation), whereas for a smooth path . This one fact forces stochastic calculus: in Itô's lemma the second-derivative term cannot be dropped, and it is the origin of the extra diffusion drift and of the Itô/Stratonovich distinction. The full calculus is owned by `ito-stratonovich-calculus`.
What is the difference between strong and weak convergence, in practice?
Strong convergence asks how close your simulated path stays to the true path driven by the same realisation of the noise — it is pathwise accuracy. Weak convergence asks only how close the simulated distribution (or any expectation ) is to the true one. For ODEs these coincide, but for SDEs Euler–Maruyama is strong order and weak order . In practice: if you want thermal averages, correlation functions, or free energies, weak order governs your error and Euler–Maruyama is fine; if you must reproduce a specific trajectory (rare in statistical physics, common in filtering), you need the higher strong order that Milstein provides.
When do I actually need the Milstein scheme?
Only for multiplicative noise, where the diffusion coefficient depends on the state. There the term that Euler–Maruyama omits is what limits its strong order to ; adding it back gives strong order . For additive noise — constant , which is the standard thermal Langevin force — , the Milstein correction vanishes identically, and Euler–Maruyama is already strong order . So for most equilibrium molecular-dynamics thermostats you never need Milstein; you need it for models with state-dependent noise amplitude (some population, finance, and reaction models).
Does the discretisation preserve the correct stationary distribution?
Not exactly — a finite Euler–Maruyama step samples a distribution that is away from the true Boltzmann weight, because the discretisation introduces a bias. There are two standard fixes. Reduce until the bias is negligible (cheap but slow), or add a Metropolis accept/reject step that corrects the bias exactly — this is the Metropolis-adjusted Langevin algorithm (MALA), which combines the gradient-informed Langevin proposal with the acceptance rule owned by `aq-sm-metropolis-hastings-algorithm`. The unadjusted algorithm trades a small controllable bias for speed; the adjusted one is exact at the cost of occasional rejections.
How does this connect to Langevin thermostats in molecular dynamics?
A Langevin thermostat adds friction and FDT-consistent noise to Newton's equations, turning the molecular-dynamics update into an SDE integrator. The physics — that the noise strength must equal to sample the canonical ensemble — is owned by `langevin-equation`; the numerics of splitting that SDE into accurate, stable steps (the BAOAB scheme and relatives) is exactly the Euler–Maruyama/Milstein technology of this article applied with care about operator splitting. The stationary distribution is the canonical Boltzmann weight, and getting there correctly is the concern of `aq-sm-thermostats-md-ensembles`.