Module contents
Lesson 16 of 20Core 110 min

ODEs: existence, uniqueness and solution methods

Ordinary differential equations as evolution laws. Prove Picard–Lindelöf using Banach's fixed point, examine uniqueness failures and finite-time blow-up, use Grönwall for continuous dependence on data, and review analytic solution methods: separable, first-order linear, and constant-coefficient second-order linear equations through the damped oscillator.

After this lesson you can

  • Formulate initial value problems and reduce any order-n ODE to a first-order system.
  • Prove Picard–Lindelöf and explain the roles of Lipschitz continuity and the local interval.
  • Use Grönwall's inequality to bound separation between solutions.
  • Solve separable, first-order linear and constant-coefficient second-order linear ODEs.
  • Analyze the damped oscillator and classify its regimes by characteristic-polynomial roots.

Before you start

Motivation: an evolution law determines a future (sometimes)

An ordinary differential equation (ODE) says how a state changes as a function of itself: it gives the local rule generating a trajectory, not the trajectory. This way of describing the world appears throughout what you will build.

  • Mechanics and robotics. Newton’s second law, mq¨=F(q,q˙,t)m\ddot{\vb{q}} = \vb{F}(\vb{q}, \dot{\vb{q}}, t), is a second-order ODE. Simulating a robot arm or vehicle means integrating it, and all control relies on future motion being determined by current position and velocity.
  • Continuous-depth networks. A residual block hk+1=hk+η gθ(hk)\vb{h}_{k+1} = \vb{h}_k + \eta\,g_\theta(\vb{h}_k) (residual block) is an Euler step of h˙=gθ(h)\dot{\vb{h}} = g_\theta(\vb{h}). Neural ODEs take the limit and define the model as an ODE flow.
  • Optimization. Gradient flow w˙=−∇L(w)\dot{\vb{w}} = -\grad\Loss(\vb{w}) is the small-step limit of gradient descent, and momentum is a damped oscillator (heavy-ball momentum), as seen at the end.
  • Populations, epidemics, circuits, chemical reactions. Almost every mechanistic scientific model is an ODE, and the important question is what it predicts long term.

Before solving one there are three foundational, not merely technical, questions. Existence: given the rule and an initial state, is there really a trajectory? Uniqueness: is there one, or does the law leave the future open? Duration: does the trajectory live forever or cease to exist? All three answers depend on the rule, and this lesson answers precisely: first Picard–Lindelöf, using lesson 5’s Banach fixed point and answering all three in the good case; then bad cases, less exotic than they seem; then Grönwall’s inequality, measuring how neighboring trajectories separate; and finally methods that actually solve ODEs by hand (separable, first-order linear, second-order linear), the vocabulary for reading any more complicated system.

The initial value problem

Let Ω⊂R×Rn\Omega \subset \R \times \R^n be open and f:Ω→Rnf: \Omega \to \R^n continuous.

We write x˙\dot{\vb{x}} for  ⁣dx/ ⁣dt\dd\vb{x}/\dd t and sometimes x′x' when n=1n = 1. Two reformulations will be used constantly.

Integral form. A continuous function x:I→Rn\vb{x}: I \to \R^n with graph in Ω\Omega solves the IVP if and only if

x(t)=x0+∫t0tf(s,x(s))  ⁣dspara todo t∈I.\vb{x}(t) = \vb{x}_0 + \int_{t_0}^{t} f(s, \vb{x}(s))\,\dd s \quad \text{para todo } t \in I.

One way, because x\vb{x} is differentiable and x˙=f(t,x(t))\dot{\vb{x}} = f(t, \vb{x}(t)) continuous, so it can be integrated. The other, because integrand s↦f(s,x(s))s \mapsto f(s, \vb{x}(s)) is continuous and the fundamental theorem of calculus says the integral is differentiable with derivative f(t,x(t))f(t, \vb{x}(t)), and equals x0\vb{x}_0 at t0t_0. Integral form is convenient: it works with continuous functions, requires no differentiation and turns the ODE into fixed-point equation x=T(x)\vb{x} = \mathcal{T}(\vb{x}).

Reduction to first order. An order-nn ODE, x(n)=g(t,x,x˙,…,x(n−1))x^{(n)} = g(t, x, \dot{x}, \dots, x^{(n-1)}), is equivalent to a first-order system for vector y=(x,x˙,…,x(n−1))\vb{y} = (x, \dot{x}, \dots, x^{(n-1)}):

y˙1=y2,  …,  y˙n−1=yn,  y˙n=g(t,y1,…,yn).\dot{y}_1 = y_2,\ \ \dots,\ \ \dot{y}_{n-1} = y_n,\ \ \dot{y}_n = g(t, y_1, \dots, y_n).

And a nonautonomous ODE in Rn\R^n becomes autonomous in Rn+1\R^{n+1} by adding variable yn+1=ty_{n+1} = t with y˙n+1=1\dot{y}_{n+1} = 1. Thus studying x˙=f(t,x)\dot{\vb{x}} = f(t, \vb{x}) with x∈Rn\vb{x} \in \R^n suffices. The most-used example is the damped oscillator, x¨+cx˙+kx=0\ddot{x} + c\dot{x} + kx = 0, which with y=(x,x˙)\vb{y} = (x, \dot{x}) becomes

y˙=[01−k−c]y.\dot{\vb{y}} = \begin{bmatrix} 0 & 1 \\ -k & -c \end{bmatrix}\vb{y}.

The matrix is the companion matrix of polynomial λ2+cλ+k\lambda^2 + c\lambda + k, with trace −c-c and determinant kk. We will meet it again.

Intuition: the slope field

For n=1n = 1, ODE x˙=f(t,x)\dot{x} = f(t, x) has an immediate geometric reading. At each point (t,x)(t, x) of the plane, f(t,x)f(t, x) is a slope: draw a small segment with that tilt to obtain the slope field. A solution is a curve x(t)x(t) tangent at each point to its segment. Solving the IVP is letting the field carry you from (t0,x0)(t_0, x_0) like a leaf in a current.

InteractiveSlope field: three questions, one picture
  • slope f(t,x)f(t, x)
  • launched solutions (RK4)
  • the latest
  • exact solutions without waiting
  • the one waiting at 0 from c₁ to c₂
Solutions waiting at equilibrium
−1.00
1.20
x′=∣x∣x' = \sqrt{|x|}
Solutions launched3
Last point (t0,x0)(t_0, x_0)(−2.50, −1.00)
Last solution: exists throughout the window.
Magenta solutionc1=−1.00, c2=0.20c_1 = -1.00,\ c_2 = 0.20
Passes through the origin?yes (c₁ ≤ 0 ≤ c₂)
f(x)=∣x∣f(x) = \sqrt{\lvert x\rvert} is continuous but not Lipschitz at 00: f(x)/x=1/xf(x)/x = 1/\sqrt{x} is unbounded. A family of solutions passes through (c,0)(c,0); the numerical integrator sees only one.
Choose an equation and click in the plane to launch solutions (integrated by fourth-order Runge–Kutta forward and backward). With x′=∣x∣x' = \sqrt{|x|} dashed curves are exact solutions crossing axis x=0x = 0 without stopping; the magenta one stops at 00 between c1c_1 and c2c_2: move c1c_1 and the waiting time to see a two-parameter family passes through the origin (all with c1≤0≤c2c_1 \le 0 \le c_2), and launch a solution at x=0x = 0 to see the integrator finds only one. With x′=x2x' = x^2 launch solutions with x0>0x_0 > 0 and compare blow-up time to 1/x01/x_0. With logistic, verify lines x=0x = 0 and x=1x = 1 never cross, and x0<0x_0 < 0 blows up. With the forced equation, observe all solutions eventually meet the same curve. Enter your own f(t,x)f(t, x) to explore.

