Ordinary Differential Equations

Dive into Deep Learning · §38.1

Ordinary Differential Equations, Phase Portraits, and Flows
vector fields · Picard–Lindelöf uniqueness · flow bijections · matrix exponential · phase portraits

When Does a Velocity Field Determine a Unique Motion?

Motivation

  • Global Lipschitz (\dot{x} = -x, x_0 = 1): Unique solution x(t) = e^{-t} on all [0, T], defining an invertible flow \Phi_t(x_0) = e^{-t}x_0.
  • Non-Lipschitz (\dot{x} = \sqrt{|x|}, x_0 = 0): Infinitely many solutions x_c(t) = (t-c)^2/4 branch from 0, breaking uniqueness and invertibility.
  • Local Lipschitz only (\dot{x} = x^2, x_0 > 0): Unique locally, but blows up to \infty at finite time t^\star = 1/x_0.

Elementary Motions: Exponential Decay and Rotation

Building Blocks

  • Radial decay (\dot{x} = -x): Velocity points inward in proportion to distance, shrinking |x(t)| = e^{-t}|x_0|.
  • Orthogonal rotation (\dot{\mathbf{x}} = \mathbf{K}\mathbf{x} with \mathbf{K} = \left(\begin{smallmatrix}0 & -1 \\ 1 & 0\end{smallmatrix}\right)): Because \mathbf{x}^\top\mathbf{K}\mathbf{x} = 0, the velocity is perpendicular to position, conserving length \frac{d}{dt}\|\mathbf{x}\|^2 = 0 at unit angular speed.
  • Combined planar spiral (\mathbf{A} = -\tfrac12\mathbf{I} + \mathbf{K}): Eigenvalues \lambda = -0.5 \pm \mathrm{i} decay as e^{-t/2} while rotating at 1\text{ rad/s}.

Running Example: Decay Plus Rotation Is a Spiral

Vector Fields

Combining half the decay rate with unit rotation produces our running planar system \dot{\mathbf{x}} = \mathbf{A}\mathbf{x}:

  • System Matrix: \mathbf{A} = -\tfrac{1}{2}\mathbf{I} + \mathbf{K} = \left(\begin{smallmatrix}-0.5 & -1 \\ 1 & -0.5\end{smallmatrix}\right).
  • Length Evolution: The rotation term \mathbf{K} preserves length while -\tfrac{1}{2}\mathbf{I} contracts it: \frac{d}{dt}\|\mathbf{x}\|^2 = 2\,\mathbf{x}^\top \mathbf{A}\mathbf{x} = -\|\mathbf{x}\|^2
  • Spiral Trajectory: The norm decays as \|\mathbf{x}(t)\| = e^{-t/2}\|\mathbf{x}_0\| while turning at 1 rad/s into the fixed point \mathbf{x}^\star = \mathbf{0}.
  • Eigenvalue Signature: \mathbf{A} has complex eigenvalues \lambda = -0.5 \pm \mathrm{i} (real part = decay rate -\tfrac{1}{2}, imaginary part = angular speed \pm 1).

The Initial-Value Problem and Its Integral Form

Formal Definitions

A general first-order ordinary differential equation prescribes a velocity vector at every point and instant of time, paired with a starting state:

\dot{\mathbf{x}}(t) = \mathbf{f}(\mathbf{x}(t), t), \qquad \mathbf{x}(0) = \mathbf{x}_0 \in \mathbb{R}^d

  • Vector Field (\mathbf{f}: \mathbb{R}^d \times \mathbb{R} \to \mathbb{R}^d): Assigns a velocity arrow \mathbf{f}(\mathbf{x}, t) to each position \mathbf{x} at time t. The system is autonomous when \mathbf{f}(\mathbf{x}) is independent of t (the arrows stand still while particles move).
  • Trajectory (\mathbf{x}(t)): A differentiable curve through \mathbf{x}_0 whose tangent \dot{\mathbf{x}}(t) matches the local arrow \mathbf{f}(\mathbf{x}(t), t) at every instant.
  • Equivalent Integral Form: Integrating both sides from 0 to t by the fundamental theorem of calculus expresses the state as the initial value plus accumulated velocity: \mathbf{x}(t) = \mathbf{x}_0 + \int_0^t \mathbf{f}(\mathbf{x}(s), s)\,ds

When Uniqueness Fails: Non-Lipschitz Branching

Counterexample

