Percentages and Math

Differential Equation Solver

Type the slope y' as a function of x and y, a starting value and an end point to follow the solution step by step.

Your numbers

Use x and y, + - * / ^, parentheses and functions such as sin, cos, exp, ln, sqrt. Radians. Example function.

The value of y at the starting x.

The step size is the distance from start to end divided by this. Up to 2,000.

If you know the exact answer, errors are measured against it. Otherwise errors are measured against Runge-Kutta 4 with 10 times as many steps.

More options

Result

y at x = 1 (Runge-Kutta 4)

3.436559488

10 steps of size 0.1.

y at the end, Runge-Kutta 4
3.436559488
y at the end, Euler
3.18748492
Exact y at the end
3.436563657
Step size
0.1

Value at the end by method

MethodOrdery at the endError
Euler13.187484920.2491
Midpoint23.4281616930.008402
Heun23.4281616930.008402
Runge-Kutta 443.4365594884.169e-6

Steps of the Runge-Kutta 4 method

xyExact yError
0110
0.11.1103416671.1103418361.695e-7
0.21.2428051421.2428055163.746e-7
0.31.3997169941.3997176156.21e-7
0.41.583648481.5836493959.151e-7
0.51.7974412771.7974425411.264e-6
0.62.0442359242.0442376011.677e-6
0.72.3275032532.3275054152.162e-6
0.82.6510791272.6510818572.73e-6
0.93.0192028283.0192062223.395e-6
13.4365594883.4365636574.169e-6
How this was calculated
  1. The step size is h = (1 - 0) / 10 = 0.1.
  2. Euler moves along the slope at the start of each step: y_next = y + h f(x, y). Midpoint and Heun average slopes within the step, and Runge-Kutta 4 blends four slopes: y_next = y + h/6 (k1 + 2 k2 + 2 k3 + k4).
  3. Runge-Kutta 4 gives 3.436559488 at x = 1; the error against the exact solution is 4.169e-6.
  • Errors are measured against the exact solution. A small error at the end does not prove the whole path is accurate, so check the table of steps too.

Calculated using SumPanda.com · https://sumpanda.com/ode-solver-euler-rk4-calculator/

Results are estimates for general information. Verify important figures before relying on them.

Next step

How to use the differential equation solver

  1. Type the slope y' = f(x, y) using x and y, operators + - * / ^, parentheses and functions such as sin, cos, exp, ln and sqrt (angles in radians).
  2. Enter the starting x and starting y, the ending x and the number of steps. The step size is the distance from start to end divided by the number of steps.
  3. If you know the exact solution, type it as a function of x. The page then measures each method's error against it. If not, errors are measured against Runge-Kutta 4 with ten times as many steps.
  4. Read the comparison table of the four methods, then the steps of the method chosen under Advanced options.

Formula

Euler: y_next = y + h f(x, y)

Midpoint: y_next = y + h f(x + h/2, y + (h/2) f(x, y))

Heun: y_next = y + (h/2) (f(x, y) + f(x + h, y + h f(x, y)))

Runge-Kutta 4: y_next = y + (h/6) (k1 + 2 k2 + 2 k3 + k4)

Each method moves from one point to the next using slopes. Euler uses one slope, midpoint and Heun use two, and Runge-Kutta 4 blends four. A method of order p has an error that falls by about 2^p when the step is halved.

y' = x + y with y(0) = 1, from 0 to 1 in 10 steps

The exact solution is y = 2e^x - x - 1, so y(1) = 2e - 2 = 3.436563657. Euler gives 3.18748492, an error of 0.2491. Midpoint and Heun both give 3.428161693, an error of 0.0084. Runge-Kutta 4 gives 3.436559488, off by only 4.2e-6.

Halving the step to 20 would cut the Euler error roughly in half and the Runge-Kutta 4 error by a factor of about sixteen. With y' = y from 0 to 1 in 5 steps, Runge-Kutta 4 gives 2.7182511, close to e = 2.7182818.

Choosing a method and a step

Euler is the simplest and the least accurate, and it is mainly useful for seeing how stepping works. Runge-Kutta 4 gives far more accuracy for the same number of steps and is the usual choice for smooth problems. Smaller steps always help, until the number of steps becomes the limit; this page allows up to 2,000.

The error column is the difference at the end point only. The path can be less accurate in the middle, so look at the table of steps when you have the exact solution to compare against.

When the method fails

Some equations grow without bound at a finite x, like y' = y squared from y(0) = 1, which blows up at x = 1. The page stops and tells you when a value stops being finite. Stiff equations, with very different time scales, need much smaller steps or other methods. For finding where a curve crosses a value use the Root Finder, for areas under a curve the Numerical Integration Calculator, and for plotting the Graphing Calculator.

More math tools

For significant figures, complex numbers, polynomials, repeating decimals and shortest paths, try the Shortest Path Calculator, Significant Figures Calculator and Complex Number Calculator.

Assumptions and limits

  • The equation is a first-order equation y' = f(x, y) with one starting value.
  • The step size is constant, equal to the span divided by the number of steps.
  • Trigonometric functions use radians.
  • Without an exact solution, the reference is Runge-Kutta 4 with ten times as many steps, which is accurate but not exact.
  • The example equation is an illustration. Replace it with your own.

Formulas reviewed October 10, 2026. See the calculation methodology for how SumPanda rounds, tests and sources its formulas.

Frequently asked questions

Why do Midpoint and Heun give the same number in the example?

For a slope that is linear in y, as in y' = x + y, the two second-order methods turn out to take identical steps. For other equations they differ slightly.

How many steps should I use?

Start with 10 or 20 and double until the answer stops changing in the digits you need. For smooth problems Runge-Kutta 4 converges quickly.

Can I solve a second-order equation?

Not directly. Rewrite it as two first-order equations, which this page does not handle. It solves one equation for one unknown function.

Why is the error sometimes tiny but the table looks wrong?

The error is shown at the final point. If the exact solution is off or the equation has a sharp feature in the middle, the end can still look fine. Compare the steps column with the exact values.