The idea: follow the slope for one step
A first-order ordinary differential equation does not tell you y, it tells you how fast y changes at every point: dy/dt = f(t, y). If you know where you are now, the slope tells you where you will be a moment later, approximately. Euler's method takes that literally. Start at the initial value, compute the slope there, move a step h along it, and repeat from the new point. Each step uses only the slope at the start of the step, which is both what makes it simple and what makes it inaccurate.
The example: Newton's law of cooling
Newton's law of cooling says a hot drink loses heat faster the hotter it is: dT/dt = −k · (T − Troom). With k = 0.05 per minute, a 20 °C room and tea at 95 °C, the slope at the start is −0.05 × 75 = −3.75 °C per minute. This equation has an exact solution, T(t) = Troom + (T0 − Troom) · e−k·t, which makes it a good test: you can put the exact answer next to Euler's and see the error in every row.
Set up Euler's method in Excel
Keep the parameters in cells (k in B2, room temperature in B3, step h in B4, start temperature in B5) and build a table with one row per step:
- Time: A8 = 0, then
=A8+$B$4copied down. - T Euler: B8 =
=B5, then=B8+$B$4*C8: the previous value plus h times the previous slope. - Slope:
=-$B$2*(B8-$B$3), f(t, y) evaluated at the current row. - Exact:
=$B$3+($B$5-$B$3)*EXP(-$B$2*A8). - Error:
=B8-D8.
The $ signs keep the parameters fixed while the row references move, so you write each formula once and copy it down to t = 60. For any other equation you only change the slope column: f(t, y) can use both the time in column A and the value in column B.
Worked example: tea cooling with 5-minute Euler steps
The yellow cells are the parameters and the start time. Each row is one Euler step: column B uses the slope in column C of the row above. Column D is the exact solution and column E the error.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Parameter | Value | |||
| 2 | Cooling constant k (per min) | 0.05 | |||
| 3 | Room temperature (°C) | 20 | |||
| 4 | Step h (min) | 5.0 | |||
| 5 | Start temperature (°C) | 95 | |||
| 6 | |||||
| 7 | t (min) | T Euler (°C) | Slope dT/dt | T exact (°C) | Error (°C) |
| 8 | 0 | 95.00 | -3.750 | 95.00 | 0.00 |
| 9 | 5 | 76.25 | -2.813 | 78.41 | -2.16 |
| 10 | 10 | 62.19 | -2.109 | 65.49 | -3.30 |
| 11 | 15 | 51.64 | -1.582 | 55.43 | -3.79 |
| 12 | 20 | 43.73 | -1.187 | 47.59 | -3.86 |
| 13 | 25 | 37.80 | -0.890 | 41.49 | -3.69 |
| 14 | 30 | 33.35 | -0.667 | 36.73 | -3.39 |
| 15 | 35 | 30.01 | -0.501 | 33.03 | -3.02 |
| 16 | 40 | 27.51 | -0.375 | 30.15 | -2.64 |
| 17 | 45 | 25.63 | -0.282 | 27.90 | -2.27 |
| 18 | 50 | 24.22 | -0.211 | 26.16 | -1.93 |
| 19 | 55 | 23.17 | -0.158 | 24.79 | -1.63 |
| 20 | 60 | 22.38 | -0.119 | 23.73 | -1.36 |
| 21 | |||||
| 22 | Largest absolute error (°C) | 3.86 | |||
| 23 | Euler at t = 60 in closed form: 20 + 75 · (1 − k·h)^n | 22.38 | |||
| 24 | Error at t = 60 with h = 2.5 (closed form) | -0.69 | |||
| 25 | Error ratio, h = 5 vs h = 2.5 | 1.96 | |||
- B9
=B8+$B$4*C8Euler step: y + h · slope - C8
=-$B$2*(B8-$B$3)Slope f(t, y) - D8
=$B$3+($B$5-$B$3)*EXP(-$B$2*A8)Exact solution - E22
=MAX(ABS(E8:E20))Largest |error| (array formula in older Excel)
Temperatures are rounded to 2 decimals in the grid. In Excel 2019 and older, confirm =MAX(ABS(E8:E20)) with Ctrl+Shift+Enter.
Reading the error
Every Euler value is below the exact curve. The tea's cooling slows during each step, but Euler keeps using the steeper slope from the start of the step, so it cools too fast. The largest error, 3.86 °C at t = 20, comes early, where the curve bends most. Later both curves flatten towards room temperature and the gap shrinks again to 1.36 °C at t = 60.
For this linear equation each step multiplies the distance to room temperature by (1 − k·h) = 0.75, so after n steps T = 20 + 75 · 0.75n. Euler replaces e−k·t by a power, which is why row 23 matches the last value of the table exactly.
Step size and the order of the method
Euler's method is first order: the global error is roughly proportional to h. Halve the step and the error at a fixed time roughly halves, here from −1.36 °C to −0.69 °C, a ratio of 1.96. To get ten times more accuracy you need ten times more rows. Methods of higher order do much better per step: Heun's method (improved Euler) averages the slope at the start and at a predicted end point and is second order, and the classical Runge-Kutta method (RK4) uses four slopes per step and is fourth order. Too large a step can also make Euler unstable: if k·h is above 2 in this equation, the values oscillate and grow instead of cooling.
Euler steps are also the engine of simple simulations such as the SIR model in Excel, and for solving an equation f(x) = 0 rather than a differential equation see the Newton-Raphson method.
Common mistakes
- Using the new slope instead of the old one.
=B8+$B$4*C9uses the slope at the end of the step, which needs the value you are still calculating. Explicit Euler uses the slope of the row above. - Forgetting the $ signs. Without
$B$4and$B$2the copied formulas drift to empty cells and every step after the first is wrong. - Mixing time units. k is per minute, so h must be in minutes too. A step of 5 with k per hour is a different problem.
- Trusting a single run. Halve the step and compare. If the result changes a lot, the step is too large.
- A step that is too large. When k·h exceeds 2 in this equation, Euler oscillates and blows up even though the real tea simply cools.
- Comparing Euler with itself. Check against an exact solution or a much smaller step, not against a second Euler run with the same h.
Frequently asked questions
What is the formula for Euler's method?
y(n+1) = y(n) + h · f(t(n), y(n)), with t(n+1) = t(n) + h. Start from the initial value and repeat. In Excel, one column holds the slope f(t, y) and the next value adds h times that slope to the previous value.
How do you do Euler's method in Excel?
Put the step size and parameters in cells, start the time column at 0 and add h in each row, put the initial value in the first row of the y column, compute the slope in the next column, and in the second row of the y column add $h times the slope of the row above. Copy the formulas down.
How accurate is Euler's method?
It is a first-order method: the global error is roughly proportional to the step size. Halving h roughly halves the error. In the example the error after 60 minutes falls from -1.36 °C with 5-minute steps to -0.69 °C with 2.5-minute steps.
What is the difference between Euler and Runge-Kutta?
Euler uses one slope per step, at the start. Runge-Kutta methods combine several slopes within the step. The classical RK4 uses four and is fourth order, so it is far more accurate for the same step size.