ForHosting KIT · Developer Utilities

Runge-Kutta 4 single-step calculator

This Runge-Kutta 4 single-step calculator advances a first-order differential equation from one known point to the next.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Enter the derivative as f(x, y), the starting coordinates, and a nonzero step size. The result shows k1, k2, k3, and k4 as slope estimates, the intermediate points where they are evaluated, their weighted average, and the final RK4 approximation. That complete trail makes the calculator useful for checking homework, validating a numerical solver, or documenting one step without hiding the arithmetic.

Describe the initial-value problem clearly

Start with a first-order equation written as y' = f(x, y). In the expression field, enter only the right-hand side, using x and y as the independent and dependent variables. For example, if y' = x + y, enter x + y. The parser supports ordinary arithmetic, parentheses, powers written with ^, the constants pi and e, and common functions such as sin, cos, exp, log, and sqrt. Then provide the known point (x, y) and the step size h. A positive h advances to the right, while a negative h performs the same RK4 construction backward. The step size cannot be zero because that would not advance the solution. All numeric inputs and every function value must remain finite. Multiplication must be explicit, so write 2*x rather than 2x. This precise input format prevents an equation label or implicit multiplication from being interpreted in an unintended way and keeps the four evaluations reproducible.

Follow the four slope estimates

The calculator reports k1 through k4 as slopes, following the convention k1 = f(x, y), rather than as increments already multiplied by h. First, k1 uses the initial point. The second estimate uses the midpoint x + h/2 and predicts its y-coordinate with h*k1/2. The third estimate stays at the midpoint but replaces that prediction with h*k2/2, which corrects the direction using the second slope. Finally, k4 evaluates the derivative at x + h with a full-step y prediction based on k3. The returned k2_point, k3_point, and k4_point fields expose those evaluation coordinates directly. This matters because textbooks sometimes use the same k symbols for h times each slope. If your source follows that alternative convention, multiply each reported k value by h before comparing individual stages. The final y approximation is unchanged when the corresponding formula is used consistently.

Interpret the weighted update and its limits

RK4 combines the slopes as (k1 + 2*k2 + 2*k3 + k4)/6, giving the two midpoint estimates twice the weight of the endpoint estimates. The calculator returns this quantity as weighted_slope, then computes y_next = y + h*weighted_slope and x_next = x + h. One RK4 step is fourth-order accurate in the standard local sense for a sufficiently smooth derivative, but that statement is not a guarantee that any chosen step size is small enough. A rapidly changing, singular, discontinuous, or stiff problem may require a much smaller h or a method with error control. This tool deliberately performs exactly one fixed step; it does not estimate truncation error, adapt the step size, or solve across an interval. To assess sensitivity, compare one step of size h with two successive steps of size h/2 in a full solver. Use the displayed stages to locate differences caused by expression entry, rounding, or slope convention.

Check a textbook exercise

Verify every intermediate RK4 slope and the next y approximation instead of comparing only a final number.

Debug a numerical solver

Compare one known step, including its midpoint states, with an implementation in a spreadsheet, script, or simulation.

Document an engineering calculation

Record the four deterministic derivative evaluations and weighted update used to advance a model by one step.

What does one calculation cost through the API?

One API request costs $0.002. The browser calculator runs locally and is free to use.

Are k1, k2, k3, and k4 slopes or increments?

They are slopes: direct values of f(x, y). Multiply each by h if your reference defines each k as an increment.

Can the step size be negative?

Yes. A finite negative step size applies the same RK4 formulas to advance toward a smaller x value.

Which expression syntax is supported?

Use x, y, numbers, pi, e, parentheses, +, -, *, /, ^, and supported single-argument functions such as sin, cos, exp, log, and sqrt.

Does this solve the differential equation over an interval?

No. It performs exactly one fixed RK4 step from the supplied initial point and does not choose a step size or estimate error.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/calculus/rk4-single-step

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/calculus/rk4-single-step \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"expression":"x + y","x":0,"y":1,"step_size":0.1}'
{
  "expression": "x + y",
  "x": 0,
  "y": 1,
  "step_size": 0.1
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "calculus.rk4_single_step",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_chars500
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →