Euler Method ODE Calculator (Explicit, Implicit, Heun)

Euler methods calculator for ODE y' = f(t,y): explicit Euler, implicit, Heun and midpoint. Order 1-2 convergence, logistic and Newton cooling examples.

Calculation parameters
Was this calculator useful?

Euler methods for ordinary differential equations

Euler methods are the simplest class of algorithms to numerically solve ordinary differential equations (ODE) of form y' = f(t,y), y(t_0) = y_0. Developed by Leonhard Euler in 1768 (Institutiones Calculi Integralis), they are the starting point of ODE numerical analysis.

Explicit Euler (Forward Euler)

Formula: y_{n+1} = y_n + h f(t_n, y_n) where h = (T - t_0)/N is integration step. Global convergence order 1: error = O(h). Fast and cheap but inaccurate. Unstable for stiff problems or oscillating ODEs.

Implicit Euler (Backward Euler)

Formula: y_{n+1} = y_n + h f(t_{n+1}, y_{n+1}). Requires solving implicit equation each step (fixed-point or Newton iteration). Double cost per iter, but A-stable: no limit on h for stability. Ideal for stiff ODEs.

Heun's method (Improved Euler)

Predictor-corrector: explicit Euler predictor y* = y_n + h f(t_n, y_n), trapezoidal corrector y_{n+1} = y_n + h/2 (f(t_n, y_n) + f(t_{n+1}, y*)). Order 2: error = O(h^2). Cost: 2 evaluations per step. Optimal accuracy/cost compromise.

Midpoint (Modified Euler)

Formula: k1 = f(t_n, y_n), y_{n+1} = y_n + h f(t_n + h/2, y_n + h/2 k1). Order 2 like Heun. Stable for oscillating ODEs. Variant of two-stage Runge-Kutta.

Global convergence and order

Local truncation error for explicit Euler is -h^2/2 y''(xi) for some xi. Summing N = (T-t0)/h steps, global error = O(h). For Heun and midpoint, global error = O(h^2). Classical RK4 reaches O(h^4). Tradeoff: higher order = more f evaluations per step, but larger h possible.

Stability

For y' = lambda y (test problem), explicit Euler stable only if |1 + h lambda| < 1, i.e. h < 2/|lambda| for negative real lambda. Implicit Euler A-stable: |1/(1 - h lambda)| < 1 for Re(lambda) < 0 always. For stiff ODEs (large eigenvalue ratio), implicit is essential.

Stiff problems

Stiff ODEs have very different time scales (e.g., chemical dynamics with fast and slow reactions). Explicit Euler requires tiny h for stability, even if solution varies little. Implicit doesn't have this limit. Example: Robertson equation y'_1 = -0.04 y_1 + 1e4 y_2 y_3 (stiff for very different constants).

Notable ODEs

  • Exponential decay: y' = -k y, solution y = y_0 exp(-k t).
  • Logistic growth: y' = r y (1 - y/K), saturation at K.
  • Newton cooling: T' = -k (T - T_amb), tendency to T_amb.
  • Riccati: y' = y^2 - t, no elementary solution.
  • Lotka-Volterra (system): predator-prey.
  • Harmonic oscillator: y'' + y = 0 (2x2 system).

Numerical comparison

For y' = -y, y(0) = 1, T = 5 (exact y(5) = e^-5 ~ 0.006738):

  • Explicit Euler h=0.1 (50 steps): y_50 ~ 0.005154 (24% error)
  • Explicit Euler h=0.01 (500 steps): y_500 ~ 0.006568 (2.5% error)
  • Heun h=0.1: y_50 ~ 0.006740 (0.03% error)
  • RK4 h=0.1: y_50 ~ 0.006738 (1e-7% error)

When to use which method

  • Explicit Euler: didactic, non-stiff ODEs, small h acceptable.
  • Implicit Euler: stiff ODEs (chemistry, fluids, equilibria).
  • Heun: educational code, medium accuracy.
  • RK4: practical standard for non-stiff ODEs.
  • Adaptive (RK45, RK23): ODEs with variable speeds.

