Runge-Kutta (RK4) ODE Solver

Solve y′ = f(x, y) with the classical fourth-order Runge–Kutta method and get an error estimate.

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

…

How to do it

  1. 1
    Step 1: Open Runge-Kutta (RK4) ODE 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 Runge-Kutta (RK4) ODE Solver does

    Solve y′ = f(x, y) with the classical fourth-order Runge–Kutta method and get an error estimate.

  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 values and the end x. The calculator applies RK4 with the number of steps you choose, lists the solution and estimates the error by comparing with the result at half the step size (Richardson estimate).

Method

Each step uses four slopes: k1 at the start, k2 and k3 at the midpoint, k4 at the end, and y ← y + h(k1 + 2k2 + 2k3 + k4) ÷ 6.

Error estimate

The tool also solves with half the step. For a fourth-order method the difference divided by 15 estimates the error of the coarser result. It is a fixed-step solver; adaptive step control (Dormand–Prince) is not included. 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.

Worked example

y′ = y − x² + 1, y(0) = 0.5 up to x = 2 with 10 steps gives 5.30536; the exact value is 5.30547, and the estimated error is about 1e-4.

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 error estimate?

|y(h/2) − y(h)| ÷ 15 for a fourth-order method.

Is the step adaptive?

No, it uses a fixed number of steps.

How many steps?

1 to 100,000.

What if the solution blows up?

The values become huge or undefined; use fewer steps in a smaller interval.

Guides for this tool

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