Euler's Method Calculator
Type the right-hand side of y' = f(t, y), a starting point, a step h and an end time, and the page runs Euler's method and classical RK4 on the same grid, draws both over a slope field and lists every step in a table. Give an exact solution and each row shows both errors; leave it out and the page shows how far Euler and RK4 disagree. Three things here are deliberate. A value of f that is not finite stops that method at that step and the notes name the t and y that produced it, so the pole example y' = 1/(1 - t) stops Euler at t 1 instead of drawing a line through the pole. Every step is checked against the method's linear stability limit, so y' = -15y at h 0.15 is flagged as past Euler's limit of -2 while RK4 stays inside its limit of -2.785. And each method is rerun at h/2 to show how far its end value moves: for y' = y from y(0) = 1 to t 1 at h 0.1, Euler's end value moves by about 0.06 and RK4's by about 0.000002. Formulas are read by a small parser written for this page, never run as code, and a run is limited to 10,000 steps per method.
y' = y from t 0 to 1 with h 0.1, 10 steps. Euler (amber) ends at y(1) = 2.5937425 and RK4 (teal) ends at 2.7182797; the exact solution (dashed) gives 2.7182818, so Euler is off by 0.12453937 and RK4 by 2.0843239e-6. 273 slope-field segments show slopes from 0.939 to 2.78 across the view. The plot shows t from 0 to 1 and y from 0.8625 to 2.856.
Showing the example: Exponential growth. Change a value and press Solve to run your own equation.
- Euler y(1)
- 2.5937425
- RK4 y(1)
- 2.7182797
- Exact y(1)
- 2.7182818
- Euler error at end
- 0.12453937
- RK4 error at end
- 2.0843239e-6
- Steps
- 10 of 10,000 max
Notes on this run
No stops, stability warnings, shortened steps or clipped paths in this run.
Method comparison
Error is the distance from the exact solution on the grid, when you give one. The h/2 column reruns each method with half the step to the same end and gives how far its end value moves. The stability column compares h times a numerical estimate of the slope of f in y with -2 for Euler and -2.785 for RK4.
| Method | y at t 1 | Error at end | Largest error | Change with h/2 | Stability check |
|---|---|---|---|---|---|
| Euler | 2.5937425 | 0.12453937 | 0.12453937 at t 1 | 0.059555245 | within the limit at all 10 checked steps |
| RK4 | 2.7182797 | 2.0843239e-6 | 2.0843239e-6 at t 1 | 1.9485212e-6 | within the limit at all 10 checked steps |
Step table
Every step of both methods on the same grid. The Euler slope is the value of f(t, y) that step used, so the last row has none. A blank Euler or RK4 cell means that method had already stopped. Download CSV for every row at full precision.
| Step | t | Euler y | Euler slope f(t, y) | RK4 y | Exact y | Euler error | RK4 error | Euler minus RK4 |
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
| 1 | 0.1 | 1.1 | 1.1 | 1.1051708333 | 1.1051709181 | 0.0051709180756 | 8.4742314499e-8 | -0.0051708333333 |
| 2 | 0.2 | 1.21 | 1.21 | 1.2214025709 | 1.2214027582 | 0.01140275816 | 1.8730947549e-7 | -0.011402570851 |
| 3 | 0.3 | 1.331 | 1.331 | 1.3498584971 | 1.3498588076 | 0.018858807576 | 3.1051346561e-7 | -0.018858497063 |
| 4 | 0.4 | 1.4641 | 1.4641 | 1.4918242401 | 1.4918246976 | 0.027724697641 | 4.5756058475e-7 | -0.027724240081 |
| 5 | 0.5 | 1.61051 | 1.61051 | 1.6487206386 | 1.6487212707 | 0.0382112707 | 6.3210329015e-7 | -0.038210638597 |
| 6 | 0.6 | 1.771561 | 1.771561 | 1.8221179621 | 1.8221188004 | 0.050557800391 | 8.3829857589e-7 | -0.050556962092 |
| 7 | 0.7 | 1.9487171 | 1.9487171 | 2.0137516266 | 2.0137527075 | 0.06503560747 | 1.0808736999e-6 | -0.065034526597 |
| 8 | 0.8 | 2.14358881 | 2.14358881 | 2.2255395633 | 2.2255409285 | 0.081952118492 | 1.3652001525e-6 | -0.081950753292 |
| 9 | 0.9 | 2.357947691 | 2.357947691 | 2.4596014138 | 2.4596031112 | 0.10165542016 | 1.6973768791e-6 | -0.10165372278 |
| 10 | 1 | 2.5937424601 | 2.7182797441 | 2.7182818285 | 0.12453936836 | 2.0843238793e-6 | -0.12453728404 |
Slope field values: f(t, y) at 273 points
| y down, t across | 0.02381 | 0.07143 | 0.119 | 0.1667 | 0.2143 | 0.2619 | 0.3095 | 0.3571 | 0.4048 | 0.4524 | 0.5 | 0.5476 | 0.5952 | 0.6429 | 0.6905 | 0.7381 | 0.7857 | 0.8333 | 0.881 | 0.9286 | 0.9762 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 | 2.779 |
| 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 | 2.626 |
| 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 | 2.472 |
| 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 | 2.319 |
| 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 | 2.166 |
| 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 | 2.012 |
| 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 | 1.859 |
| 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 | 1.706 |
| 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 | 1.552 |
| 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 | 1.399 |
| 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 | 1.246 |
| 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 | 1.093 |
| 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 | 0.9392 |
Examples
- y' = y
- y' = t - y
- y' = y(1 - y)
- y' = -15y
- y' = 1/(1 - t)
- y' = y - t
Worked checks
Computed by this page from the same functions that solve your equation.
- y(0.1) = 1.1
- y(0.1) = 1.1051708333
- Euler stops at t 1: f is infinite; RK4 stops on the step from t 0.5
What f(t, y) can contain
t and y (x is read as t), numbers such as 2, 0.5 or 1e-3, the signs + - * / and ^ (or **), brackets, the constants pi, tau and e, and these functions: sin, cos, tan, sec, csc, cot, asin, acos, atan, sinh, cosh, tanh, exp, ln, log10, log2, sqrt, cbrt, abs, sign, floor, ceil, round, min and max. ln is the natural log; log alone is refused because it could mean base 10. Multiplication can be left out where it is clear, so 2ty, 3(y + 1) and y exp(t) all work; when the reading differs from what you typed, a line under the field shows it.
Common questions
- How does Euler's method work?
- From the starting point it takes the slope f(t0, y0), walks one step h along that slope to y1 = y0 + h f(t0, y0), and repeats from the new point. For y' = y with y(0) = 1 and h = 0.1 the first step gives y(0.1) = 1 + 0.1 x 1 = 1.1, and ten steps reach 2.5937425 at t 1, where the true value is e = 2.7182818. The step table shows the slope each Euler step used in its own column, so you can check every line by hand.
- What is RK4, and why is it so much closer?
- Classical fourth-order Runge-Kutta samples the slope four times per step, once at the start, twice at the midpoint and once at the end, and averages them with weights 1, 2, 2 and 1. On the same y' = y problem its first step gives 1.1051708333 against e^0.1 = 1.1051709181, and at t 1 it is off by about 2.1e-6 where Euler is off by 0.12. For smooth problems halving h cuts Euler's error roughly in half and RK4's roughly sixteen times; the h/2 column of the method comparison shows how far each end value moves for your own equation.
- Why did the calculation stop partway?
- Because f had no finite value at a point the method needed, or the next y was too large for a double-precision number. 1/(1 - t) has no value at t 1, so with y(0) = 0 and h 0.5 Euler stops at t 1, and RK4 stops on the step from t 0.5 because its fourth stage needs f at t 1. The rows before the stop are kept, nothing is drawn or written after it, the notes give the exact t and y, and the readout says stopped instead of showing an end value.
- What does the stability warning mean?
- For a decaying equation such as y' = -15y, explicit Euler only damps errors while h times the slope of f in y stays at or above -2, and RK4 has room down to about -2.785. The page estimates that slope numerically at every step and counts the steps past each limit. At h 0.15, h times -15 is -2.25, so Euler is flagged at all 10 steps: its values flip sign and grow, ending at 9.3132257 where the exact value is about 1.7e-10, while RK4 stays within its limit. The check is based on the linearised equation, so it marks where a method amplifies errors rather than proving anything about the true solution.
- Do I need to know the exact solution?
- No. Leave that field empty and the page compares Euler with RK4 instead: the readout shows Euler minus RK4 at the end, and the h/2 column shows how far each method moves when the step is halved. If you do give one, write it as a formula in t, such as t - 1 + 2exp(-t) for y' = t - y with y(0) = 1. The page checks that it starts at your y0 and says so in the notes when it does not.
- What can I type for f(t, y)?
- t, y, numbers, + - * / ^, brackets, the constants pi, tau and e, and 25 functions: sin, cos, tan, sec, csc, cot, asin, acos, atan, sinh, cosh, tanh, exp, ln, log10, log2, sqrt, cbrt, abs, sign, floor, ceil, round, min and max. x is read as t, so textbook forms such as y' = x + y work. arcsin, arccos and arctan are read as asin, acos and atan. Multiplication can be left out, so 2ty means 2 * t * y, and for a formula of ordinary length the page prints how it read it under the field when that differs from what you typed. The text is read by a small parser written for this page and never run as code, so any other name is refused with a message.
- How many steps can it take?
- Up to 10,000 steps per method in one run, so h must be at least the length of the interval divided by 10,000; a smaller h is refused with the step count it would need and the smallest h that fits. When h does not divide the interval evenly, the last step is shortened so the run ends exactly at your end time, and the notes say so. A very long formula combined with many steps can also be refused, with the number of operations it would need. The step table shows 200 rows at a time with buttons to page through them, and the CSV holds every row.
- What are the extra starting values for?
- They show how nearby solutions behave. Each value becomes another RK4 path from t0 on the same grid, drawn over the slope field, and up to 8 are allowed. In the Nearby starts example, y' = y - t has the straight-line solution y = t + 1 from y(0) = 1, and starts of 0.8, 0.9, 1.1 and 1.2 bend away from it on either side, ending at 1.522191, 2.2610955, 3.7389045 and 4.477809 at t 2.
- Can I save the results?
- Download CSV gives every row at full precision: step, t, Euler y and the slope it used, RK4 y, the exact value and both errors when you gave an exact solution, Euler minus RK4, and a column for each extra start, with the equation, settings and notes as comment lines at the top. Download SVG gives the plot with the equation written above it and the text description embedded. Both are built in your browser from the run on screen, and after an edit they wait until you press Solve.
Euler and RK4 values are numerical approximations to the equation you type, not physical or safety predictions. Points where f is not finite, steps past each method's linear stability limit and the 10,000-step limit are reported where they occur.