Lesson 1
Discretization and Euler's Method
The simplest stepping rule, and the framework that every later method extends.
1 Modelling context
A differential equation is a statement about rates of change. It tells you how fast a quantity is moving, but not where it will be at some later time. To answer that question, you integrate the rate over time — and in most applied problems, the integral cannot be evaluated in closed form.
Numerical methods replace integration with stepping. Starting from
a known value at time t₀, they estimate the rate of
change, take a small step forward, and repeat. The family of
methods in this module all share the same structure; they differ
in how they estimate the rate of change during each step.
Euler's method is the simplest. It assumes the rate of change is constant across each step, using the value at the start. This is often wrong, but the method is easy to implement and easy to analyse. More importantly, understanding exactly how Euler fails is the prerequisite for understanding why more sophisticated methods exist.
Discretization is a modelling decision
Choosing a step size is not a technical detail. It changes the numerical problem you are actually solving, and it determines the accuracy of the result. The step size is part of the model and must be documented alongside the parameters.
2 Learning objectives
By the end of this lesson you will be able to
- Discretize an initial-value problem onto a uniform grid.
- Derive Euler's method from the forward-difference approximation.
- Implement Euler's method in a spreadsheet with documented inputs and step size.
- Identify the qualitative failure modes of Euler's method on a convex or concave solution.
- Explain the relationship between step size and global error for a first-order method.
3 Prerequisite review
- Derivative as a rate of change
-
dy/dtis the instantaneous rate at whichychanges with respect tot. In an ODE, this rate is expressed as a function oftandy. - Taylor expansion
-
A function can be expanded about a point as
y(t + h) = y(t) + h y'(t) + (h²/2) y''(t) + …. Truncating after the first-order term gives Euler's method. - Forward-difference approximation
-
The derivative can be approximated as
y'(t) ≈ ( y(t + h) − y(t) ) / h. Rearranging gives the Euler update rule. - Analytical solution
- For a small class of ODEs, the solution can be written in closed form. When this is available, it is the gold standard against which the numerical solution is compared.
4 Mathematical formulation
Consider the initial-value problem
dy/dt = f(t, y), y(t₀) = y₀
Choose a uniform step size h > 0 and define the
grid
t_n = t₀ + n h, n = 0, 1, 2, …
Derivation from the forward difference
The forward-difference approximation of the derivative at
t_n is
dy/dt |_{t = t_n} ≈ ( y(t_{n+1}) − y(t_n) ) / h
Substituting the ODE dy/dt = f(t, y) and rearranging:
y(t_{n+1}) ≈ y(t_n) + h f(t_n, y(t_n))
Let y_n denote the numerical approximation to
y(t_n). Euler's method is
y_{n+1} = y_n + h f(t_n, y_n), y_0 given
Derivation from the Taylor expansion
Expand the exact solution about t_n:
y(t_n + h) = y(t_n) + h y'(t_n) + (h²/2) y''(t_n) + O(h³)
Since y'(t_n) = f(t_n, y(t_n)), this becomes
y(t_n + h) = y(t_n) + h f(t_n, y(t_n)) + (h²/2) y''(t_n) + O(h³)
Euler's method retains only the first two terms. The truncation error is therefore
τ_n = (h²/2) y''(t_n) + O(h³) = O(h²)
This is the local truncation error. It scales as
O(h²), which means the method is of order 1 globally
— a fact developed fully in Lesson 3.
Geometric interpretation
Euler's method advances along the tangent line to the solution at
each grid point. When the solution is convex (y'' > 0), the tangent lies below the curve, and Euler underestimates.
When the solution is concave (y'' < 0), the
tangent lies above the curve, and Euler overestimates. The sign of
the error is therefore predictable from the curvature of the exact
solution.
5 Worked example
Exponential growth with a known analytical solution
Consider the simple growth model
dy/dt = y, y(0) = 1
whose exact solution is y(t) = et. This example is deliberately simple so that the numerical
error can be measured exactly.
Step 1 — Discretize.
Choose h = 0.1. The grid points are
t_n = 0, 0.1, 0.2, …
Step 2 — Apply the update rule.
At n = 0:
y_1 = y_0 + h · y_0 = 1 + 0.1 · 1 = 1.1.
At n = 1:
y_2 = 1.1 + 0.1 · 1.1 = 1.21.
In general, the update rule for this problem is
y_{n+1} = (1 + h) y_n, so the numerical solution
after n steps is
y_n = (1 + h)n.
Step 3 — Compare with the exact solution.
After 10 steps (t = 1):
-
Exact:
y(1) = e1 ≈ 2.71828. -
Euler with
h = 0.1:1.110 ≈ 2.59374. - Absolute error:
0.12454.
After 100 steps (t = 10):
-
Exact:
y(10) = e10 ≈ 22026.47. -
Euler with
h = 0.1:1.1100 ≈ 13780.61. - Absolute error:
8245.86.
The absolute error grows dramatically over the interval because
the solution itself grows. The relative error is a
better measure: it is about 4.6% at t = 1 and about
37% at t = 10.
Step 4 — Reduce the step size.
Halve the step size to h = 0.05. The relative error
at t = 10 becomes approximately 20%. Halve again to
h = 0.025: the relative error becomes approximately
10%.
The pattern: halving h approximately halves the
global error. This is the signature of a first-order method, and
it motivates the higher-order methods of Lesson 2 and Unit 2.2.
The step size is not a free parameter. Reducing it improves accuracy but increases the number of steps required, and therefore the runtime. The tradeoff between accuracy and cost is the central theme of the module.
6 Verification check
Checks to perform
-
Reproduce a known case. For
dy/dt = y, y(0) = 1, the exact solution iset. Confirm the spreadsheet's output at a few grid points against this. -
Check the first step by hand. Compute
y_1 = y_0 + h f(t_0, y_0)independently and compare against the spreadsheet. -
Verify the step count. The number of steps
from
t_0tot_endis(t_end − t_0) / h. A mismatch indicates a grid error. -
Check units. If
fhas units ofyper unit time, thenh fhas units ofy, as required. -
Test the limiting case
f = 0. If the derivative is zero, the solution should remain constant aty_0for all time. -
Test the limiting case
h → 0. As the step size decreases, the numerical solution should approach the exact solution.
7 Interpretation
Euler's method is a first-order method. This means that reducing
the step size by a factor of k reduces the global
error by a factor of approximately k. To gain one
additional decimal digit of accuracy, you must reduce the step
size by a factor of ten — and multiply the runtime by ten.
The method is rarely used in production work for this reason. Its value in this course is conceptual: it establishes the framework that all one-step methods share, and it demonstrates the systematic bias that arises from using a tangent-line approximation on a curved solution.
Reading the error pattern
The error of Euler's method is not random. On a convex solution, it is systematically negative — the method underestimates. On a concave solution, it is systematically positive. This bias is a property of the method, not of the data, and it persists no matter how small the step size becomes. It shrinks, but it does not disappear.
8 Uncertainty and limitations
Two sources of error limit the accuracy of Euler's method. Their relative importance depends on the step size.
| Source | Scaling | Reduced by |
|---|---|---|
| Local truncation error | O(h²) per step |
Smaller step size |
| Accumulated global error | O(h) over a fixed interval |
Smaller step size; higher-order method |
| Roundoff | Grows with step count | Fewer steps; careful arithmetic |
Truncation error decreases with the step size; roundoff error increases as the number of steps grows. There is a step size below which further reduction does not improve accuracy and may degrade it. The optimal step size depends on the problem and on the machine precision. For most practical problems with double-precision arithmetic, this limit is far below any step size you would choose for reasons of accuracy alone.
Smaller is not always better
Reducing the step size improves truncation error but increases the number of steps, and therefore roundoff accumulation and runtime. A carefully chosen moderate step size is usually preferable to an indiscriminately small one.
9 Common implementation errors
Watch for these
-
Using the updated value of
twhen evaluatingf. Euler is an explicit method: the increment usesf(t_n, y_n), notf(t_{n+1}, y_n). Reading the wrong row from a spreadsheet is a common source of this error. -
Filling the formula with a relative reference that shifts
incorrectly.
The reference to
hshould be absolute so that it does not change as the formula is copied down. -
Off-by-one in the step count. The number of
steps is
(t_end − t_0) / h. Verify the last row reachest_endexactly, or document the endpoint. -
Mixing units between
handf. Iffhas units of per-hour, thenhmust be in hours. - Assuming the error is small because the output looks right. A first-order method can produce a solution that appears visually correct while carrying substantial error. The comparison against an analytical solution or a refined step size is required.
- Applying Euler to a stiff problem. See Unit 2.2, Lesson 3. The step size required for stability can be far smaller than the step size required for accuracy.
10 Independent modelling task
Your turn
-
Choose an initial-value problem with a known analytical
solution. Good candidates:
dy/dt = −y,dy/dt = y − t, ordy/dt = cos(t). - Implement Euler's method in a spreadsheet, with inputs (initial condition, step size, endpoint) in a clearly labelled input region.
-
Compute the numerical solution at
h = 0.2,h = 0.1, andh = 0.05. - For each step size, compute the absolute error against the analytical solution at the endpoint.
- Tabulate the errors against the step sizes. Compute the ratio of error between successive step sizes. Confirm the ratio is close to 2, the signature of a first-order method.
- Plot the numerical and analytical solutions on the same axes for the largest and smallest step sizes. Describe the qualitative difference.
This exercise is the basis for Laboratory 3 and feeds the ODE component of Assignment 2.
11 Reflection prompt
Reflect before continuing
In the worked example, the relative error grew substantially over the integration interval, even though the local truncation error per step remained the same. What does this suggest about the relationship between local and global error?
Two or three sentences. Lesson 3 develops this relationship formally.
12 Lesson summary
Key takeaways
- Euler's method advances along the tangent line at each step. It assumes the derivative is constant across the step, which is exact only for linear solutions.
-
The update rule is
y_{n+1} = y_n + h f(t_n, y_n). It is explicit: the increment uses values at the start of the step. -
The local truncation error is
O(h²). The global error isO(h), so the method is first-order. - The error is systematic, not random. On a convex solution, Euler underestimates; on a concave solution, it overestimates.
- Halving the step size halves the global error. Gaining one decimal digit of accuracy requires a tenfold increase in runtime. This motivates the higher-order methods that follow.
Coming next
Lesson 2 introduces second-order corrections — modified Euler and midpoint methods — that use a trial step to improve accuracy per step.
§ Self-quiz, practice, and homework
Self-quiz
Q1
Euler's method for dy/dt = f(t, y) is:
Show answer
y_{n+1} = y_n + h f(t_n, y_n).
Euler uses the slope at the start of the step.
Q2
Euler's method is derived from truncating a Taylor expansion after:
Show answer
The first-order term. This is why Euler is first-order accurate.
Q3
The local truncation error of Euler's method is:
Show answer
O(h²). The local error per
step is second-order; the global error is first-order.
Q4
On a convex solution, Euler's method:
Show answer
Underestimates. The tangent line lies below a convex curve.
Q5
Halving the step size in Euler's method reduces the global error by approximately:
Show answer
A factor of 2. First-order method.
Practice exercises
-
Apply Euler's method by hand to
dy/dt = −2y, y(0) = 1withh = 0.1for three steps. Compute the exact value at each step and the error. -
Repeat exercise 1 with
h = 0.05. Confirm the error ratio is approximately 2. -
Write the Euler update rule for
dy/dt = t − y. Compute three steps from(t₀, y₀) = (0, 1)withh = 0.1. -
For
dy/dt = y sin(t), write the Euler update and explain why the method cannot be simplified to a closed-form recurrence.
Homework problems
-
Euler implementation and analysis. Implement
Euler's method in a spreadsheet for the initial-value problem
dy/dt = −y + sin(t), y(0) = 1. Run ath = 0.2,0.1,0.05. For each, compute the numerical solution att = 1, 2, 3and compare against the analytical solution. Tabulate the errors, compute the observed order, and produce a log-log plot. Write a 500-word report. -
Error sign analysis. For the problem
dy/dt = t², y(0) = 0, compute the exact solution and the Euler approximation att = 1forh = 0.1. Determine the sign of the error and explain it geometrically. -
Boundary case. Consider
dy/dt = 0withy(0) = 5. Verify that Euler's method is exact for this problem. Explain why.
Mini project
Choose an ODE model of a physical, biological, or economic process with a known analytical solution. Implement Euler's method in a spreadsheet, run a convergence study, and produce a technical report that documents the grid, the initial condition, the parameter values, the observed order of convergence, and a claim-support statement. This is the basis for Laboratory 3 and part of Assignment 2.