Four observations from the figure, proved in the rest of the lesson.

  1. Through each point of the logistic, x2x^2 and forced equations passes one curve. Solutions neither cross nor touch: at each point the field specifies one direction and neighboring curves neither split nor merge. This is uniqueness.
  2. With x′=∣x∣x' = \sqrt{|x|} that fails on axis x=0x = 0. Curve x≡0x \equiv 0 is a solution, as is x=t2/4x = t^2/4 for t≥0t \ge 0 leaving the origin at t=0t = 0, and those leaving at any other instant. The law does not determine the future from the origin.
  3. With x′=x2x' = x^2 curves escape upward in finite time. No solution is defined for all tt: existence is generally local.
  4. With the forced equation all solutions converge together. This is not general: it happens when the field contracts in xx, quantified by Grönwall.

The Picard–Lindelöf theorem

The key to uniqueness is how ff varies when only xx moves, and differentiability is unnecessary.

This is lesson 1’s Lipschitz continuity with time as a parameter. If ∂f/∂x\partial f/\partial\vb{x} exists and is continuous, ff is locally Lipschitz in x\vb{x} by the mean value theorem and compactness of closed balls. But that much is unnecessary: ∣x∣\abs{x} is Lipschitz with L=1L = 1 without being differentiable at 00. What excludes ∣x∣\sqrt{\abs{x}} is its slope f(x)/x=1/xf(x)/x = 1/\sqrt{x} being unbounded near 00.

Let R={(t,x):∣t−t0∣≤a, ∥x−x0∥≤b}⊂ΩR = \{(t, \vb{x}) : \abs{t - t_0} \le a,\ \norm{\vb{x} - \vb{x}_0} \le b\} \subset \Omega be a closed rectangle around the initial datum. Since ff is continuous on a compact set it is bounded, M=max⁡R∥f∥M = \max_R \norm{f}, and call LL a Lipschitz constant in x\vb{x} on RR. The central result is known as the Picard–Lindelöf theorem (or Cauchy–Lipschitz).

Proof

Let X={φ∈C(Ih;Rn):∥φ−x0∥∞≤b}X = \{\vb{\varphi} \in C(I_h; \R^n) : \norm{\vb{\varphi} - \vb{x}_0}_\infty \le b\} have the supremum distance. It is a closed subset of space C(Ih;Rn)C(I_h; \R^n), which is complete (supremum-norm completeness), so XX is a complete metric space. Define the Picard operator

(Tφ)(t)=x0+∫t0tf(s,φ(s))  ⁣ds.(\mathcal{T}\vb{\varphi})(t) = \vb{x}_0 + \int_{t_0}^{t} f(s, \vb{\varphi}(s))\,\dd s.

T\mathcal{T} maps XX into XX. If φ∈X\vb{\varphi} \in X, point (s,φ(s))(s, \vb{\varphi}(s)) lies in RR, so s↦f(s,φ(s))s \mapsto f(s, \vb{\varphi}(s)) is continuous and Tφ\mathcal{T}\vb{\varphi} is continuous (even C1C^1). Also ∥Tφ(t)−x0∥≤M∣t−t0∣≤Mh≤b\norm{\mathcal{T}\vb{\varphi}(t) - \vb{x}_0} \le M\abs{t - t_0} \le Mh \le b.

T\mathcal{T} is a contraction. For φ,ψ∈X\vb{\varphi}, \vb{\psi} \in X and t∈Iht \in I_h,

∥Tφ(t)−Tψ(t)∥≤∣∫t0t∥f(s,φ(s))−f(s,ψ(s))∥  ⁣ds∣≤L h ∥φ−ψ∥∞.\norm{\mathcal{T}\vb{\varphi}(t) - \mathcal{T}\vb{\psi}(t)} \le \Big\lvert\int_{t_0}^{t} \norm{f(s, \vb{\varphi}(s)) - f(s, \vb{\psi}(s))}\,\dd s\Big\rvert \le L\,h\,\norm{\vb{\varphi} - \vb{\psi}}_\infty.

Taking the supremum over tt, d(Tφ,Tψ)≤q d(φ,ψ)d(\mathcal{T}\vb{\varphi}, \mathcal{T}\vb{\psi}) \le q\,d(\vb{\varphi}, \vb{\psi}) with q=hL<1q = hL < 1.

Conclusion. By Banach’s theorem, T\mathcal{T} has a unique fixed point in XX, and iterates φk=Tkφ0\vb{\varphi}_k = \mathcal{T}^k\vb{\varphi}_0 converge to it with a priori bound d(φk,x)≤qk1−qd(φ1,φ0)d(\vb{\varphi}_k, \vb{x}) \le \frac{q^k}{1 - q}d(\vb{\varphi}_1, \vb{\varphi}_0). By integral form, fixed points of T\mathcal{T} are exactly IVP solutions with graph in RR.

∎

Read carefully: the proof is one idea, turn the ODE into a fixed-point equation and check Banach’s two assumptions. hM≤bhM \le b makes T\mathcal{T} keep functions inside the rectangle where ff is controlled (self-map), and hL<1hL < 1 makes it a contraction. Both conditions appear in the next figure: the first limits size, the second sensitivity.

InteractivePicard iterations
blow-up t* = 1.00
  • error on [0,h][0, h]
  • error on [0,0.9 t∗][0, 0.9\,t^*]
  • Banach bound qk∥φ1−φ0∥/(1−q)q^k\|\varphi_1 - \varphi_0\|/(1 - q)
  • current iterate φk\varphi_k
  • previous iterates
  • exact solution
  • guaranteed interval [0,h][0, h]
Problem
1.00
0.20
k = 10
x′=x2, x(0)=1x' = x^2,\ x(0) = 1
Error of φk\varphi_k on [0,h][0, h]1.7e−12
q=hLq = hL0.80
MM, LL in the rectangle4.00, 4.00
Maximum guaranteed hh0.250
Optimum over bb0.25 with b = 1.00
Actual interval of existence[0, 1.000)
The assumptions hold (hM≤bhM \le b and hL<1hL < 1): T\mathcal{T} is a contraction and error decreases at least as fast as qkq^k.
Iterates φk\varphi_k (current magenta, earlier blue) versus the exact solution (dashed). With x′=λxx' = \lambda x and x(0)=1x(0) = 1 iterates are exactly Taylor polynomials of eλte^{\lambda t}, and the theorem only guarantees h<1/∣λ∣h < 1/|\lambda|. With x′=x2x' = x^2 and x′=1+x2x' = 1 + x^2 (whose solution is tan⁡t\tan t), the rectangle of half-width bb fixes MM and LL and the guaranteed interval is min⁡(b/M,1/L)\min(b/M, 1/L): optimize it over bb. The graph compares measured error on [0,h][0, h] and on an interval nearly reaching blow-up with the Banach bound, drawn only while assumptions hold. Extend hh past the guarantee and observe what breaks: the proof, not convergence.

What appears is instructive. The interval guaranteed by the proof is pessimistic: for x′=x2x' = x^2 with x(0)=1x(0) = 1, the optimum over bb is h→1/4h \to 1/4 (with b=1b = 1, M=4M = 4 and L=4L = 4 and both ratios b/Mb/M and 1/L1/L are 1/41/4), while solution 1/(1−t)1/(1 - t) exists until t=1t = 1. And within the guarantee, convergence is much faster than the geometric bound. The explanation is that supremum-norm contraction discards information: the integral from t0t_0 to tt sees only what happens on [t0,t][t_0, t].

Proof

Iterates remain in the ball by the same self-map argument. For k=0k = 0: ∥φ1(t)−x0∥≤M∣t−t0∣\norm{\vb{\varphi}_1(t) - \vb{x}_0} \le M\abs{t - t_0}. If the bound holds for k−1k - 1, integral form and the Lipschitz condition give

∥φk+1(t)−φk(t)∥≤L∣∫t0tMLk−1∣s−t0∣kk!  ⁣ds∣=MLk∣t−t0∣k+1(k+1)!.\norm{\vb{\varphi}_{k+1}(t) - \vb{\varphi}_k(t)} \le L\Big\lvert\int_{t_0}^{t}\frac{M L^{k-1}\abs{s - t_0}^{k}}{k!}\,\dd s\Big\rvert = \frac{M L^{k}\abs{t - t_0}^{k+1}}{(k+1)!}.

