Differential Equations

Euler’s Method: Formula and Step-by-Step Example

Euler’s Method: Formula and Step-by-Step Example — CalculusCalc cover image

Euler’s method is a first-order numerical procedure for solving initial value differential equations \(y' = F(x, y)\) with \(y(x_0) = y_0\) using the iterative formula \(y_{n+1} = y_n + h \cdot F(x_n, y_n)\) and \(x_{n+1} = x_n + h\). Starting from a known initial point, you calculate the local tangent slope, step forward by step size \(h\), and repeat to estimate future points along the solution curve.

When solving ordinary differential equations (ODEs), many equations encountered in physics, engineering, and biology cannot be integrated in terms of standard elementary functions. Numerical methods provide the essential bridge between an unsolved differential equation and a precise numerical trajectory. Euler’s method represents the fundamental building block for all discrete numerical integration techniques.

What is Euler’s method formula?

The core mathematical framework of Euler’s method rests on constructing a discrete sequence of approximate coordinates \((x_0, y_0), (x_1, y_1), (x_2, y_2), \dots, (x_N, y_N)\) that trace an unknown solution curve \(y(x)\).

Euler's method: A scientific calculator, pen, and blank notebook on a desk

For a first-order differential equation given by:

$$y' = F(x, y), \qquad y(x_0) = y_0$$

The updating formulas for stepping from step \(n\) to step \(n+1\) are:

$$x_{n+1} = x_n + h$$

$$y_{n+1} = y_n + h \cdot F(x_n, y_n)$$

The parameters in these formulas represent specific geometric and numerical components:

  • \(x_0, y_0\): The initial conditions provided at the start of the problem.
  • \(h\): The step size (a small positive constant distance along the independent axis \(x\)).
  • \(F(x_n, y_n)\): The derivative value evaluated at the start of step \(n\), which gives the slope of the tangent line at point \((x_n, y_n)\).
  • \(y_n\): The current estimated value of the dependent variable.
  • \(y_{n+1}\): The calculated target value at the next point \(x_{n+1}\).

Geometrically, Euler’s method follows the slope field of the differential equation using a series of short straight segments. At each point, you evaluate the slope, project a straight line segment over a horizontal distance \(h\), land at a new estimated point, recompute the local slope at this new location, and take another step.

Where does the Euler formula come from?

You can derive Euler’s method using two independent mathematical approaches: Taylor series expansions and numerical integration. Both derivations highlight how the approximation works and reveal the origin of its numerical error.

A feather quill pen and inkwell on a wooden desk

Derivation from Taylor series

Assuming the true solution \(y(x)\) is infinitely differentiable near \(x_n\), expand \(y(x_n + h)\) as a Taylor series centered at \(x_n\):

$$y(x_n + h) = y(x_n) + h \cdot y'(x_n) + \frac{h^2}{2!} y''(x_n) + \frac{h^3}{3!} y'''(x_n) + \dots$$

Because \(y'(x_n) = F(x_n, y(x_n))\), substituting the differential equation into the series yields:

$$y(x_n + h) = y(x_n) + h \cdot F(x_n, y(x_n)) + \frac{h^2}{2} y''(\xi)$$

where \(\xi\) is some point between \(x_n\) and \(x_n + h\). Dropping the higher-order terms involving \(h^2\) and replacing the exact values \(y(x_n)\) with calculated estimates \(y_n\) leaves the standard Euler update rule. However, the discarded leading term, \(\frac{h^2}{2} y''(\xi)\), represents the local truncation error per step.

Derivation from definite integration

Integrating both sides of \(y' = F(x, y)\) over the interval \([x_n, x_{n+1}]\) yields the exact integral relationship:

$$y(x_{n+1}) = y(x_n) + \int_{x_n}^{x_{n+1}} F(x, y(x)) \, dx$$

Euler’s method approximates the integral on the right using a left-endpoint rectangle approximation. The width of the rectangle is \(h = x_{n+1} - x_n\) and its height is the slope evaluated at the left endpoint, \(F(x_n, y(x_n))\). Approximating the integral as a left Riemann sum produces \(h \cdot F(x_n, y_n)\), yielding the exact same updating equation.

How to calculate Euler’s method step by step

  1. Identify the system variables: Extract the differential equation function \(F(x, y)\), initial point \((x_0, y_0)\), target endpoint \(x_{\text{end}}\), and step size \(h\).
  2. Determine total step count: Calculate \(N = \frac{x_{\text{end}} - x_0}{h}\). If \(N\) is not an integer, adjust \(h\) so that an integer number of uniform steps reaches \(x_{\text{end}}\).
  3. Evaluate current derivative: Substitute \((x_n, y_n)\) into \(F(x, y)\) to find the local slope \(k_1 = F(x_n, y_n)\).
  4. Calculate next point: Compute \(y_{n+1} = y_n + h \cdot k_1\) and set \(x_{n+1} = x_n + h\).
  5. Record and iterate: Log \(x_n\), \(y_n\), slope, and \(y_{n+1}\) in a calculation table. Repeat steps 3 and 4 until \(x_n = x_{\text{end}}\).

Worked examples: step-by-step solutions

Example 1: Full iteration table for \(y' = x + y\)

Approximate \(y(1)\) for the initial value problem \(y' = x + y\) with \(y(0) = 1\) using step size \(h = 0.1\). The number of steps required is \(N = \frac{1.0 - 0}{0.1} = 10\).

A blank notebook and pencil on a wooden background
Step (\(n\)) \(x_n\) \(y_n\) Slope \(F(x_n, y_n) = x_n + y_n\) \(y_{n+1} = y_n + 0.1 \cdot \text{slope}\)
0 0.0 1.0000 1.0000 1.1000
1 0.1 1.1000 1.2000 1.2200
2 0.2 1.2200 1.4200 1.3620
3 0.3 1.3620 1.6620 1.5282
4 0.4 1.5282 1.9282 1.7210
5 0.5 1.7210 2.2210 1.9431
6 0.6 1.9431 2.5431 2.1974
7 0.7 2.1974 2.8974 2.4871
8 0.8 2.4871 3.2871 2.8158
9 0.9 2.8158 3.7158 3.1874
10 1.0 3.1874 — —

The numerical approximation yields \(y(1) \approx 3.1874\). However, the exact analytical solution for this ODE is \(y(x) = 2e^x - x - 1\). Evaluating at \(x = 1\) gives \(y(1) = 2e - 2 \approx 3.4366\). As a result, the error after 10 steps is \(3.4366 - 3.1874 = 0.2492\).

Example 2: Exponential growth rate

Estimate \(y(1)\) for \(y' = y\) with \(y(0) = 1\) using \(h = 0.25\).

For \(F(x, y) = y\), each step computes \(y_{n+1} = y_n + h(y_n) = y_n(1 + h)\). With \(h = 0.25\), each step multiplies the previous value by \(1.25\):

  • Step 1 (\(x_1 = 0.25\)): \(y_1 = 1.0 \cdot (1.25) = 1.2500\)
  • Next, Step 2 (\(x_2 = 0.50\)): \(y_2 = 1.25 \cdot (1.25) = 1.5625\)
  • Step 3 (\(x_3 = 0.75\)): \(y_3 = 1.5625 \cdot (1.25) = 1.9531\)
  • Also, Step 4 (\(x_4 = 1.00\)): \(y_4 = 1.9531 \cdot (1.25) = 2.4414\)

The true value is \(y(1) = e^1 \approx 2.7183\). This illustrates how discrete stepping introduces structural lag in compounding growth problems compared to continuous models analyzed with an exponential growth calculator.

Example 3: Newton’s law of cooling

A heated liquid at 90°C cools in a surrounding ambient room temperature of 20°C according to \(T' = -0.1(T - 20)\), where \(t\) is measured in minutes. Estimate \(T(3)\) using \(h = 1\) minute.

  • Step 1 (\(t_1 = 1\)): \(T_1 = 90 + 1 \cdot [-0.1(90 - 20)] = 90 - 7.0 = 83.00^\circ\text{C}\)
  • Then, Step 2 (\(t_2 = 2\)): \(T_2 = 83 + 1 \cdot [-0.1(83 - 20)] = 83 - 6.3 = 76.70^\circ\text{C}\)
  • Step 3 (\(t_3 = 3\)): \(T_3 = 76.7 + 1 \cdot [-0.1(76.7 - 20)] = 76.7 - 5.67 = 71.03^\circ\text{C}\)

The exact continuous solution is \(T(t) = 20 + 70e^{-0.1t}\). At \(t = 3\), \(T(3) = 20 + 70e^{-0.3} \approx 71.86^\circ\text{C}\). Because the solution curve is concave upward ($T” > 0$), Euler’s linear tangent estimates consistently stay below the exact decay curve.

Example 4: Non-elementary differential equation

The non-linear differential equation \(y' = x^2 + y^2\) with initial condition \(y(0) = 0\) cannot be solved in closed form using standard elementary functions. Apply Euler’s method with \(h = 0.1\) to estimate \(y(0.3)\).

  • Step 1 (\(x_0 = 0.0, y_0 = 0.0\)): \(\text{slope} = 0.0^2 + 0.0^2 = 0.0 \implies y_1 = 0.0 + 0.1(0.0) = 0.0\)
  • Similarly, Step 2 (\(x_1 = 0.1, y_1 = 0.0\)): \(\text{slope} = 0.1^2 + 0.0^2 = 0.01 \implies y_2 = 0.0 + 0.1(0.01) = 0.0010\)
  • Step 3 (\(x_2 = 0.2, y_2 = 0.0010\)): \(\text{slope} = 0.2^2 + (0.0010)^2 = 0.040001 \implies y_3 = 0.0010 + 0.1(0.040001) = 0.0050001\)

At \(x = 0.3\), \(y(0.3) \approx 0.0050001\). This highlights why numerical integration is required in quantitative analysis when analytic solutions are impossible to obtain.

Example 5: Logistic population growth

Model a population governed by \(P' = 0.5P \left(1 - \frac{P}{100}\right)\) with \(P(0) = 10\) and \(h = 1\) year for 2 years.

  • Step 1 (\(t_1 = 1\)): \(\text{slope} = 0.5(10)\left(1 - \frac{10}{100}\right) = 5(0.9) = 4.5 \implies P_1 = 10 + 1(4.5) = 14.50\)
  • Step 2 (\(t_2 = 2\)): \(\text{slope} = 0.5(14.5)\left(1 - \frac{14.5}{100}\right) = 7.25(0.855) \approx 6.1988 \implies P_2 = 14.5 + 1(6.1988) = 20.6988\)

Example 6: Numerical instability in stiff equations

Consider \(y' = -10y\) with \(y(0) = 1\). The analytical solution is \(y(x) = e^{-10x}\), which decays smoothly to zero. Attempt to approximate \(y(1)\) using \(h = 0.25\):

  • \(y_0 = 1.0\)
  • \(y_1 = 1.0 + 0.25(-10 \cdot 1.0) = 1.0 - 2.5 = -1.5\)
  • \(y_2 = -1.5 + 0.25(-10 \cdot -1.5) = -1.5 + 3.75 = 2.25\)
  • \(y_3 = 2.25 + 0.25(-10 \cdot 2.25) = 2.25 - 5.625 = -3.375\)

Instead of decaying toward zero, the numerical solution oscillates wildly with increasing magnitude. This numerical instability occurs whenever the step size exceeds the stability limit of the differential equation.

How accurate is Euler’s method and how do you reduce error?

To quantify accuracy in numerical differential equation solvers, mathematicians distinguish between two forms of numerical error:

A close-up of a stainless steel Vernier caliper measuring tool
  • Local Truncation Error (LTE): The error incurred during a single step assuming the previous point is exact. For Euler’s method, \(\text{LTE} = \frac{h^2}{2} y''(\xi) = \mathcal{O}(h^2)\).
  • Global Truncation Error (GTE): The accumulated total error at a fixed final position \(x_{\text{end}}\). Because accumulating steps over an interval of length \(L = x_{\text{end}} - x_0\) requires \(N = L / h\) steps, multiplying \(N\) steps by \(\mathcal{O}(h^2)\) local error yields \(\text{GTE} = \mathcal{O}(h)\).

Because the global error scales directly with \(h^1\), Euler’s method is classified as a first-order method. Halving step size \(h\) reduces global error by approximately half.

The second derivative \(y''(x)\) dictates whether Euler’s method overestimates or underestimates the true path:

  • If $y”(x) > 0$ (concave upward), the tangent line lies entirely below the true curve, causing Euler’s method to underestimate the solution.
  • If $y”(x) < 0$ (concave downward), the tangent line lies above the true curve, causing Euler’s method to overestimate the solution.

Comparing Euler’s method to other numerical solvers

While simple to implement, Euler’s method requires small step sizes to maintain modest accuracy. Advanced algorithms sample multiple slopes across each interval to eliminate low-order error terms.

Solver Method Order of Accuracy Global Error Slopes Evaluated per Step Primary Application Use Case
Forward Euler 1st Order \(\mathcal{O}(h)\) 1 Basic conceptual teaching, real-time simple physics engines
Improved Euler (Heun) 2nd Order \(\mathcal{O}(h^2)\) 2 Moderate accuracy requirements with minimal code complexity
Midpoint Method 2nd Order \(\mathcal{O}(h^2)\) 2 Second-order kinematic systems and geometric stepping
Runge–Kutta (RK4) 4th Order \(\mathcal{O}(h^4)\) 4 Standard computational science and engineering solver
Backward (Implicit) Euler 1st Order \(\mathcal{O}(h)\) 1 (Implicit) Stiff differential equations requiring absolute stability

Improved Euler (Heun’s method) predicts an initial endpoint using standard Euler, evaluates the slope at that predicted endpoint, and averages the starting slope and predicted ending slope. Runge–Kutta (RK4) evaluates four distinct intermediate slopes per step, reducing global error to \(\mathcal{O}(h^4)\). Similarly, concepts like root iteration in Newton’s method share a similar underlying reliance on linear tangent approximations.

How to extend Euler’s method to second-order differential equations

A second-order differential equation \(y'' = G(x, y, y')\) with \(y(x_0) = y_0\) and \(y'(x_0) = v_0\) cannot be stepped directly with a single variable formula. To solve it, define a helper variable \(v = y'\) to convert the single second-order equation into a coupled system of two first-order differential equations:

A metal pendulum cone tracing patterns in sand

$$\begin{cases}y' = v v' = G(x, y, v)\end{cases}$$

Applying Euler’s method simultaneously to both equations updates position and velocity across step size \(h\):

$$y_{n+1} = y_n + h \cdot v_n$$

$$v_{n+1} = v_n + h \cdot G(x_n, y_n, v_n)$$

This coupled approach is standard in physics engines for simulating planetary motion, spring-mass dampers, and projectile trajectories.

When should you not use Euler’s method?

Euler’s method is inadequate or non-viable under specific mathematical conditions:

A mechanical pencil lying horizontally on a white background
  • Stiff differential equations: Equations containing rapidly decaying exponential components alongside slow dynamics (such as chemical reaction kinetics) force explicit Euler methods to use tiny step sizes to avoid wild oscillations.
  • High-precision scientific computing: Achieving 8 digits of precision with a first-order method requires roughly \(10^8\) steps, whereas an RK4 solver achieves equal precision in a fraction of the computational time.
  • Conservative physical systems over long time horizons: Simple forward Euler integration continuously adds artificial numerical energy into oscillating systems (like orbital mechanics or frictionless pendulums), causing orbits to spiral outward. Symplectic integrators or implicit methods must be used instead.

Common errors and how to avoid them

  • Evaluating slopes at the wrong point: Always evaluate \(F(x_n, y_n)\) at the start of the current step \(n\). Do not mix \(x_{n+1}\) with \(y_n\).
  • Forgetting step size \(h\): Remember that \(y_{n+1} = y_n + h \cdot F(x_n, y_n)\). Omitting \(h\) adds the derivative directly to position rather than scaling by time or distance.
  • Off-by-one step errors: Track step index \(n\) and current position \(x_n\) explicitly in a table. Stepping from \(x = 0\) to \(x = 1\) with \(h = 0.1\) requires exactly 10 iterations (\(n = 0\) through \(n = 9\) produce \(y_1\) through \(y_{10}\)).
  • Intermediate rounding errors: Retain at least 4 to 6 decimal places during intermediate steps. Rounding off intermediate steps compounds cumulative truncation errors.
  • Ignoring \(y\)-dependence in derivative functions: When derivative \(F(x, y)\) contains \(y\), re-evaluate the derivative using your latest updated value \(y_n\) at every single iteration.

Euler’s method interactive calculator

Test differential equations, initial conditions, and step sizes using the integrated tool below:

A man sitting on a couch working on a laptop
Physics & Applied#24

Euler's Method ODE Solver

Approximates \(y' = F(x, y)\) step by step, compared with RK4.

For complete tabular step listings and interactive plotting options, access the dedicated Euler’s method calculator.

Practice problems with full solutions

Work through these practice problems to test your understanding before checking the solutions.

A person's hand drawing on paper with a pencil
  1. Given \(y' = y\), \(y(0) = 1\), and \(h = 0.5\), estimate \(y(1)\).
  2. Next, Given \(y' = 2x\), \(y(0) = 0\), and \(h = 0.5\), estimate \(y(1)\).
  3. Given \(y' = -y\), \(y(0) = 1\), and \(h = 0.1\), estimate \(y(0.2)\).
  4. Also, Given \(y' = x y\), \(y(0) = 1\), and \(h = 0.5\), estimate \(y(1)\).
  5. Given \(y' = y - x\), \(y(0) = 2\), and \(h = 0.5\), estimate \(y(1)\).
  6. For the linear equation \(y' = -10y\), determine the maximum step size \(h\) that maintains numerical stability for explicit Euler integration.

Solutions

1. Solution: \(y_1 = 1 + 0.5(1) = 1.5\). \(y_2 = 1.5 + 0.5(1.5) = 2.25\). Answer: \(y(1) \approx 2.25\).

2. Solution: \(y_1 = 0 + 0.5(2 \cdot 0) = 0\). Then \(y_2 = 0 + 0.5(2 \cdot 0.5) = 0.5\). Answer: \(y(1) \approx 0.5\).

3. Solution: \(y_1 = 1 + 0.1(-1) = 0.9\). Next, \(y_2 = 0.9 + 0.1(-0.9) = 0.81\). Answer: \(y(0.2) \approx 0.81\).

4. Solution: \(y_1 = 1 + 0.5(0 \cdot 1) = 1.0\). Following this, \(y_2 = 1.0 + 0.5(0.5 \cdot 1.0) = 1.25\). Answer: \(y(1) \approx 1.25\).

5. Solution: \(y_1 = 2 + 0.5(2 - 0) = 3.0\). After that, \(y_2 = 3.0 + 0.5(3.0 - 0.5) = 3.0 + 1.25 = 4.25\). Answer: \(y(1) \approx 4.25\).

6. Solution: For \(y' = -ky\), stability requires $|1 – kh| < 1$, which simplifies to \(h < \frac{2}{k}\). Here \(k = 10\), so \(h < \frac{2}{10} = 0.2\). Therefore, the answer is $h < 0.2$.

Frequently asked questions

What step size should I choose for Euler’s method?

Select a step size small enough that halving it does not significantly alter your answer at your required precision level. For classroom homework, \(h = 0.1\) or \(h = 0.05\) is standard, while practical applications usually employ higher-order adaptive solvers instead.

Does Euler’s method overestimate or underestimate the exact solution?

It depends entirely on the concavity of the solution curve. For example, if the solution is concave up ($y” > 0$), tangent lines sit below the curve and Euler underestimates. However, if concave down ($y” < 0$), tangent lines sit above and Euler overestimates.

Why is Euler’s method considered first-order if the step error is \(h^2\)?

While the local truncation error per step is \(\mathcal{O}(h^2)\), reaching a fixed endpoint across an interval requires \(N = \frac{\text{length}}{h}\) steps. Multiplying \(N \propto \frac{1}{h}\) steps by local error \(\mathcal{O}(h^2)\) yields a cumulative global error of \(\mathcal{O}(h)\).

How does Euler’s method handle systems of equations?

Euler’s method updates every state variable simultaneously at each step using its corresponding derivative equation. For instance, in a two-variable system \((y, v)\), both \(y_{n+1}\) and \(v_{n+1}\) are computed using the current values \((y_n, v_n)\) before advancing to step \(n+1\).

What is the difference between forward and backward Euler methods?

Forward (explicit) Euler evaluates the slope at the current known point \((x_n, y_n)\) to calculate \(y_{n+1}\). Backward (implicit) Euler evaluates the slope at the future point \((x_{n+1}, y_{n+1})\), requiring algebraic equation solving at each step but providing superior numerical stability for stiff equations.

Further reading

Calculators for this topic

Get new calculus guides by email

Free worked examples and new calculators, at most once a day. Unsubscribe with one click.

Leave a comment

Your email address will not be published. Required fields are marked *