Euler's Method Calculator

Solve dy/dx = a·x + b·y + c with Euler's method: a step-by-step table for step size h and n steps, compared with the exact solution.

The equation is dy/dx = a·x + b·y + c.
Must be greater than 0. Smaller steps are more accurate.
A whole number from 1 to 10,000. The last x is x₀ + n·h.

Results

Euler estimate of y at the last step
3.1875
y(1) after 10 steps of size 0.1.
Exact solution at the same x
3.4366
Error (exact − Euler)
0.249079
Relative error
7.2479 %
Exact solution
y = 2·e^x − x − 1
Problem
dy/dx = x + y, y(0) = 1, h = 0.1, 10 steps
Step-by-step table
n | xₙ | yₙ (Euler) | exact y(xₙ) | error 0 | 0 | 1 | 1 | 0 1 | 0.1 | 1.1 | 1.110341836 | 0.01034183615 2 | 0.2 | 1.22 | 1.242805516 | 0.02280551632 3 | 0.3 | 1.362 | 1.399717615 | 0.03771761515 4 | 0.4 | 1.5282 | 1.583649395 | 0.05544939528 5 | 0.5 | 1.72102 | 1.797442541 | 0.0764225414 6 | 0.6 | 1.943122 | 2.044237601 | 0.1011156008 7 | 0.7 | 2.1974342 | 2.327505415 | 0.1300712149 8 | 0.8 | 2.48717762 | 2.651081857 | 0.163904237 9 | 0.9 | 2.815895382 | 3.019206222 | 0.2033108403 10 | 1 | 3.18748492 | 3.436563657 | 0.2490787367

How it’s calculated

Euler's method follows the slope of a differential equation in small straight steps. Starting from (x₀, y₀), each step moves h to the right and uses the slope at the current point to predict the next y.

xₙ = x₀ + n·h yₙ = yₙ₋₁ + h × f(xₙ₋₁, yₙ₋₁) here f(x, y) = a·x + b·y + c

Because dy/dx = a·x + b·y + c is a first-order linear equation, its exact solution is known, so the calculator shows how far Euler's estimate is off at each step:

b ≠ 0: y = K·e^(b(x − x₀)) − (a/b)·x − (a + b·c)/b², K = y₀ + (a/b)·x₀ + (a + b·c)/b² b = 0: y = y₀ + (a/2)(x² − x₀²) + c(x − x₀)

(For b ≠ 0, try y = Px + Q: matching terms gives P = −a/b and Q = −(a + bc)/b², and adding K·e^(b(x − x₀)), the solution of y′ = b·y, lets y(x₀) = y₀. For b = 0 the right side does not involve y, so just integrate.) Euler's error at a fixed x shrinks roughly in proportion to h: halve the step, roughly halve the error.

Example: dy/dx = x + y with y(0) = 1, h = 0.1, 10 steps. y₁ = 1 + 0.1 × (0 + 1) = 1.1; y₂ = 1.1 + 0.1 × (0.1 + 1.1) = 1.22; y₃ = 1.362; … y₁₀ ≈ 3.187485. The exact solution is y = 2eˣ − x − 1, so y(1) = 2e − 2 ≈ 3.436564, and Euler is about 0.249 too low.

Frequently asked questions

How do I make Euler’s method more accurate?

Use a smaller step size h (and more steps to reach the same x). The error at a fixed point is roughly proportional to h, so halving h about halves the error.

Why does Euler’s method underestimate here?

When the solution curves upward (concave up), each tangent-line step falls below the curve, and the errors build up. For a concave-down solution it overestimates.

Can I enter a different equation?

This calculator handles dy/dx = a·x + b·y + c, which has an exact solution to compare against. Set any of a, b, c to 0 as needed, for example b = 1, a = c = 0 gives dy/dx = y.

Can the method blow up?

Yes. With b negative and a large step (h·|b| > 2) the Euler values oscillate and grow even though the true solution decays. Reduce h if the table swings wildly.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator