On this page
Euler's method turns a differential equation into a loop you can run by hand or in a spreadsheet. The cleanest test case is dy/dx = y with y(0) = 1, because its exact solution is y = e^x, so y(1) is the number e, approximately 2.718281828 (value of e)). Because we know the true answer, every estimate can be checked.
What is Euler's method?
The textbook rule is x_n = x_0 + nh and y_n = y_(n-1) + h f(x_(n-1), y_(n-1)), where h > 0 is the step size (OpenStax Calculus Volume 2, section 4.2). In words: stand at a point, read the slope from the equation, walk a straight step of width h along that slope, and repeat.
Leonhard Euler first proposed the method in his book Institutionum calculi integralis, published 1768 to 1770 (Euler method).
For dy/dx = y the slope is just the current value of y, so each step multiplies y by (1 + h). After 1/h steps you reach x = 1 with the estimate (1 + h)^(1/h). That is the compound-interest expression whose limit is e, which is the story in our post on Jacob Bernoulli and the compound interest that led to e. If you want to see the same multiply-each-period idea worked through with money, read how the compound interest formula grows out of yearly steps.
How does step size affect Euler's method accuracy?
Here are three runs, each compared with e = 2.718281828 (value of e)).
h = 0.5: two steps, 1 to 1.5 to 2.25. The error is 0.468, about 17% of e.
h = 0.1: ten steps, each multiplying by 1.1, give 1.1^10 = 2.5937. The error is 0.125, about 4.6%.
h = 0.01: a hundred steps give 1.01^100 = 2.7048. The error is 0.0135, about 0.5%.
The steps went up 50 times, from 2 to 100, and the error went down about 35 times. Now run each step size and its half:
h = 0.5 gives 2.2500, error 0.4683; h = 0.25 gives 2.4414, error 0.2769. Ratio 1.69.
h = 0.1 gives 2.5937, error 0.1245; h = 0.05 gives 2.6533, error 0.0650. Ratio 1.92.
h = 0.01 gives 2.7048, error 0.0135; h = 0.005 gives 2.7115, error 0.0068. Ratio 1.99.
Euler's method is a first-order method: the error made in one step is approximately proportional to h squared, and the total error at a fixed point is approximately proportional to h (Euler method). The reason is counting. Each step adds an error of size about h squared, and you take 1/h steps, so the total is about h. In our runs, error divided by h rises from 0.94 to 1.35, heading for e/2, about 1.36.
Every estimate is below e. The curve y = e^x bends upward, so each straight step along a tangent line lands a little under the curve, and the next step starts from that lower point. Our explainer on why e^x is its own derivative shows that tangent picture.
How do you build the spreadsheet table?
This works in Excel, Google Sheets or LibreOffice.
Type the step size, 0.1, in cell E1.
In A2 type =(ROW()-2)*$E$1 for x. Building x this way avoids the 0.9999999 you get from adding 0.1 again and again.
Type 1 in B2 for y(0). In B3 type =B2+$E$1*B2, which is y_n = y_(n-1) + h times the slope.
In C2 type =EXP(A2) for the exact value and in D2 type =C2-B2 for the error.
Fill A and C, D down from row 2, and B down from row 3, until column A reads 1. That is 10 rows below the start for h = 0.1, 100 for h = 0.01.
Change E1, refill to x = 1, and write each error at x = 1 next to its h. Divide each error by the next one.
Does a smaller step always mean a better answer?
For this problem, yes, but you pay for it. Smaller h means more calculations, and larger h trades that saving for lower accuracy (OpenStax Calculus Volume 2, section 4.2). Because the error here is about 1.36h, getting it under 0.001 needs h near 0.0007, or roughly 1,400 steps to reach x = 1. Halving the step doubles the work and only halves the error, so when high accuracy matters, higher-order methods such as Runge–Kutta are used instead (Euler method).
Some people need to see the stepping before it sticks. The Fermi Simulation Lab has interactive simulations for the ideas that are easier to see than to read. If your own working keeps going wrong at the same line, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.
Open a blank sheet, put 0.1 in E1, and see whether you get 2.5937 at x = 1.