Series ∑kMLkhk+1/(k+1)!=(M/L)(eLh−1)\sum_k M L^k h^{k+1}/(k+1)! = (M/L)(e^{Lh} - 1) converges for any hh, so partial sums φk=x0+∑j<k(φj+1−φj)\vb{\varphi}_k = \vb{x}_0 + \sum_{j<k}(\vb{\varphi}_{j+1} - \vb{\varphi}_j) converge uniformly (uniform convergence) to a continuous function φ\vb{\varphi}. Passing to the limit in integral form (uniform convergence and continuity of ff permit this), φ=Tφ\vb{\varphi} = \mathcal{T}\vb{\varphi}.

∎

Thus condition hL<1hL < 1 is an artifact of choosing the supremum norm. Error of φk\vb{\varphi}_k is of order (Lh)k/k!(Lh)^k/k!, which for x′=λxx' = \lambda x is exactly the Taylor remainder of eλte^{\lambda t} (iterates are its degree-kk polynomials, as the figure shows). An equivalent view: with weighted norm ∥φ∥L=max⁡te−2L∣t−t0∣∥φ(t)∥\norm{\vb{\varphi}}_L = \max_t e^{-2L\abs{t - t_0}}\norm{\vb{\varphi}(t)} the Picard operator is a contraction with constant 1/21/2 on all IhI_h, regardless of LL.

Maximal solutions and the blow-up alternative

The theorem is local, but solutions can be glued. Two solutions agreeing at one time agree on their common interval (proved with Grönwall), so the union of all IVP solutions is a solution on a maximal open interval (t−,t+)(t_-, t_+). What follows is the continuation theorem, stated without proof (see Teschl, chapter 2):

A solution ceases to exist only by going to infinity (or the boundary of Ω\Omega): it cannot simply “end.” This turns duration into a question of bounds, answered by Grönwall.

When the assumption fails

Without Lipschitz there are infinitely many solutions

Let x˙=∣x∣\dot{x} = \sqrt{\abs{x}} with x(0)=0x(0) = 0. Constant function x≡0x \equiv 0 is a solution. But for any c≥0c \ge 0, so is

