Runge-Kutta Method (2nd Order, Second-Order ODE)
Convert y''=f(x,y,y') into a first-order system and solve it numerically with the 2nd-order Runge-Kutta method. Get y and y' at the end point, plus a solution curve and a table of every step.
Input
Example equations (tap to insert)
Variables are x (independent), y (solution), and v (= y', the slope). Operators: + - * / ^ (power). Functions: sin cos tan exp log (natural log) ln log10 sqrt abs pow(a,b), etc. Constants: pi (π), e.
Result
Approximate solution y at x = 10
y ≒ -0.333058
Slope there y' ≒ 0.189841
Steps
100 steps
Step size h = 0.1
Initial conditions
y(0) = 1
y'(0) = 0
Solution at end point
y = -0.3331
y' = 0.1898
Solution trace (excerpt)
| x | y | y' (= v) |
|---|---|---|
| 0 | 1 | 0 |
| 0.8 | 0.711093 | -0.663591 |
| 1.7 | -0.019739 | -0.840923 |
| 2.5 | -0.572066 | -0.47327 |
| 3.3 | -0.72085 | 0.105891 |
| 4.2 | -0.386692 | 0.570002 |
| 5 | 0.103275 | 0.58628 |
| 5.8 | 0.462488 | 0.270557 |
| 6.7 | 0.490978 | -0.197022 |
| 7.5 | 0.218389 | -0.439761 |
| 8.3 | -0.136527 | -0.399268 |
| 9.2 | -0.374116 | -0.101006 |
| 10 | -0.333058 | 0.189841 |
y' = -y - 0.2*v is rewritten as the system y' = v, v' = f(x, y, v) and integrated step by step with the 2nd-order Runge-Kutta method.
How it works
- A second-order equation y''=f(x,y,y') is solved by tracking the solution y and its slope y' (written as v) together as a first-order system. The expression may use three variables: the independent variable x, the solution y, and the slope v (=y').
- Enter the right-hand side, the initial point x0, the initial value y(x0), the initial slope y'(x0), the step size h, and the end point x_end, and the approximate y and y' at the end point are shown prominently.
- Smaller step sizes h give higher accuracy but increase the number of steps and the computation cost. If the result oscillates or diverges, try reducing h first.
- You can include functions such as sin, cos, exp, log, and sqrt, as well as constants like pi (the circle constant) and e (the base of the natural logarithm). The two-argument pow(a,b) is also supported.
- Quickly check the behavior of equations of motion that appear often in physics, such as simple harmonic motion y''=-y, damped oscillation y''=-y-0.2y', and forced oscillation with an external force.
- The displayed table is a thinned-out excerpt of the computation steps, and the solution-curve graph also marks the positions of the initial point and the end point.
Related calculators
Function Graph Plotter f(x)
NumericalType an expression such as sin(x) or x^2-2 and instantly plot its graph over a chosen x range. Maximum, minimum, zeros, and sample point values are shown alongside.
Open calculator →Graph Two Functions f(x) and g(x)
NumericalPlot two expressions f(x) and g(x) on the same axes in distinct colors, and automatically find their max, min, and intersection points.
Open calculator →Data Point f(x) Graph Plotter
NumericalJust paste your (x, y) data points to instantly draw a line-and-point chart. See the point count plus the minimum, maximum, and average of y at the same time.
Open calculator →Plot Data Points f(x), g(x)
NumericalPaste two sets of (x, y) data points and get f(x) and g(x) drawn as color-coded overlaid line graphs, with each series' point count and min/max.
Open calculator →