If the velocity changes too abruptly near a point, a single initial condition can spawn infinitely many valid trajectories:

  • The Fan Equation: Consider \dot{x} = \sqrt{|x|} started at rest (x_0 = 0).
  • Infinitely Many Solutions: Besides x(t) \equiv 0, a particle can wait at 0 until any departure time c \ge 0 and then leave along a parabola: x_c(t) = \begin{cases} 0, & t \le c \\ (t - c)^2 / 4, & t > c \end{cases}
  • Root Cause: The derivative \frac{d}{dx}\sqrt{x} = \frac{1}{2\sqrt{x}} \to \infty as x \to 0^+. No linear constant L can bound |f(x) - f(0)| \le L|x - 0| near the origin.

Picard Iteration: Building Solutions by Integration

Constructive Existence

The Picard integral operator P maps any continuous path \boldsymbol{\varphi} to a refined path:

(P\boldsymbol{\varphi})(t) = \mathbf{x}_0 + \int_0^t \mathbf{f}(\boldsymbol{\varphi}(s), s)\,ds

  • Fixed-point equivalence: \boldsymbol{\varphi} = P\boldsymbol{\varphi} iff \boldsymbol{\varphi} solves the ODE.
  • Banach contraction: When \mathbf{f} is globally L-Lipschitz, choosing \delta = 1/(2L) halves path distance at every step, and \lceil 2LT \rceil uniform restarts cover any horizon [0, T].

The Picard–Lindelöf Existence and Uniqueness Theorem

Core Theorem

A global bound on how fast the vector field changes from point to point makes the Picard operator P a strict contraction:

Theorem (Picard–Lindelöf): If \mathbf{f}(\mathbf{x}, t) is continuous in t and globally L-Lipschitz in \mathbf{x}, \|\mathbf{f}(\mathbf{x}, t) - \mathbf{f}(\mathbf{y}, t)\| \le L\,\|\mathbf{x} - \mathbf{y}\| \qquad \text{for all } \mathbf{x}, \mathbf{y} \in \mathbb{R}^d,\; t \in [0, T], then \dot{\mathbf{x}} = \mathbf{f}(\mathbf{x}, t), \mathbf{x}(0) = \mathbf{x}_0 has exactly one solution on [0, T] for every \mathbf{x}_0 and every T > 0.

  • Contraction on Short Intervals: Measuring path distance by d(\boldsymbol{\varphi}, \boldsymbol{\psi}) = \max_{t \le \delta}\|\boldsymbol{\varphi}(t) - \boldsymbol{\psi}(t)\|, pulling the Lipschitz constant through the integral gives: d(P\boldsymbol{\varphi}, P\boldsymbol{\psi}) \le \int_0^\delta L\,\|\boldsymbol{\varphi}(s) - \boldsymbol{\psi}(s)\|\,ds \le L\delta\,d(\boldsymbol{\varphi}, \boldsymbol{\psi})
  • Global Extension: Choosing \delta = \frac{1}{2L} halves the distance at every Picard step, guaranteeing convergence and uniqueness on [0, \delta]. Because L is global, \delta is independent of the state, so \lceil 2LT \rceil restarts cover all of [0, T].

Local Lipschitz Without Global Bounds: Blow-Up

Limits of the Theorem

When f(x) = x^2 is only locally Lipschitz (L_\rho = 2\rho on |x| \le \rho), the solution escapes to +\infty in finite time:

\dot{x} = x^2, \quad x(0) = x_0 > 0 \;\Longrightarrow\; x(t) = \frac{x_0}{1 - x_0 t}

  • Why the theorem gives out: As x(t) grows, the safe Picard step \delta_\rho = 1/(2L_\rho) = 1/(4\rho) shrinks, and the restarts can add up to a finite time. They guarantee a solution only for a while; the blow-up time t^\star = 1/x_0 is read from the formula.

The Flow Map Is a Smooth Bijection of Space

Flow Maps & Invertibility

Fixing a globally Lipschitz vector field and varying \mathbf{x}_0 defines the flow map \Phi_t(\mathbf{x}_0) = \mathbf{x}(t):

\Phi_0 = \mathrm{id}, \qquad \Phi_{t+s} = \Phi_t \circ \Phi_s, \qquad \Phi_t^{-1} = \Phi_{-t}

  • Bijection & non-crossing: Reversing time (\dot{\mathbf{y}} = -\mathbf{f}(\mathbf{y}, T-s)) is also globally L-Lipschitz, so distinct trajectories can never cross in space-time and \Phi_T : \mathbb{R}^d \to \mathbb{R}^d is a smooth bijection.

Linear Systems and the Matrix Exponential Series

Linear ODEs