xc(t)={0t≤c(t−c)2/4t≥c,x_c(t) = \begin{cases} 0 & t \le c \\ (t - c)^2/4 & t \ge c \end{cases},

because on segment t>ct > c it is x˙c=(t−c)/2=xc\dot{x}_c = (t - c)/2 = \sqrt{x_c}, and at t=ct = c one-sided derivatives are 00 on both sides, so xcx_c is C1C^1. Since x˙=∣x∣≥0\dot{x} = \sqrt{\abs{x}} \ge 0, solutions are nondecreasing, and those passing through the origin have the form −(c1−t)2/4-(c_1 - t)^2/4 for t≤c1t \le c_1, 00 on [c1,c2][c_1, c_2] and (t−c2)2/4(t - c_2)^2/4 for t≥c2t \ge c_2, with c1≤0≤c2c_1 \le 0 \le c_2 (and c1=−∞c_1 = -\infty or c2=+∞c_2 = +\infty also work): a two-parameter family through one point, drawn by the first interactive’s sliders. The solution can wait at equilibrium as long as it wants and depart whenever it likes.

Why does the proof fail? Because f(x)=∣x∣f(x) = \sqrt{\abs{x}} is continuous but ∣f(x)−f(0)∣/∣x∣=1/∣x∣\abs{f(x) - f(0)}/\abs{x} = 1/\sqrt{\abs{x}} is unbounded near 00: there is no LL. The Picard operator is no longer a contraction on any interval around t=0t = 0. In the next fragment you will see the numerical integrator sees only one solution (the one starting with x(0)=0x(0) = 0 is zero, and with x(0)=10−12x(0) = 10^{-12} it changes to x(6)≈9x(6) \approx 9): the computer does not know there are more.

Without Lipschitz existence remains: Peano

Existence does survive removing the Lipschitz condition.

The proof uses compactness rather than contractions. Euler polygonal approximations with step δ\delta lie in the rectangle, are equicontinuous (with Lipschitz constant MM) and bounded, so by Arzelà–Ascoli a subsequence converges uniformly as δ→0\delta \to 0. The limit satisfies integral form. What is lost is uniqueness (the limit may depend on the subsequence, as with ∣x∣\sqrt{\abs{x}}) and with it a guarantee that the whole sequence converges: neither polygonal approximations nor Picard iterates, which with a merely continuous field may oscillate without converging.

Without a global bound, the solution dies: x′=x2x' = x^2

The third phenomenon is finite-time blow-up. With x(0)=x0>0x(0) = x_0 > 0, separating variables (justified below), −1/x=t−1/x0-1/x = t - 1/x_0, that is,

x(t)=x01−x0t,t+=1x0.x(t) = \frac{x_0}{1 - x_0 t}, \qquad t_+ = \frac{1}{x_0}.

A larger initial condition blows up sooner: x0=2x_0 = 2 lives until t=1/2t = 1/2. Here f(x)=x2f(x) = x^2 is smooth and locally Lipschitz, so there is a unique solution through each point, but it grows so fast that ∫x0∞ ⁣dx/x2=1/x0\int_{x_0}^{\infty}\dd x/x^2 = 1/x_0 is finite, exactly the time taken to reach infinity. Growing faster than linearly does not suffice by itself (x′=xln⁡xx' = x\ln x grows faster than a line and its solutions are global because ∫∞ ⁣dx/(xln⁡x)\int^{\infty}\dd x/(x\ln x) diverges), but growth like xpx^p with p>1p > 1 does. The general pattern seen with Grönwall: a field growing at most linearly gives global solutions, while one growing faster may not.

The opening slope field shows three situations to remember: globally Lipschitz (existence for all R\R), locally Lipschitz (existence and uniqueness, but local), and not Lipschitz (existence without uniqueness). Here is a summary for x(0)=0x(0) = 0 in the four fields of an exercise below:

f(x)f(x)Lipschitz near 00?Solutions through (0,0)(0, 0)
∣x∣\sqrt{\abs{x}}no (f(x)/x→∞f(x)/x \to \infty)infinitely many
∣x∣\abs{x}yes, L=1L = 1one: x≡0x \equiv 0
x1/3x^{1/3}no (f(x)/x→∞f(x)/x \to \infty)infinitely many (x≡0x \equiv 0 and ±(2(t−c)/3)3/2\pm(2(t - c)/3)^{3/2})
sin⁡x\sin xyes, L=1L = 1 (∣cos⁡x∣≤1\abs{\cos x} \le 1)one: x≡0x \equiv 0

Grönwall’s inequality

How far apart can two solutions with very close initial data get? This sensitivity question governs weather forecasting and gradient computation for a Neural ODE. The answer is an integral inequality with a one-line proof and enormous consequences.

The tool is Grönwall’s inequality in integral form.

Proof

Let U(t)=∫t0tu(s)  ⁣dsU(t) = \int_{t_0}^{t} u(s)\,\dd s: it is class C1C^1, U(t0)=0U(t_0) = 0 and U′=u≤α+LUU' = u \le \alpha + LU. Multiply by integrating factor e−L(t−t0)e^{-L(t - t_0)}:

 ⁣d ⁣dt(e−L(t−t0)U(t))=e−L(t−t0)(U′(t)−LU(t))≤α e−L(t−t0).\frac{\dd}{\dd t}\Big(e^{-L(t - t_0)}U(t)\Big) = e^{-L(t - t_0)}\big(U'(t) - LU(t)\big) \le \alpha\,e^{-L(t - t_0)}.

Integrate from t0t_0 to tt (with U(t0)=0U(t_0) = 0) and assume L>0L > 0: e−L(t−t0)U(t)≤αL(1−e−L(t−t0))e^{-L(t - t_0)}U(t) \le \frac{\alpha}{L}\big(1 - e^{-L(t - t_0)}\big), that is, LU(t)≤α(eL(t−t0)−1)LU(t) \le \alpha(e^{L(t - t_0)} - 1). Substitute in the assumption to get u(t)≤α+LU(t)≤αeL(t−t0)u(t) \le \alpha + LU(t) \le \alpha e^{L(t - t_0)}. Case L=0L = 0 is trivial.

∎

The most-used conclusion is this.

Proof

Let u=∥x−y∥u = \norm{\vb{x} - \vb{y}} and Δ0=u(t0)\Delta_0 = u(t_0). By integral form of both equations and the triangle inequality, u(t)≤Δ0+∫t0t(∥f(s,x)−f(s,y)∥+∥f(s,y)−g(s,y)∥) ⁣ds≤Δ0+∫t0t(Lu+ε)  ⁣dsu(t) \le \Delta_0 + \int_{t_0}^{t}\big(\norm{f(s, \vb{x}) - f(s, \vb{y})} + \norm{f(s, \vb{y}) - g(s, \vb{y})}\big)\dd s \le \Delta_0 + \int_{t_0}^{t}(Lu + \eps)\,\dd s. With v=u+ε/Lv = u + \eps/L, this is v(t)≤(Δ0+ε/L)+L∫t0tv  ⁣dsv(t) \le (\Delta_0 + \eps/L) + L\int_{t_0}^{t} v\,\dd s, and Grönwall gives v≤(Δ0+ε/L)eL(t−t0)v \le (\Delta_0 + \eps/L)e^{L(t - t_0)}. Subtract ε/L\eps/L.

∎

Three consequences:

  • Uniqueness. If Δ0=0\Delta_0 = 0 and ε=0\eps = 0, then x=y\vb{x} = \vb{y}. Two solutions of an ODE with ff locally Lipschitz in x\vb{x} agreeing at one time agree throughout any common interval (the union of both graphs over a compact interval is compact, and a continuous function locally Lipschitz in x\vb{x} is Lipschitz on any compact set: use the local constant for nearby points and 2max⁡∥f∥/δ2\max\norm{f}/\delta for points at least δ\delta apart). This completes Picard–Lindelöf: the solution is unique among all solutions, not just those remaining in the rectangle. In particular, one-dimensional solution curves cannot cross, and equilibrium is a barrier.
  • Continuous dependence. With ε=0\eps = 0, ∥x(t)−y(t)∥≤Δ0eL(t−t0)\norm{\vb{x}(t) - \vb{y}(t)} \le \Delta_0 e^{L(t - t_0)}: on each bounded interval the solution depends continuously on initial data. With Δ0=0\Delta_0 = 0 it also depends continuously on the field: if f(t,x;μ)f(t, \vb{x}; \mu) is KμK_\mu-Lipschitz in parameter μ\mu, perturbing μ\mu by δμ\delta\mu gives ε=Kμ∣δμ∣\eps = K_\mu\abs{\delta\mu}. The IVP is well posed in Hadamard’s sense (existence, uniqueness and continuous dependence).
  • Global existence with linear growth. If ∥f(t,x)∥≤A+B∥x∥\norm{f(t, \vb{x})} \le A + B\norm{\vb{x}} on [t0,T]×Rn[t_0, T] \times \R^n, with B>0B > 0, any solution satisfies ∥x(t)∥≤∥x0∥+∫(A+B∥x∥)\norm{\vb{x}(t)} \le \norm{\vb{x}_0} + \int(A + B\norm{\vb{x}}), and with v=∥x∥+A/Bv = \norm{\vb{x}} + A/B Grönwall gives ∥x(t)∥≤(∥x0∥+A/B)eB(t−t0)\norm{\vb{x}(t)} \le (\norm{\vb{x}_0} + A/B)e^{B(t - t_0)}. A solution bounded on bounded intervals cannot blow up, and the blow-up alternative says it exists on all [t0,T][t_0, T]. This includes every globally Lipschitz field (because ∥f(t,x)∥≤∥f(t,0)∥+L∥x∥\norm{f(t, \vb{x})} \le \norm{f(t, \vb{0})} + L\norm{\vb{x}}) and the linear equations below. Case x′=x2x' = x^2 is excluded because x2x^2 is not bounded by a line.

The exponential bound is the best one can say without knowing more of the field, but is not always sharp. The next figure tests it.

InteractiveThe Grönwall envelope

Solutions from x0=0.15x_0 = 0.15 and x0+Δ0x_0 + \Delta_0, with Δ0=10−1.7\Delta_0 = 10^{-1.7}.

  • separation ∣x2−x1∣\lvert x_2 - x_1\rvert
  • envelope Δ0eLt\Delta_0 e^{Lt}
  • refined bound
  • x1(t)x_1(t)
  • x2(t)x_2(t)
0.15
−1.7
8.0
x′=x(1−x)x' = x(1 - x)
L=max⁡∣f′∣L = \max\lvert f'\rvert in the region1.00
Separation at TT2.62e−4
Envelope Δ0eLT\Delta_0 e^{LT}5.79e1
Envelope / separation2.2e5
Max separation / envelope (always ≤1\le 1)1.000 at t = 0.00
Near x=1x = 1 the field contracts (f′=−1f' = -1), but LL is the maximum of ∣f′∣\lvert f'\rvert over the entire visited region: the envelope grows while actual separation collapses.
Two solutions of x′=f(x)x' = f(x) with initial data x0x_0 and x0+Δ0x_0 + \Delta_0. Left, both trajectories; right, on a logarithmic scale, their actual separation (magenta) and Grönwall envelope Δ0eLt\Delta_0 e^{Lt} (dashed), with LL the maximum of ∣f′∣|f'| in the region they visit. For x′=xx' = x they agree. For logistic, near stable equilibrium x=1x = 1, separation plummets while the envelope still grows. Enable the refined bound, integrating at each instant the signed maximum of f′f' between the two solutions instead of the maximum of ∣f′∣|f'|, and verify it also bounds separation while tracking it. The ‘max separation / envelope’ readout never exceeds 11.

The pessimism comes from Grönwall using the maximum of ∣f′∣\abs{f'} and its absolute value: it does not distinguish an expanding field (f′>0f' > 0) from a contracting one (f′<0f' < 0). In dimension 11 this is easily fixed: difference Δ=x2−x1\Delta = x_2 - x_1 does not change sign (uniqueness) and, by the mean value theorem, Δ˙=f(x2)−f(x1)=f′(ξ(t)) Δ\dot{\Delta} = f(x_2) - f(x_1) = f'(\xi(t))\,\Delta with ξ(t)\xi(t) between the solutions, so ∣Δ(t)∣=Δ0exp⁡∫t0tf′(ξ(s))  ⁣ds≤Δ0exp⁡∫t0tm(s)  ⁣ds\abs{\Delta(t)} = \Delta_0\exp\int_{t_0}^{t} f'(\xi(s))\,\dd s \le \Delta_0\exp\int_{t_0}^{t} m(s)\,\dd s, where m(s)m(s) is the signed maximum of f′f' on the segment between x1(s)x_1(s) and x2(s)x_2(s). This is the figure’s refined bound, negative in the exponent when the field contracts. For small separations, m(s)≈f′(x1(s))m(s) \approx f'(x_1(s)) and the bound becomes nearly exact, Δ0exp⁡∫t0tf′(x1(s))  ⁣ds\Delta_0\exp\int_{t_0}^{t} f'(x_1(s))\,\dd s: this is the variational equation in the sensitivity lesson, where solution derivatives with respect to initial data solve their own linear ODE. For nn-dimensional systems, the refined version replaces LL by the Jacobian’s logarithmic norm along the solution, which can be negative (when the segment between solutions lies in the domain).

The opposite of logistic is what matters in practice. If the field truly expands, error grows like eLte^{Lt} and no trick avoids it: forecasts of a chaotic system degrade exponentially, with characteristic time 1/L1/L, and numerical integrator errors are amplified by the same exponential (Euler and Runge–Kutta methods are the simulation lesson’s topic).

Analytic solution methods

With existence and uniqueness established, how are solutions found? Most ODEs have no formula, and those that do are few and almost always in three families. They matter little as calculation tools and greatly as vocabulary: near equilibrium any system reads like one of these models (stability by linearization).

Separable equations

Proof

(1) The constant is a solution, and unique by uniqueness. (2) If xx is a solution with x(t0)=x0x(t_0) = x_0, it cannot touch a zero of hh: at that point x(t1)=ξx(t_1) = \xi with h(ξ)=0h(\xi) = 0 the constant ξ\xi would be another solution through the same point, forbidden by uniqueness. Thus x(t)∈Jx(t) \in J while it exists and  ⁣d ⁣dtH(x(t))=x˙(t)/h(x(t))=g(t)\frac{\dd}{\dd t}H(x(t)) = \dot{x}(t)/h(x(t)) = g(t). Integration gives H(x(t))=G(t)H(x(t)) = G(t). Conversely, x=H−1∘Gx = H^{-1}\circ G is differentiable and x˙=g(t)/H′(x)=g(t)h(x)\dot{x} = g(t)/H'(x) = g(t)h(x).

∎

Equilibria are zeros of hh and are lost by dividing by h(x)h(x). Thus handle them separately: the proof explains why no other solutions touch an equilibrium (uniqueness makes it a barrier), but the mechanical “move  ⁣dx/h(x)\dd x/h(x) to one side” method does not produce them. They are often recovered at the end: passing from ln⁡∣x∣=G(t)+C\ln\abs{x} = G(t) + C to x=KeG(t)x = Ke^{G(t)}, constant KK, initially unable to be 00, may be set to 00 and returns equilibrium x≡0x \equiv 0.

First-order linear equations

Proof

If xx is a solution,  ⁣d ⁣dt(e−A(t)x(t))=e−A(x˙−ax)=e−A(t)b(t)\frac{\dd}{\dd t}\big(e^{-A(t)}x(t)\big) = e^{-A}(\dot{x} - a x) = e^{-A(t)}b(t), and integration from t0t_0 (where A=0A = 0) gives the formula, thus the only possibility. Conversely the formula defines a C1C^1 function that, differentiated, satisfies the equation and initial datum.

∎

Factor e−A(t)e^{-A(t)} is the integrating factor, and writing the solution as the homogeneous solution with constant x0x_0 replaced by a function is variation of constants: multiply the equation to turn the left side into an exact derivative. The formula has an interpretation worth remembering. First term eA(t)x0e^{A(t)}x_0 is the homogeneous solution: initial state evolving without forcing. The second sums contributions of force b(s)b(s) at each time ss, each evolved from ss to tt by factor eA(t)−A(s)e^{A(t) - A(s)}. This is superposition; next lesson generalizes it as Duhamel’s formula for systems. All solutions form an affine space: a particular solution plus any homogeneous solution. And there is no blow-up because the field grows linearly: a,ba, b continuous on II suffice for existence on all II.

With constant a=−1/τa = -1/\tau, the formula is x(t)=e−t/τx0+∫0te−(t−s)/τb(s)  ⁣dsx(t) = e^{-t/\tau}x_0 + \int_0^t e^{-(t - s)/\tau}b(s)\,\dd s: output is a moving average of input with an exponential kernel of memory τ\tau. Its Euler discretization with step Δt\Delta t is xn+1=(1−α)xn+α τbnx_{n+1} = (1 - \alpha)x_n + \alpha\,\tau b_n with α=Δt/τ\alpha = \Delta t/\tau, the exponential moving average of time series (simple exponential smoothing) and of optimizers with momentum and second-moment statistics.

Second-order linear equations with constant coefficients

This is the most important second-order ODE case. With unit mass, x¨+cx˙+kx=0\ddot{x} + c\dot{x} + kx = 0, with c≥0c \ge 0 (damping) and k>0k > 0 (stiffness).

The equation follows by seeking solutions eλte^{\lambda t}: since  ⁣d ⁣dteλt=λeλt\frac{\dd}{\dd t}e^{\lambda t} = \lambda e^{\lambda t}, substitution gives p(λ)eλt=0p(\lambda)e^{\lambda t} = 0. Every root of pp gives a solution. It remains to show there are no others and handle missing real roots.

Proof

Dimension 2. With y=(x,x˙)\vb{y} = (x, \dot{x}) the equation is linear system y˙=Cy\dot{\vb{y}} = \mat{C}\vb{y} with constant C\mat{C}, having a unique global solution for any initial data (Picard–Lindelöf and linear growth). Thus x↦(x(0),x˙(0))x \mapsto (x(0), \dot{x}(0)) is a linear map from solutions to R2\R^2 that is injective (uniqueness) and surjective (existence): a linear bijection, so dimension is 22. It suffices to exhibit two solutions with independent initial conditions, checked by determinant W(0)=x1(0)x˙2(0)−x˙1(0)x2(0)W(0) = x_1(0)\dot{x}_2(0) - \dot{x}_1(0)x_2(0) (the Wronskian).

Distinct real roots. xi=eλitx_i = e^{\lambda_i t} are solutions and W(0)=λ2−λ1≠0W(0) = \lambda_2 - \lambda_1 \ne 0.

Double root. x1=eλtx_1 = e^{\lambda t} is a solution. For x2=teλtx_2 = te^{\lambda t}: x˙2=(1+λt)eλt\dot{x}_2 = (1 + \lambda t)e^{\lambda t}, x¨2=(2λ+λ2t)eλt\ddot{x}_2 = (2\lambda + \lambda^2 t)e^{\lambda t}, and x¨2+cx˙2+kx2=(λ2+cλ+k) teλt+(2λ+c)eλt=0\ddot{x}_2 + c\dot{x}_2 + kx_2 = (\lambda^2 + c\lambda + k)\,te^{\lambda t} + (2\lambda + c)e^{\lambda t} = 0, because p(λ)=0p(\lambda) = 0 and λ=−c/2\lambda = -c/2. W(0)=1W(0) = 1.

Complex roots. The equation is real and z(t)=e(−c/2+iωd)tz(t) = e^{(-c/2 + i\omega_d)t} solves its complex version (same calculation, with complex λ\lambda), so its real and imaginary parts, e−ct/2cos⁡ωdte^{-ct/2}\cos\omega_d t and e−ct/2sin⁡ωdte^{-ct/2}\sin\omega_d t, solve the real equation. By Euler’s formula z=e−ct/2(cos⁡ωdt+isin⁡ωdt)z = e^{-ct/2}(\cos\omega_d t + i\sin\omega_d t). W(0)=det⁡[10−c/2ωd]=ωd≠0W(0) = \det\begin{bmatrix} 1 & 0 \\ -c/2 & \omega_d \end{bmatrix} = \omega_d \ne 0.

∎

The classification is that of 2×22\times 2 matrices in linear algebra lesson 10, in another guise: earlier matrix C\mat{C} has characteristic polynomial pp, trace τ=−c\tau = -c and determinant δ=k\delta = k, so plane (c,k)(c, k) is the trace–determinant plane of trace, determinant and eigenvalues, and parabola k=c2/4k = c^2/4 separating regimes is the same boundary seen there between complex eigenvalues and real ones. Roots of pp are eigenvalues of C\mat{C}; what changes between regimes is only their distribution in the complex plane.

InteractiveThe damped oscillator
m = 1

Phase plane (x,x′)(x, x'): a spiral toward the origin for complex roots, approach without rotations for real roots.

c = 2√kstable half-plane

Roots of λ2+cλ+k\lambda^2 + c\lambda + k. The dashed curve traces them as cc varies with fixed kk; the circle marks the critical point.

  • x(t)x(t) (RK4)
  • current time
  • envelope ±Ae−ct/2\pm A e^{-ct/2}
  • damper
0.80
4.0
1.00
0.0
External force
t = 20.0
Regimeunderdamped
Discriminant c2−4kc^2 - 4k−15.36
λ=−0.40±1.96 i\lambda = -0.40 \pm 1.96\,i
Damping ratio ζ=c/(2k)\zeta = c/(2\sqrt{k})0.20
Decay rate −max⁡Re⁡λ-\max\operatorname{Re}\lambda0.400
Frequency ωd\omega_d1.960
Complex conjugate roots: oscillation has frequency ωd=k−c2/4\omega_d = \sqrt{k - c^2/4} and the envelope decays as e−ct/2e^{-ct/2}.
A mass attached to a spring (stiffness kk) and damper (coefficient cc): x′′+c x′+k x=0x'' + c\,x' + k\,x = 0 (mass 1), integrated by Runge–Kutta. Above, the mass; center, x(t)x(t) with envelope ±Ae−ct/2\pm A e^{-ct/2}; lower left, phase plane (x,x′)(x, x'); lower right, characteristic polynomial roots in the complex plane, with their path as cc varies (dashed curve). Raise cc: complex roots descend to the real axis, merge at c=2kc = 2\sqrt{k} (‘Critical’ button) and separate along the real axis. Notice the decay rate. Switch to ‘forced’ and vary ω\omega to see resonance.

The interactive’s three readouts are the same information. Roots tell all: real part is decay rate, imaginary part frequency. Phase plane shows the same motion as a trajectory: a spiral toward the origin with complex roots and direct entry (no turns) with real roots. Time graph is the projection of that trajectory onto axis xx.

Two numbers summarize behavior. Natural frequency ω0=k\omega_0 = \sqrt{k} is that of the undamped oscillator, and damping ratio ζ=c/(2k)=c/(2ω0)\zeta = c/(2\sqrt{k}) = c/(2\omega_0) gives the regime: ζ<1\zeta < 1 underdamped, ζ=1\zeta = 1 critical, ζ>1\zeta > 1 overdamped. In the underdamped regime ωd=ω01−ζ2\omega_d = \omega_0\sqrt{1 - \zeta^2} is slightly less than ω0\omega_0 and the envelope decays like e−ζω0te^{-\zeta\omega_0 t}.

Proof

For c<2kc < 2\sqrt{k} roots are complex with real part −c/2-c/2, so σ=c/2\sigma = c/2, increasing. For c≥2kc \ge 2\sqrt{k} the slow root is λ1=−c/2+c2/4−k=−k/(c/2+c2/4−k)\lambda_1 = -c/2 + \sqrt{c^2/4 - k} = -k/(c/2 + \sqrt{c^2/4 - k}) (multiply and divide by the conjugate), and the denominator increases with cc, so σ=∣λ1∣\sigma = \abs{\lambda_1} decreases. At c=2kc = 2\sqrt{k} both branches equal k\sqrt{k}.

∎

This is counterintuitive and fundamental: more damping does not mean faster decay. Going from c=2kc = 2\sqrt{k} to c=4kc = 4\sqrt{k} gives slow root λ1=−(2−3)k≈−0.27k\lambda_1 = -(2 - \sqrt{3})\sqrt{k} \approx -0.27\sqrt{k}, nearly four times slower than critical: the overdamped system “crawls” because friction prevents spring force from returning it to rest.

Forcing and resonance

With sinusoidal external force, x¨+cx˙+kx=Fcos⁡ωt\ddot{x} + c\dot{x} + kx = F\cos\omega t, the general solution is a particular solution plus the homogeneous one, which decays if c>0c > 0. Long term what remains is an oscillation at the force’s frequency, with amplitude obtained by a complex-number calculation.

Proof

By linearity and since Re⁡\operatorname{Re} commutes with differentiation in tt, solve the complex version with right side FeiωtFe^{i\omega t} and take the real part. For z=Ceiωtz = Ce^{i\omega t}, z¨+cz˙+kz=p(iω)Ceiωt\ddot{z} + c\dot{z} + kz = p(i\omega)Ce^{i\omega t}, which is FeiωtFe^{i\omega t} if C=F/p(iω)C = F/p(i\omega) (p(iω)=(k−ω2)+icω≠0p(i\omega) = (k - \omega^2) + ic\omega \ne 0: if ω≠0\omega \ne 0 its imaginary part cωc\omega does not vanish, and if ω=0\omega = 0 it equals k>0k > 0). The difference between any solution and xpx_p solves the homogeneous equation, which decays because both roots have negative real part when c>0c > 0. Amplitude is ∣C∣\abs{C}. For the maximum, AA is maximal when radicand D(s)=(k−s)2+c2sD(s) = (k - s)^2 + c^2 s, with s=ω2s = \omega^2, is minimal: D′(s)=−2(k−s)+c2=0D'(s) = -2(k - s) + c^2 = 0 gives s=k−c2/2s = k - c^2/2, admissible if c2<2kc^2 < 2k, and then D=c2k−c4/4D = c^2 k - c^4/4.

∎

Remember two facts from this formula. First, the peak grows like 1/c1/c as c→0c \to 0. Second, without damping (c=0c = 0) and with ω=k\omega = \sqrt{k} polynomial p(iω)p(i\omega) vanishes and the calculation fails: the solution is x(t)=F2ω tsin⁡ωtx(t) = \frac{F}{2\omega}\,t\sin\omega t, growing linearly (check by differentiating: x¨+ω2x=Fcos⁡ωt\ddot{x} + \omega^2 x = F\cos\omega t). This is pure resonance, why bridges and wings are designed so natural frequencies are far from the forces they receive. In the preceding interactive’s ‘forced’ mode, with c=0.5c = 0.5 and k=4k = 4, the peak is at ωr≈1.97\omega_r \approx 1.97 with amplitude ≈1.008\approx 1.008.

Back to momentum

The damped oscillator is the continuous model of momentum. Heavy ball wk+1=wk−η∇L(wk)+β(wk−wk−1)\vb{w}_{k+1} = \vb{w}_k - \eta\grad\Loss(\vb{w}_k) + \beta(\vb{w}_k - \vb{w}_{k-1}) is, with h=ηh = \sqrt{\eta} and β=1−γh\beta = 1 - \gamma h, a discretization of w¨+γw˙+∇L(w)=0\ddot{\vb{w}} + \gamma\dot{\vb{w}} + \grad\Loss(\vb{w}) = \vb{0}: replace w¨\ddot{\vb{w}} by central difference (wk+1−2wk+wk−1)/h2(\vb{w}_{k+1} - 2\vb{w}_k + \vb{w}_{k-1})/h^2 and w˙\dot{\vb{w}} by backward difference (wk−wk−1)/h(\vb{w}_k - \vb{w}_{k-1})/h, multiply by h2h^2 and solve for wk+1\vb{w}_{k+1}. If L\Loss is a quadratic 12∑iμiyi2\tfrac{1}{2}\sum_i\mu_i y_i^2, in its Hessian eigenvector basis each coordinate obeys y¨i+γy˙i+μiyi=0\ddot{y}_i + \gamma\dot{y}_i + \mu_i y_i = 0: an oscillator with k=μik = \mu_i.

Apply the preceding theorem. Pure gradient flow, y˙i=−μiyi\dot{y}_i = -\mu_i y_i, has slowest direction decay rate μmin⁡\mu_{\min}. With momentum and γ=2μmin⁡\gamma = 2\sqrt{\mu_{\min}} the slowest direction is critical and decays at rate μmin⁡\sqrt{\mu_{\min}}, and the others (with μi>μmin⁡\mu_i > \mu_{\min}) are underdamped at rate γ/2=μmin⁡\gamma/2 = \sqrt{\mu_{\min}}: all decay at the same speed, with characteristic time 1/μmin⁡1/\sqrt{\mu_{\min}} instead of 1/μmin⁡1/\mu_{\min}. For a meaningful comparison fix the time scale using the stiffest direction (the discrete method’s stable step is order 1/μmax⁡1/\sqrt{\mu_{\max}} in hh): with μmax⁡=1\mu_{\max} = 1 and condition number κ=μmax⁡/μmin⁡\kappa = \mu_{\max}/\mu_{\min}, time goes from κ\kappa to κ\sqrt{\kappa}. This is the acceleration studied in momentum as an ODE (and why critical damping is called optimal). This is continuous analysis; the discrete stability limit is another calculation.

Implementation from scratch

Begin with symbolic Picard iteration: exact iterates for x′=xx' = x and x′=t+x2x' = t + x^2 with x(0)=0x(0) = 0, compared with the solution’s Taylor expansion.

[ ]Picard iterates with sympyBrowser
import sympy as sp

t, s = sp.symbols("t s")

def picard_sym(f, x0, n):
    """Iterados de Picard x_{k+1}(t) = x0 + integral de 0 a t de f(s, x_k(s)) ds, exactos."""
    iterados = [sp.sympify(x0)]
    for _ in range(n):
        xk = iterados[-1]
        iterados.append(sp.expand(x0 + sp.integrate(f(s, xk.subs(t, s)), (s, 0, t))))
    return iterados

print("x' = x, x(0) = 1")
for k, p in enumerate(picard_sym(lambda s, x: x, 1, 4)):
    print(f"  k={k}: {p}")

print("\nx' = t + x^2, x(0) = 0")
its = picard_sym(lambda s, x: s + x**2, 0, 4)
for k, p in enumerate(its):
    print(f"  k={k}: {p}")

# serie de Taylor de la solución, por recurrencia: (m+1) c_{m+1} = [m = 1] + sum c_i c_{m-i}
c = [sp.Integer(0)]
for m in range(30):
    c.append((sp.Integer(1 if m == 1 else 0) + sum(c[i] * c[m - i] for i in range(m + 1))) / (m + 1))
print("\nTaylor de la solución:", " + ".join(f"({c[m]}) t^{m}" for m in range(14) if c[m] != 0), "+ ...")
for k, p in enumerate(its):
    coef = [sp.Poly(p, t).coeff_monomial(t**m) if p != 0 else 0 for m in range(31)]
    m = 0
    while m < 31 and coef[m] == c[m]:
        m += 1
    print(f"  el iterado {k} coincide con Taylor hasta el grado {m - 1}")

Iterates of x′=xx' = x are Taylor polynomials of ete^t, one per iteration, as the figure showed. In the second problem something similar happens with more luck: iterate kk agrees with the solution’s Taylor expansion through degree 3k+13k + 1, three orders per iteration. Generally, at minimum, iterate kk gets the first kk orders right: every integration increases by one the order at which φk\vb{\varphi}_k and x\vb{x} can differ (the local version of the factorial bound). Degrees grow rapidly (2k−12^k - 1 at x′=x2x' = x^2), so only a few steps are done by hand or with sympy.

Now the numerical version, with cumulative trapezoid integration written from scratch, for any scalar field. It stops when supremum distance between consecutive iterates falls below tolerance.

[ ]Numerical Picard iteration on a gridBrowser
import numpy as np
from scipy.integrate import solve_ivp

def cumtrapz(y, t):
    """Integral acumulada por trapecios: out[i] = integral de t[0] a t[i]."""
    out = np.zeros_like(y)
    out[1:] = np.cumsum(0.5 * (y[1:] + y[:-1]) * np.diff(t))
    return out

def picard_grid(f, x0, t_grid, tol=1e-10, max_iter=300):
    """Itera x_{k+1} = x0 + integral de f(s, x_k(s)) ds hasta que la distancia sup entre iterados baje de tol."""
    x = np.full_like(t_grid, float(x0))
    with np.errstate(all="ignore"):
        for k in range(1, max_iter + 1):
            x_nuevo = x0 + cumtrapz(f(t_grid, x), t_grid)
            if not np.all(np.isfinite(x_nuevo)):
                return x_nuevo, k
            if np.max(np.abs(x_nuevo - x)) < tol:
                return x_nuevo, k
            x = x_nuevo
    return x, max_iter

def referencia(f, x0, T, t_grid):
    sol = solve_ivp(lambda t, y: f(t, y), (0, T), [x0], t_eval=t_grid, rtol=1e-12, atol=1e-14)
    return sol.y[0]

t_grid = np.linspace(0, 2, 2001)
x, k = picard_grid(lambda t, x: x, 1.0, t_grid)
print(f"x' = x en [0, 2]: {k} iteraciones, error frente a exp(t) = {np.max(np.abs(x - np.exp(t_grid))):.1e}")

x, k = picard_grid(lambda t, x: t + x**2, 0.0, np.linspace(0, 1.2, 2401))
ref = referencia(lambda t, y: t + y**2, 0.0, 1.2, np.linspace(0, 1.2, 2401))
print(f"x' = t + x^2 en [0, 1.2]: {k} iteraciones, distancia a solve_ivp = {np.max(np.abs(x - ref)):.1e}")

print("\nx' = x^2, x(0) = 1 (explota en t = 1): iteraciones para tol = 1e-8")
for T in [0.25, 0.5, 0.9, 1.2]:
    x, k = picard_grid(lambda t, x: x**2, 1.0, np.linspace(0, T, 1001), tol=1e-8, max_iter=400)
    estado = "converge" if np.all(np.isfinite(x)) and k < 400 else "no converge"
    print(f"  [0, {T}]: {k:3d} iteraciones, {estado}")

Three readouts. For x′=xx' = x on [0,2][0, 2] about 18 iterations suffice, and final error (order 10−610^{-6}) comes from the trapezoid rule with step 10−310^{-3}, not iteration: iteration converges to the discretized operator’s fixed point, which differs from the solution by quadrature error. With x′=t+x2x' = t + x^2, lacking an elementary formula, distance to solve_ivp confirms iteration reaches the same place. And with x′=x2x' = x^2 the theorem’s limit appears: iteration count rises as the interval approaches blow-up at t=1t = 1, and past that time iteration does not converge: values explode.

With libraries: sympy.dsolve and solve_ivp

For ODEs with formulas, sympy.dsolve solves and verifies. For others, scipy.integrate.solve_ivp is the black box (internally a family of adaptive-step Runge–Kutta methods, covered in the numerical methods module’s Runge–Kutta methods lesson): here use it only to check what we proved.

[ ]Analytic solutions with sympy.dsolveBrowser
import sympy as sp

t = sp.symbols("t")
x = sp.Function("x")

# la explosión de x' = x^2 con x(0) = 2, y el ejemplo del factor integrante
s1 = sp.dsolve(sp.Eq(x(t).diff(t), x(t) ** 2), x(t), ics={x(0): 2})
s2 = sp.dsolve(sp.Eq(x(t).diff(t) + 2 * x(t), sp.exp(-t)), x(t), ics={x(0): 0})
print(s1)
print(s2, "  en t = 1:", float(s2.rhs.subs(t, 1)))

# el oscilador subamortiguado, con x(0) = 1 y x'(0) = 0
c, k = sp.Rational(2, 5), 4
s3 = sp.dsolve(sp.Eq(x(t).diff(t, 2) + c * x(t).diff(t) + k * x(t), 0), x(t), ics={x(0): 1, x(t).diff(t).subs(t, 0): 0})
print(s3)
print("raíces del polinomio característico:", sp.solve(sp.Symbol("l") ** 2 + c * sp.Symbol("l") + k, sp.Symbol("l")))
[ ]solve_ivp: events and lack of uniquenessBrowser
import numpy as np
from scipy.integrate import solve_ivp

# 1) la explosión, detectada con un evento terminal
def explota(t, y):
    return abs(y[0]) - 1e6
explota.terminal = True

sol = solve_ivp(lambda t, y: y**2, (0, 2), [2.0], events=explota, rtol=1e-10, atol=1e-12)
print(f"x' = x^2, x(0) = 2: el evento salta en t = {sol.t_events[0][0]:.6f}  (teoría: 0.5 - 1e-6 = {0.5 - 1e-6:.6f})")

# 2) solve_ivp no ve la falta de unicidad de x' = sqrt|x|
f = lambda t, y: np.sqrt(np.abs(y))
for x0 in [0.0, 1e-12, 1e-8, 1e-4]:
    s = solve_ivp(f, (0, 6), [x0], rtol=1e-10, atol=1e-14)
    print(f"x(0) = {x0:.0e}  ->  x(6) = {s.y[0, -1]:.6f}   (exacta (t/2 + sqrt(x0))^2 = {(3 + np.sqrt(x0))**2:.6f})")

# 3) x'' + 0.4 x' + 4 x = 0 como sistema de primer orden, frente a la fórmula cerrada
c, k = 0.4, 4.0
sol = solve_ivp(lambda t, y: [y[1], -c * y[1] - k * y[0]], (0, 10), [1.0, 0.0], rtol=1e-10, atol=1e-12, dense_output=True)
wd = np.sqrt(k - c**2 / 4)
tt = np.linspace(0, 10, 11)
exacta = np.exp(-c * tt / 2) * (np.cos(wd * tt) + (c / (2 * wd)) * np.sin(wd * tt))
print("error máximo frente a la fórmula cerrada:", np.max(np.abs(sol.sol(tt)[0] - exacta)))

The event turns blow-up into data: the integrator stops when ∣x∣\abs{x} crosses the threshold and stopping time is blow-up time minus an order-1/umbral1/\text{umbral} term (here 10−610^{-6}). The second block is numerical uniqueness: for x(0)=0x(0) = 0 the integrator returns the zero solution, and with x(0)=10−12x(0) = 10^{-12}, a trillionth change to the datum, it returns the departing solution x(6)≈9x(6) \approx 9. In an ODE with uniqueness, Grönwall’s continuous dependence says Δ0=10−12\Delta_0 = 10^{-12} changes the solution by 10−12eLt10^{-12}e^{Lt}; here the change is order 11 and no bound exists. Learn to recognize this warning: an ODE whose solution changes greatly when the datum barely changes likely has a non-Lipschitz field (or an unstable system, another case).

Common mistakes

Exercises

NumericBlow-up time
The solution of x′=x2x' = x^2 with x(0)=2x(0) = 2 blows up at finite time t∗t^*. Calculate t∗t^*.
NumericA forced linear equation
Solve x′=−2x+e−tx' = -2x + e^{-t} with x(0)=0x(0) = 0 and give x(1)x(1).
QuizIs there a unique solution through the origin?
With x(0)=0x(0) = 0, for which of these ODEs does the IVP have a unique solution?

More than one answer may be correct.

ProofThe Picard operator is a contraction
Prove: Let ff be continuous on R=[t0−a,t0+a]×[x0−b,x0+b]R = [t_0 - a, t_0 + a]\times[x_0 - b, x_0 + b], with ∣f∣≤M\abs{f} \le M and Lipschitz in xx with constant LL. If h≤ah \le a, hM≤bhM \le b and hL<1hL < 1, operator (Tφ)(t)=x0+∫t0tf(s,φ(s))  ⁣ds(\mathcal{T}\varphi)(t) = x_0 + \int_{t_0}^{t} f(s, \varphi(s))\,\dd s has a unique fixed point in X={φ∈C[t0−h,t0+h]:∥φ−x0∥∞≤b}X = \{\varphi \in C[t_0 - h, t_0 + h] : \norm{\varphi - x_0}_\infty \le b\}, and fixed points are IVP solutions with graph in RR.
0
Use the supremum distance on XX (here n=1n = 1 for simplicity).

Step 1 of 4. Before applying Banach two things about XX and T\mathcal{T} must be checked. Which?

ProofGrönwall's inequality
Prove: Let u:[t0,T]→[0,∞)u: [t_0, T] \to [0, \infty) be continuous with u(t)≤α+L∫t0tu(s)  ⁣dsu(t) \le \alpha + L\int_{t_0}^{t} u(s)\,\dd s, where α≥0\alpha \ge 0 and L>0L > 0. Then u(t)≤αeL(t−t0)u(t) \le \alpha e^{L(t - t_0)}.
0
Nothing is known of uu except the integral inequality: in particular, differentiability is not assumed.

Step 1 of 4. Since uu is not differentiable, what auxiliary function do you introduce?

NumericThe interval guaranteed by the theorem
For x′=x2x' = x^2 with x(0)=1x(0) = 1, consider rectangle [−a,a]×[1−b,1+b][-a, a]\times[1 - b, 1 + b] and theorem conditions hM≤bhM \le b and hL<1hL < 1. Optimizing over b>0b > 0, what is the supremum of hh guaranteed by the theorem?
NumericHow long logistic growth takes
The solution of x′=x(1−x)x' = x(1 - x) with x(0)=0.1x(0) = 0.1 reaches value 1/21/2 at time t1/2t_{1/2}. Calculate t1/2t_{1/2}.
NumericSteady-state amplitude
A mass has x′′+0.5 x′+4x=cos⁡(1.8 t)x'' + 0.5\,x' + 4x = \cos(1.8\,t). After the transient decays, oscillation has amplitude AA. Calculate AA.
QuizWhich decays fastest?
All oscillators have k=4k = 4. Which has the greatest decay rate −max⁡Re⁡λ-\max\operatorname{Re}\lambda?
QuizCan two solutions cross?
Let x′=f(t,x)x' = f(t, x) with ff continuous and locally Lipschitz in xx throughout the plane. Which statements are true?

More than one answer may be correct.

CodePicard for systems
Implement picard_numeric(f, x0, t_grid, tol=1e-10, max_iter=500) for a system x˙=f(t,x)\dot{\vb{x}} = f(t, \vb{x}). x0 is a vector of shape (n,); f(t, X) receives t_grid (shape (N,)) and X of shape (n, N) and returns an array (n, N). Return (X, k): the last iterate (shape (n, N)) and number of iterations performed. Iterate Xk+1=x0+∫t0tf(s,Xk(s))  ⁣dsX_{k+1} = x_0 + \int_{t_0}^{t} f(s, X_k(s))\,\dd s using the cumulative trapezoid rule (along axis 1) and stop when max|X_nuevo - X| < tol. If it does not converge in max_iter iterations, return the last with k = max_iter (without raising exceptions even if inf or nan appears). Start from X0≡x0X_0 \equiv x_0.
import numpy as np

def picard_numeric(f, x0, t_grid, tol=1e-10, max_iter=500):
  """Iteración de Picard en una rejilla para un sistema x' = f(t, x). Devuelve (X, k)."""
  t_grid = np.asarray(t_grid, dtype=float)
  x0 = np.asarray(x0, dtype=float)
  X = np.tile(x0[:, None], (1, len(t_grid)))
  # tu código: integral acumulada por trapecios a lo largo del eje 1, y el bucle con parada por tolerancia
  return X, 0
Shift+Enter to run

Summary

Key idea
An ODE x˙=f(t,x)\dot{\vb{x}} = f(t, \vb{x}) with ff locally Lipschitz in x\vb{x} determines the trajectory from initial data: it exists, is unique and depends continuously on the data, proved by converting the ODE to a fixed-point equation and applying Banach. Duration is not guaranteed (it can blow up), and Grönwall’s bound eLte^{Lt} says how far neighboring solutions can separate.
  • Integral form and first order. x=x0+∫f\vb{x} = \vb{x}_0 + \int f is equivalent to the ODE with initial datum, and any order-nn ODE is a first-order system in Rn\R^n.
  • Picard–Lindelöf. If ff is continuous and Lipschitz in x\vb{x}, the Picard operator is a contraction on C[t0−h,t0+h]C[t_0 - h, t_0 + h] for small hh: a unique local solution with convergent iterates (in fact factorially fast). The theorem is pessimistic about interval size.
  • Failures. Without Lipschitz there is existence (Peano) but not uniqueness (∣x∣\sqrt{\abs{x}}). Without a growth bound there is finite-time blow-up (x2x^2). A maximal solution only ends by going to infinity (or the domain boundary).
  • Grönwall. From u≤α+L∫uu \le \alpha + L\int u follows u≤αeL(t−t0)u \le \alpha e^{L(t - t_0)}, giving uniqueness, continuous dependence on data and parameters, and global existence for linear-growth fields. Exact for x′=xx' = x and pessimistic when the field contracts.
  • Methods. Separable: equilibria are lost when dividing by h(x)h(x). First-order linear: integrating factor and variation of constants, always global. Second-order linear: characteristic polynomial, three regimes and critical damping as fastest.
  • Oscillator and momentum. The forced oscillator has amplitude F/(k−ω2)2+c2ω2F/\sqrt{(k - \omega^2)^2 + c^2\omega^2} and resonance at ωr=k−c2/2\omega_r = \sqrt{k - c^2/2}. Momentum discretizes it, and critical damping explains acceleration.