Euler Method Calculator

Type y' = f(x, y), the starting point, the step size and the end value.

Write y' = f(x, y), such as y' = x + y, or just the right side.

The starting value of x.

The value of y at the start.

The step size, more than 0. The distance from x₀ to the end must be a whole number of steps.

The value of x to stop at, more than x₀. At most 1000 steps.

Try

Result

You enteredy′=x+y,y(0)=1, h=0.1y' = x + y,\quad y(0) = 1,\ h = 0.1

y(0.5)≈1.72102\displaystyle y(0.5) \approx 1.72102

Exact solution

y=2ex−x−1\displaystyle y = 2e^{x} - x - 1

Exact value

y(0.5)=1.797443\displaystyle y(0.5) = 1.797443

Error

∣error∣=0.076423\displaystyle |\text{error}| = 0.076423
Show the work
  1. Euler's method

    Follow the tangent line for a short step hh: from (xn,yn)(x_n, y_n) the slope is f(xn,yn)f(x_n, y_n), so yy grows by hh times that slope.

    Using yn+1=yn+hf(xn,yn)y_{n+1} = y_n + h f(x_n, y_n)

    yn+1=yn+h f(xn,yn)xn+1=xn+h\begin{gathered} y_{n+1} = y_n + h\,f(x_n, y_n) \\ x_{n+1} = x_n + h \end{gathered}
  2. First step

    Start at (x0,y0)=(0,1)(x_0, y_0) = (0, 1) with h=0.1h = 0.1; there are 55 steps to x=0.5x = 0.5.

    y1=1+0.1⋅f(0,1)=1+0.1⋅1=1.1\begin{aligned} y_1 &= 1 + 0.1\cdot f(0, 1) \\ &= 1 + 0.1\cdot 1 \\ &= 1.1 \end{aligned}
  3. Table of steps

    Every step.

    nxnyn00110.11.120.21.2230.31.36240.41.528250.51.72102\begin{array}{ccc} n & x_n & y_n \\ \hline 0 & 0 & 1 \\ 1 & 0.1 & 1.1 \\ 2 & 0.2 & 1.22 \\ 3 & 0.3 & 1.362 \\ 4 & 0.4 & 1.5282 \\ 5 & 0.5 & 1.72102 \end{array}
  4. Compare with the exact solution

    This equation has an exact solution, so the numerical value can be checked: y=2ex−x−1y = 2e^{x} - x - 1 gives y(0.5)=1.797443y(0.5) = 1.797443, an error of 0.0764230.076423.

    y(0.5)=1.797443∣error∣=0.076423\begin{gathered} y(0.5) = 1.797443 \\ |\text{error}| = 0.076423 \end{gathered}
  5. Result

    The value after 55 steps.

    y(0.5)≈1.72102y(0.5) \approx 1.72102

Worked examples