Just as \dot{x} = ax is solved by x(t) = e^{at}x_0, the d-dimensional linear system \dot{\mathbf{x}} = \mathbf{A}\mathbf{x} is solved by the matrix exponential power series:

e^{\mathbf{A}t} = \sum_{k=0}^\infty \frac{(\mathbf{A}t)^k}{k!} = \mathbf{I} + t\mathbf{A} + \frac{t^2}{2}\mathbf{A}^2 + \frac{t^3}{6}\mathbf{A}^3 + \cdots

  • Universal Convergence: Submultiplicativity of the spectral norm (\|\mathbf{A}^k\| \le \|\mathbf{A}\|^k) ensures the series is dominated term-by-term by the convergent scalar exponential e^{\|\mathbf{A}\||t|}.
  • Term-by-Term Differentiation: Differentiating the series shows that \mathbf{x}(t) = e^{\mathbf{A}t}\mathbf{x}_0 is the unique Picard–Lindelöf solution (L = \|\mathbf{A}\|_2): \frac{d}{dt}e^{\mathbf{A}t} = \sum_{k=1}^\infty \frac{\mathbf{A}^k t^{k-1}}{(k-1)!} = \mathbf{A}\sum_{j=0}^\infty \frac{(\mathbf{A}t)^j}{j!} = \mathbf{A}e^{\mathbf{A}t}

Spectral Decoupling into Independent Eigenmodes

Eigendecomposition

Diagonalizing \mathbf{A} = \mathbf{V}\boldsymbol{\Lambda}\mathbf{V}^{-1} telescopes (\mathbf{A}t)^k = \mathbf{V}(\boldsymbol{\Lambda}t)^k\mathbf{V}^{-1} and decouples the matrix exponential:

e^{\mathbf{A}t} = \mathbf{V}\,\mathrm{diag}\!\left(e^{\lambda_1 t}, \ldots, e^{\lambda_d t}\right)\mathbf{V}^{-1}

  • Mode superposition: Expanding \mathbf{x}_0 = \sum_{j=1}^d c_j\mathbf{v}_j decouples the system into d independent scalar exponentials \mathbf{x}(t) = \sum_{j=1}^d c_j e^{\lambda_j t}\mathbf{v}_j.

Closed-Form Matrix Exponential for the Planar Spiral

Commuting Matrices

Because -\tfrac12\mathbf{I} and \mathbf{K} commute, e^{(-\frac12\mathbf{I} + \mathbf{K})t} = e^{-t/2\mathbf{I}}e^{\mathbf{K}t}:

e^{\mathbf{A}t} = e^{-t/2}\begin{pmatrix}\cos t & -\sin t \\ \sin t & \cos t\end{pmatrix}

  • Cyclic powers of \mathbf{K}: Since \mathbf{K}^2 = -\mathbf{I}, even powers sum to \cos t\,\mathbf{I} and odd powers sum to \sin t\,\mathbf{K}.
  • Non-commuting warning: When \mathbf{P}\mathbf{Q} \neq \mathbf{Q}\mathbf{P}, e^{\mathbf{P}+\mathbf{Q}} \neq e^{\mathbf{P}}e^{\mathbf{Q}}.

Matrix Compound Interest Converges Only at O(1/n)

Numerical Verification

Taking n short steps of length t/n along the linear field gives the compound-interest approximation (\mathbf{I} + t\mathbf{A}/n)^n \approx e^{\mathbf{A}t}, whose error on each eigenvalue is governed by \log(1 + z) = z - z^2/2 + \cdots:

\left(1 + \frac{\lambda t}{n}\right)^n \approx e^{\lambda t}\left(1 - \frac{(\lambda t)^2}{2n}\right) \;\Longrightarrow\; \text{error at } t = 2 \text{ is } \frac{|\lambda t|^2}{2n}e^{-1} = \frac{2.5\,e^{-1}}{n} \approx \frac{0.90}{n}

eigenvalues of A: [-0.5+1.j -0.5-1.j]
x(2) = [-0.3062  0.669 ]  length 0.735759
n = 2^10: error 8.8e-04, n * error = 0.90
n = 2^16: error 1.4e-05, n * error = 0.90
n = 2^24: error 5.4e-08, n * error = 0.90

Eigenvalue Spectrum and Planar Phase Portraits

Stability Classification

Writing each eigenvalue as \lambda_j = a_j + \mathrm{i}\,b_j, the mode magnitude scales as |e^{\lambda_j t}| = e^{a_j t} while rotating at angular speed b_j:

  • Asymptotic Stability (\max_j a_j < 0): Every mode decays to \mathbf{0} at a rate set by the slowest eigenvalue -\max_j \operatorname{Re}\lambda_j.
  • Instability (\max_j a_j > 0): Any initial state with a component along an expanding eigenvector \mathbf{v}_j escapes exponentially.
  • Gradient Flows vs. Games: Continuous gradient descent \dot{\mathbf{x}} = -\mathbf{H}\mathbf{x} has a symmetric Hessian \mathbf{H} with purely real eigenvalues (producing only nodes and saddles, top row); min-max games like GANs have complex eigenvalues that circle in centers or spirals (bottom row).

Driven Linear Systems and Variation of Constants

State Space Models

In a continuous-time State Space Model (SSM), an external input sequence \mathbf{u}(t) drives the hidden state through an input matrix \mathbf{B}:

\dot{\mathbf{x}}(t) = \mathbf{A}\mathbf{x}(t) + \mathbf{B}\mathbf{u}(t), \qquad \mathbf{x}(0) = \mathbf{x}_0

  • Integrating Factor (e^{-\mathbf{A}t}): Pulling the state back to t = 0 along the free motion cancels the \mathbf{A}\mathbf{x} term via the product rule: \frac{d}{dt}\left(e^{-\mathbf{A}t}\mathbf{x}(t)\right) = e^{-\mathbf{A}t}\big(\dot{\mathbf{x}}(t) - \mathbf{A}\mathbf{x}(t)\big) = e^{-\mathbf{A}t}\mathbf{B}\mathbf{u}(t)
  • Variation of Constants Formula: Integrating from 0 to t and multiplying by e^{\mathbf{A}t} expresses the state as the decayed start plus a convolution over all past inputs: \mathbf{x}(t) = e^{\mathbf{A}t}\mathbf{x}_0 + \int_0^t e^{\mathbf{A}(t-s)}\,\mathbf{B}\mathbf{u}(s)\,ds

Zero-Order Hold: Exact Discretization for SSMs

Exact Recurrence

Holding the input constant over each step (\mathbf{u}(s) = \mathbf{u}_n on [t_n, t_n + h)) yields the exact ZOH recurrence for State Space Models (S4, Mamba):

\mathbf{x}_{n+1} = \bar{\mathbf{A}}\,\mathbf{x}_n + \bar{\mathbf{B}}\,\mathbf{u}_n, \quad \bar{\mathbf{A}} = e^{\mathbf{A}h}, \quad \bar{\mathbf{B}} = \mathbf{A}^{-1}\big(e^{\mathbf{A}h} - \mathbf{I}\big)\mathbf{B}

  • Unconditional stability: Whenever \operatorname{Re}\lambda < 0, |\bar{a}| = e^{h\operatorname{Re}\lambda} < 1 for every step size h > 0 (at \lambda = -50, h = 0.05, \bar{a} = e^{-2.5} \approx 0.082, whereas Euler’s 1 + h\lambda = -1.5 explodes).

Measuring Zero-Order Hold Across Fast and Slow Modes

Numerical Experiment

Integrating \dot{x} = \lambda x + \sin t to T = 2 with the input held constant on each step incurs only an O(h) hold error on the moving sine wave, never an instability—even at h|\lambda| = 25:

  lam     h  e^(h lam)  1 + h lam  error at T
   -1  0.50      0.607       0.50     6.8e-02
   -1  0.10      0.905       0.90     9.7e-03
   -1  0.02       0.98       0.98     1.8e-03
  -50  0.50   1.39e-11     -24.00     1.6e-03
  -50  0.10    0.00674      -4.00     5.8e-04
  -50  0.02      0.368       0.00     9.2e-05

At \lambda = -50 and h = 0.5, the step is 25\times longer than the relaxation time 1/|\lambda|, yet the ZOH recurrence remains rock-solid (e^{h\lambda} = 1.4 \times 10^{-11}, error 1.6 \times 10^{-3}) while 1 + h\lambda = -24 blows up.

Non-Normal Matrices and Transient Growth Before Decay

Transient Dynamics

When \mathbf{A}\mathbf{A}^\top \neq \mathbf{A}^\top\mathbf{A}, nearly parallel eigenvectors can cause substantial transient growth before asymptotic decay:

\dot{\mathbf{x}} = \begin{pmatrix}-1 & 10 \\ 0 & -2\end{pmatrix}\mathbf{x}, \quad \mathbf{x}_0 = \begin{pmatrix}0 \\ 1\end{pmatrix} \;\Longrightarrow\; x_1(t) = 10\left(e^{-t} - e^{-2t}\right)

  • 2.5\times norm spike: Although \lambda_1 = -1, \lambda_2 = -2 < 0, the eigenvectors sit 5.7^\circ apart, so \|\mathbf{x}(t)\| climbs to 2.51 at t = \log 2 before decaying (explaining early momentum spikes).

