Exponential growth
Consider the ODE The rate of change of equals itself. This law describes populations, compound interest, and unstable physical systems in some regimes. The exponential has this property and satisfies the initial condition, so This is the analytical solution. Most ODEs encountered in practice have no analytical solution, so you must compute numerically. The simplest numerical method is the Euler method.The Euler method
The Euler method approximates the solution by taking repeated short steps in the direction of the derivative. Choose a small step size . Starting from , replace the continuous ODE with the discrete update At each step, evaluate the slope at the current point and move a distance in that direction. After steps, the result approximates at time . The following Python function implements this update.Show plotting code
Show plotting code

Step size and error
The Euler method is first-order accurate. The global error at a fixed final time scales linearly with . Halving roughly halves the error. You can verify this by running Euler at several step sizes and plotting the error at on a log-log axis. A first-order method produces a straight line with slope 1.Show plotting code
Show plotting code

Rotation in two dimensions
An ODE can also describe a vector state . Its right-hand side is then a vector-valued function : The vector field assigns a velocity to every point in space. A solution follows this velocity. The Euler update has the same form: Consider the two-dimensional vector field for pure rotation: Each particle at position has a velocity perpendicular to its position vector. Its exact trajectory is a circle around the origin, traced counterclockwise.Show plotting code
Show plotting code

Generative models
The same construction appears in modern generative models. Replace the hand-written rotation field with a learned vector field parameterized by a neural network. Initialize the particles with Gaussian noise. Then apply the same Euler loop.- If is trained to match a target velocity field that connects Gaussian noise to the data distribution, the result is flow matching.
- If encodes the score of a noise-perturbed data distribution, the result is a diffusion model in its probability-flow ODE form.
References
- L. C. Evans, Partial Differential Equations (Chapter 1), for ODE basics and existence/uniqueness.
- E. Hairer, S. P. Nørsett, G. Wanner, Solving Ordinary Differential Equations I, the standard reference on Euler and its successors.
- Khan Academy, Differential equations, for an introductory video course.

