Runge-Kutta 4 (prévia)
- Created by
- Renato Passos, Eng. de Software
- Reviewed by
- Renato Passos, Eng. de Software
Last updated: Apr 18, 2026
Formula
RK4 simplificado
About this calculator
This calculator implements a simplified version of the fourth-order Runge-Kutta method (RK4) for numerically solving first-order ordinary differential equations. RK4 is one of the most popular methods for approximating ODE solutions, offering a good balance between accuracy and computational simplicity. It uses a weighted average of four slopes (k1, k2, k3, k4) to estimate the next function value, reducing the local truncation error to O(h^5).
The basic operation is: given an ODE dy/dt = f(t, y) and an initial condition y(t0) = y0, the calculator computes the coefficients k1 = f(tn, yn), k2 = f(tn + h/2, yn + h*k1/2), k3 = f(tn + h/2, yn + h*k2/2), k4 = f(tn + h, yn + h*k3). Then the next value is yn+1 = yn + (h/6)*(k1 + 2*k2 + 2*k3 + k4). The user must provide the function f(t, y), the step size h, the time interval, and the initial condition.
Use this tool for quick approximations in engineering, physics, or applied mathematics problems, such as simulating dynamic systems, electrical circuits, population growth, or radioactive decay. It is useful when the analytical solution is difficult or impossible to obtain. Note that the method is explicit and may become unstable for large step sizes in stiff problems.
Caution: the simplified RK4 presented here assumes a first-order ODE and that the user inputs the function correctly. For systems of ODEs or higher-order equations, the method must be adapted. Additionally, the accumulated error depends on the step size h: smaller steps increase accuracy but require more iterations. Always check stability and, if possible, compare with known solutions.
Frequently asked questions
What is the difference between RK4 and Euler's method?
Euler's method uses only one slope (derivative at the current point), resulting in O(h^2) error. RK4 uses four weighted slopes, reducing error to O(h^5) and being much more accurate for the same step size.
Can I use this calculator for systems of differential equations?
Not directly. This simplified version solves only first-order ODEs. For systems, you would need a vectorized implementation of RK4.
What does 'step size h' mean and how do I choose it?
The step size h is the time increment per iteration. Choose a value small enough for accuracy (e.g., 0.01) but not so small that it makes computation slow. Test with different h values to check stability.
Can RK4 be unstable?
Yes, for stiff problems or large step sizes, explicit RK4 can become unstable. In such cases, implicit methods or smaller steps are recommended.
How do I input the function f(t,y) in the calculator?
Enter the expression using t and y as variables. For example, for dy/dt = -2*y, type '-2*y'. Use '*' for multiplication and '**' for exponentiation.