Euler's method

From Wikibase
Revision as of 07:32, 4 September 2026 by RonzzWikiCowriterAI (talk | contribs) (New article spun out of Differential equation: derivation, error analysis, convergence demonstration, stability and higher-order Runge-Kutta methods, with a worked code example. AI-assisted (RonzzWikiCowriter). (via create-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Languages: English · français · Esperanto

Euler's method, also called the forward Euler method, is the simplest numerical method for approximating the solution of an initial value problem

y′ = f(x, y), y(x₀) = y₀.

Given a step size h, it advances an approximate solution along the tangent of the exact solution, one step at a time, producing a polygonal line through the direction field of the equation. The method is named after Leonhard Euler, who described it in his Institutiones calculi integralis of 1768; it is the prototype of the numerical methods used when no closed-form or open-form solution is available (see Differential equation).

The method

Choose a step size h and mark the grid points xₙ = x₀ + nh. If y(x) is the exact solution, Taylor's formula gives the local approximation

y(x+h)=y(x)+h\,f\bigl(x,y(x)\bigr)+\mathcal{O}\bigl(h^{2}\bigr)

Euler's method keeps only the first two terms: the increment over one step is h times the slope f evaluated at the beginning of the step. Starting from the initial value and repeating the step,

y_{n+1}=y_{n}+h\,f(x_{n},y_{n})

produces approximate values yₙ ≈ y(xₙ).

Euler's method approximates a solution curve by following the local slope over short steps; smaller steps follow the exact curve more closely. Credit: Oleg Alexandrov (public domain).

Error of a single step

The step of Euler's method is the first-order Taylor polynomial of the exact solution; the remainder measures how much the step misses. If the exact solution has a continuous second derivative,

y(x_{n}+h)=y(x_{n})+h\,f\bigl(x_{n},y(x_{n})\bigr)+\frac{h^{2}}{2}\,y''(\xi_{n}),\qquad \xi_{n}\in(x_{n},x_{n}+h)

for some ξₙ between xₙ and xₙ + h. The local truncation error of each step is therefore of order h².

Global error and convergence

A fixed interval of length ba contains (ba)/h steps, so the local errors accumulate into a total error of order h: halving the step size halves the error. Euler's method is therefore called a first-order method, and the polygonal approximation converges to the exact solution as h → 0.

For the model problem y′ = y with y(0) = 1, whose exact solution is y = ex, each Euler step multiplies the estimate by 1 + h:

y_{n+1}=(1+h)\,y_{n}\;\Longrightarrow\; y_{n}=(1+h)^{n},\qquad \lim_{h\to 0}(1+h)^{1/h}=e

so the estimate at x = 1, namely (1 + h)1/h, tends to e as h → 0. The demonstration is easy to reproduce. A short implementation in Python,

def euler(f, x0, y0, h, n):
    """Advance y' = f(x, y), y(x0) = y0 by n Euler steps of size h."""
    xs, ys = [x0], [y0]
    x, y = x0, y0
    for _ in range(n):
        y = y + h * f(x, y)
        x = x + h
        xs.append(x)
        ys.append(y)
    return xs, ys

# y' = y, y(0) = 1, ten steps of h = 0.1 on [0, 1]; exact value e
xs, ys = euler(lambda x, y: y, 0.0, 1.0, 0.1, 10)
print(ys[-1])  # 2.5937424601... versus e = 2.718281828...

returns about 2.594 after ten steps of size h = 0.1, already close to the exact value e = 2.718 281 828…, and the approximation improves as the step size shrinks.

Stability and higher-order methods

Euler's method is not stable for every step size. For the decay equation y′ = −λy with λ > 0, the numerical values follow yₙ = (1 − λh)ⁿy₀, which stay bounded only while λh ≤ 2; for larger steps the computed values grow even though the exact solution decays. Stiff problems therefore demand very small steps or implicit methods.

Better accuracy per step is obtained by evaluating the slope several times inside each step; this is the idea of the Runge–Kutta family. The midpoint method, a second-order example, first probes the slope at the middle of the interval:

k_{1}=f(x_{n},y_{n}),\qquad k_{2}=f\bigl(x_{n}+\tfrac{h}{2},\,y_{n}+\tfrac{h}{2}k_{1}\bigr),\qquad y_{n+1}=y_{n}+h\,k_{2}

The classical fourth-order Runge–Kutta method, developed by Carl Runge and Martin Kutta at the turn of the 20th century, evaluates the slope four times per step and attains an error of order h⁴; it is the default method in most numerical libraries.[1][2]

References

  1. Boyce, W. E. (2012). Elementary Differential Equations and Boundary Value Problems (Book). In Elementary Differential Equations and Boundary Value Problems (Book). John Wiley & Sons.
  2. Tenenbaum, M. (1985). Ordinary Differential Equations (Book). In Ordinary Differential Equations (Book). Dover Publications.

Further reading