History

Leonhard Euler 1768 introduces method in "Institutiones Calculi Integralis". Cauchy 1840 rigorously proves convergence. Heun 1900 and Kutta 1901 extend to higher orders. Dahlquist 1956 introduces A-stability concept. Modern software (LSODE, scipy.integrate.solve_ivp) includes dozens of specialized methods.

Local and global error: where the order comes from

The distinction between local and global error explains why explicit Euler is called a first-order method. The local truncation error is the error committed in a single step, assuming the starting value exact: expanding the solution in a Taylor series shows that Euler neglects the term (h^2/2) y'', so its local error is proportional to h^2. The global error, accumulated over the whole interval divided into about 1/h steps, is instead proportional to h: halving the step halves the final error.

Second-order methods, such as Heun and the midpoint, also cancel the quadratic term and have local error h^3 and global error h^2: halving h reduces the error to a quarter. A practical way to estimate the error without knowing the exact solution is Richardson extrapolation, which compares the results obtained with two different steps (h and h/2) to deduce the effective order and a quantitative error estimate.

Toward Runge-Kutta: the ladder of one-step methods

The Euler methods are the first rungs of a wider hierarchy, that of one-step Runge-Kutta methods. Explicit Euler is the first-order Runge-Kutta; the midpoint and Heun's method are second-order variants that evaluate the slope at intermediate points to double the accuracy. The famous RK4, of order four, combines four evaluations per step and offers an excellent compromise between accuracy and cost, and is the workhorse of numerical ODE solving.

The next step is adaptive step control: methods such as Runge-Kutta-Fehlberg (RKF45) simultaneously compute a fourth-order and a fifth-order estimate, and from their difference deduce the local error, automatically adapting h to keep it below a threshold. Thus the solver uses large steps where the solution is smooth and small steps where it varies rapidly, optimizing the number of evaluations: an idea that descends directly from the simple Euler methods.

Updated July 2026

Frequently Asked Questions

What is the Euler method?

It is the simplest numerical method for solving an ordinary differential equation y' = f(t,y) with an initial condition. It approximates the solution with the formula y_{n+1} = y_n + h f(t_n, y_n), advancing in small steps h along the direction of the slope given by the equation.

What is the difference between explicit and implicit Euler?

Explicit Euler evaluates the slope at the start of the step, y_{n+1} = y_n + h f(t_n,y_n), and is simple but poorly stable. The implicit one evaluates it at the end, y_{n+1} = y_n + h f(t_{n+1},y_{n+1}), requiring an equation to be solved at each step but offering far superior stability for stiff problems.

What order is the Euler method?

Explicit Euler is first order: the global error is proportional to the step h, so halving h halves the error. Heun's and the midpoint methods are second order (error proportional to h^2), much more accurate for the same step.

What is a stiff problem?

It is an equation in which very different time scales coexist, with components that decay rapidly alongside slow ones. Explicit methods like Euler require tiny steps to remain stable, whereas implicit methods handle these problems with much larger steps.

What is Heun's method?

It is a second-order method also called improved Euler: it uses Euler as a predictor to estimate y_{n+1}, then corrects by averaging the slopes at the start and end of the step (trapezoidal rule). It doubles the order of accuracy over Euler at the cost of one extra evaluation.

How do you estimate the error without the exact solution?

With Richardson extrapolation: you solve the problem with step h and with step h/2 and compare the results. The difference, combined with the known order of the method, provides a quantitative error estimate and is the basis of adaptive step control.

What is the relation to Runge-Kutta?

The Euler methods are the simplest cases of the one-step Runge-Kutta family: Euler is first order, Heun and the midpoint second order, the famous RK4 fourth order. Increasing the slope evaluations per step yields greater accuracy.

When should you use which method?

Explicit Euler for simple and didactic problems; Heun or midpoint when more accuracy is needed at low cost; implicit Euler for stiff problems where stability is crucial. For serious applications one moves to RK4 or adaptive methods such as RKF45.

Comments (0)

No comments yet. Be the first!