Local Linearization at Hyperbolic Fixed Points

Nonlinear Systems

Near a fixed point \mathbf{f}(\mathbf{x}^\star) = \mathbf{0}, a smooth nonlinear ODE behaves like its Jacobian linearization \dot{\boldsymbol{\delta}} = \mathbf{J}(\mathbf{x}^\star)\boldsymbol{\delta}:

  • Hartman–Grobman Theorem: If \mathbf{x}^\star is hyperbolic (\operatorname{Re}\lambda_j \neq 0 for all j), the local nonlinear flow is topologically conjugate to \dot{\boldsymbol{\delta}} = \mathbf{J}\boldsymbol{\delta}.
  • Damped pendulum (\ddot{\phi} + 0.5\dot{\phi} + \sin\phi = 0): Hanging bottom (0, 0) has \lambda = -0.25 \pm 0.97\mathrm{i} (stable spiral); upright top (\pi, 0) has \lambda = +0.78, -1.28 (unstable saddle).

Concept Check: Uniqueness, Spectra, and Discretization

Concept Check

Test your understanding of vector fields, matrix exponentials, and local stability:

  1. Global Existence & Uniqueness: Which of the scalar fields \dot{x} = \tanh(x), \dot{x} = x^3, and \dot{x} = |x|^{1/3} guarantees a unique trajectory on [0, T] from every starting point x_0 \in \mathbb{R}?
  2. Gradient Flow Portraits: Can continuous-time gradient descent \dot{\mathbf{x}} = -\nabla\mathcal{L}(\mathbf{x}) on a twice-differentiable loss \mathcal{L} ever spiral around a critical point \mathbf{x}^\star?
  3. SSM Step Stability: For \dot{x} = -100x + u(t) discretized at step h = 0.1, compare the exact ZOH state multiplier \bar{a} with the naive linear multiplier 1 + h\lambda.

Answers:

  1. Only \dot{x} = \tanh(x) (globally Lipschitz with L = \max \operatorname{sech}^2(x) = 1). The field x^3 blows up in finite time for x_0 \ne 0, and |x|^{1/3} violates Lipschitz uniqueness at x_0 = 0.
  2. No: At any critical point, the Jacobian of -\nabla\mathcal{L} is minus the symmetric Hessian -\mathbf{H}(\mathbf{x}^\star), whose eigenvalues are purely real (\mathrm{i}b_j = 0). Gradient flows form nodes and saddles, never spirals or centers.
  3. Exact ZOH gives \bar{a} = e^{-10} \approx 4.5 \times 10^{-5} (stable contraction), whereas 1 + h\lambda = 1 - 10 = -9 explodes by 9\times per step.

Summary: Ordinary Differential Equations and Flows

Key Takeaways

Concept Mathematical Form Deep Learning & Systems Role
Picard–Lindelöf Theorem \|\mathbf{f}(\mathbf{x},t) - \mathbf{f}(\mathbf{y},t)\| \le L\|\mathbf{x} - \mathbf{y}\| Guarantees unique, non-crossing trajectories on [0, T]
Bijective Flow Map \Phi_T(\mathbf{x}_0) = \mathbf{x}(T), \Phi_T^{-1} = \Phi_{-T} Makes Neural ODEs and continuous normalizing flows invertible
Matrix Exponential e^{\mathbf{A}t} = \mathbf{V}\mathrm{diag}(e^{\lambda_1 t}, \ldots, e^{\lambda_d t})\mathbf{V}^{-1} Decouples linear dynamics into d independent eigenmodes
Eigenvalue Stability \lambda_j = a_j + \mathrm{i}b_j \implies |e^{\lambda_j t}| = e^{a_j t} Real part a_j < 0 sets decay rate; imaginary part b_j sets rotation
Zero-Order Hold (ZOH) \mathbf{x}_{n+1} = e^{\mathbf{A}h}\mathbf{x}_n + \mathbf{A}^{-1}(e^{\mathbf{A}h}-\mathbf{I})\mathbf{B}\mathbf{u}_n Exact, unconditionally stable recurrence for State Space Models
Jacobian Linearization \dot{\boldsymbol{\delta}} = \mathbf{J}(\mathbf{x}^\star)\boldsymbol{\delta} + o(\|\boldsymbol{\delta}\|) Classifies fixed points (minima vs. saddles in gradient flows)