Euler, Heun and RK4 Differential Equation Solver

Solve y′ = f(x, y) numerically with Euler's method, Heun's method and RK4 and compare them.

Runs in your browser. Your files never leave your device. See how to check

…

How to do it

  1. 1
    Step 1: Open Euler, Heun and RK4 Differential Equation Solver and add your input

    Type your numbers or text, add your file, or pick the options you need. Nothing is uploaded: everything stays in your browser.

  2. 2
    Step 2: What Euler, Heun and RK4 Differential Equation Solver does

    Solve y′ = f(x, y) numerically with Euler's method, Heun's method and RK4 and compare them.

  3. 3
    Step 3: Read the result and compare

    The result appears at once. Change one value to see how the answer moves, then keep the figure that fits your case.

  4. 4
    Step 4: Copy or save it

    Copy the result or download it. For an important decision, confirm it with the official source or an adviser.

About this tool

Enter f(x, y), the starting point (x0, y0), the end x and the number of steps. The calculator solves the initial value problem three ways and lists the values side by side, with the error of Euler's method against a fine RK4 reference.

Methods

Euler: y ← y + h f(x, y), first order. Heun (improved Euler): averages the slopes at both ends of the step, second order. RK4: the classical fourth-order Runge–Kutta method with four slope evaluations per step.

Accuracy

Halving the step roughly halves Euler's error, quarters Heun's and divides RK4's by 16. The reference is RK4 with at least 20 times as many steps. Write the function with x, + − * / ^, parentheses, and sin, cos, tan, asin, acos, atan, exp, ln, log (base 10), sqrt, abs, sinh, cosh, tanh, pi and e. Implicit multiplication such as 2x or 3(x+1) works. Use y for the unknown.

Worked example

For y′ = x + y with y(0) = 1 the exact value at x = 1 is 3.43656. With 10 steps Euler gives 3.18, Heun 3.4177 and RK4 3.4365.

Tips for best results

Check every box before you rely on a result, because one wrong digit changes the whole answer. Use the exact figures from your payslip, bill, certificate or contract, and keep a note of the date you calculated. Rates, thresholds and rules change from time to time, so for tax, fees and legal matters treat the output as an estimate and confirm with the official source named on this page. You can run as many scenarios as you like; nothing is saved or sent, and refreshing the page clears the boxes.

Quick facts

Embed this calculator on your site

Copy this code to show the calculator on your own page. A link back to shobfree.com is included.

Frequently asked questions

What is the difference between the methods?

Higher order methods are far more accurate for the same step size.

How do I enter y′ = x + y?

Type x + y in the f(x, y) box.

How many steps?

1 to 100,000.

Is the reference exact?

No, it is a very fine RK4 solution.

Guides for this tool

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages