Connect via MCP →

Enter Calculation

Right-hand side of y'' = F(x, y, y'). Use x, y, p and + - * / ^, sin, cos, exp, log, sqrt, pi, e.

Formula

Advertisement

Results

y at xn
0.135335274181834636
value of y at the end point
y' at xn
-0.135335259156935755
value of y' (= p) at the end point

Method: classic 4th-order Runge-Kutta (RK4) · steps n = 50 · step size h = 0.02

i x y = f(x) y' = p
0 0 0 1
1 0.0200000000000000004 0.0192157866666666649 0.922357866666666637
2 0.0400000000000000008 0.0369246498212522645 0.849267048373009037
3 0.0599999999999999978 0.0532152204359356007 0.780489998192799184
4 0.0800000000000000017 0.0681714957894921647 0.715800800394514436
5 0.100000000000000006 0.0818730665794356605 0.654984623530822985
6 0.119999999999999996 0.0943953333479264356 0.597837198534814762
7 0.140000000000000013 0.105809712710295489 0.544164320702777649
8 0.160000000000000003 0.116183833853126500 0.493781374492720526
9 0.179999999999999993 0.125581725747898248 0.446512880115091604
10 0.200000000000000011 0.134063995506174150 0.402192060937331175
11 0.220000000000000001 0.141687998283193534 0.360660430767116402
12 0.239999999999999991 0.148507999118433237 0.321767400120490987
13 0.260000000000000009 0.154575327084229969 0.285369900620602468
14 0.280000000000000027 0.159938522096849084 0.251332026710574419
15 0.299999999999999989 0.164643474728420641 0.219524693900195078
16 0.320000000000000007 0.168733559342904987 0.189825312800676715
17 0.340000000000000024 0.172249760864668727 0.162117478234802465
18 0.359999999999999987 0.175230795474316581 0.136290672741392865
19 0.380000000000000004 0.177713225513107781 0.112239983823256881
20 0.400000000000000022 0.179731568864560570 0.0898658343166999773
21 0.419999999999999984 0.181318403069687717 0.0690737252883046882
22 0.440000000000000002 0.182504464420687129 0.0497739908911289108
23 0.460000000000000020 0.183318742266808804 0.0318815646377390433
24 0.479999999999999982 0.183788568755511195 0.0153157565716578320
25 0.5 0.183939704221884465 4.08419086883604621E-8
26 0.520000000000000018 0.183796418429634401 -0.0141381467925742240
27 0.540000000000000036 0.183381567857668515 -0.0271676019807839605
28 0.560000000000000053 0.182716669217487304 -0.0391535357516522645
29 0.579999999999999960 0.181821969378139686 -0.0501577498528595900
30 0.599999999999999978 0.180716511867434454 -0.0602388038506180140
31 0.619999999999999996 0.179418200110394555 -0.0694521743669628405
32 0.640000000000000013 0.177943857558579527 -0.0778504068142278072
33 0.660000000000000031 0.176309284856870752 -0.0854832599702608359
34 0.680000000000000049 0.174529314187597984 -0.0923978437225306121
35 0.700000000000000067 0.172617860925471212 -0.0986387502945474809
36 0.719999999999999973 0.170587972730655124 -0.104248179253945611
37 0.739999999999999991 0.168451876201472006 -0.109266056588119206
38 0.760000000000000009 0.166221021202630853 -0.113730148120445823
39 0.780000000000000027 0.163906122979543406 -0.117676167527839340
40 0.800000000000000044 0.161517202164191437 -0.121137879208628521
41 0.820000000000000062 0.159063622773142788 -0.124147196238530849
42 0.839999999999999969 0.156554128293666411 -0.126734273641762762
43 0.859999999999999987 0.153996875949458961 -0.128927597194074095
44 0.880000000000000004 0.151399469233258754 -0.130754067964697240
45 0.900000000000000022 0.148768988789577172 -0.132239082794837953
46 0.920000000000000040 0.146112021726915342 -0.133406610901388389
47 0.940000000000000058 0.143434689435146284 -0.134279266785993751
48 0.959999999999999964 0.140742673980222749 -0.134878379621434813
49 0.979999999999999982 0.138041243145009956 -0.135224059279484138
50 1 0.135335274181834636 -0.135335259156935755

What this calculator does

This tool numerically solves a second-order ordinary differential equation written in the form \(y'' = F(x, y, y')\) over an interval \([x_0, x_n]\), using the classic fourth-order Runge-Kutta (RK4) method. You supply the right-hand side \(F\) as a math expression in \(x\), \(y\) and \(p\) (where \(p\) stands for \(y'\)), the initial conditions \(y(x_0)\) and \(y'(x_0)\), the interval endpoints, and the number of steps. The calculator returns a full table of \(x\), \(y\) and \(y'\) values plus the endpoint values. It is pure numerical analysis and applies universally.

How to use it

Enter \(F(x, y, p)\) — for example -4*p - 4*y for \(y'' + 4y' + 4y = 0\). Set \(x_0\), \(y_0 = f(x_0)\), and \(p_0 = y'(x_0)\). Set the end point \(x_n\) and choose the number of subintervals \(n\) (more steps means a smaller step size \(h = (x_n - x_0)/n\) and higher accuracy). Pick how many significant digits to display. The error of RK4 is \(O(h^4)\) globally, so doubling \(n\) roughly cuts the error by a factor of 16.

The formula explained

A second-order ODE is reduced to a system of two first-order equations by setting \(p = y'\): then \(y' = p\) and \(p' = F(x, y, p)\). RK4 advances both unknowns each step using four weighted slope evaluations (\(k\) for \(y\), \(j\) for \(p\)), combining them as $$\frac{k_1 + 2k_2 + 2k_3 + k_4}{6} \quad\text{and}\quad \frac{j_1 + 2j_2 + 2j_3 + j_4}{6}.$$

Advertisement
Schematic showing y''=F reduced to the system y'=p and p'=F(x,y,p)
The second-order ODE is rewritten as a coupled first-order system in \(y\) and \(p = y'\).
Diagram of four RK4 slope estimates k1 to k4 across one step from x to x+h
RK4 combines four slope estimates per step to advance the solution from \(x\) to \(x+h\).

Worked example

Take \(y'' = -4p - 4y\) with \(x_0 = 0\), \(y_0 = 0\), \(p_0 = 1\), \(x_n = 1\) and a single coarse step (\(n = 1\), \(h = 1\)). The four stages give \(k_1=1\), \(k_2=-1\), \(k_3=2\), \(k_4=-5\) and \(j_1=-4\), \(j_2=2\), \(j_3=-6\), \(j_4=12\). Then $$y(1) = \frac{1 - 2 + 4 - 5}{6} = -\frac{1}{3} = -0.3333$$ and $$p(1) = 1 + \frac{-4 + 4 - 12 + 12}{6} = 1.$$ The exact solution is \(y = x e^{-2x}\), so \(y(1) = e^{-2} = 0.1353\); one giant step of \(h = 1\) is far too coarse. Using \(n = 50\) or \(100\) converges right onto the exact value.

FAQ

Can I integrate backward? Yes — set \(x_n\) less than \(x_0\) and the step size \(h\) becomes negative, integrating from \(x_0\) down to \(x_n\).

Why does my answer look wrong with few steps? RK4 accuracy depends on a small step size. Increase \(n\) until successive results stop changing.

What functions can F contain? + - * / ^, parentheses, and sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, exp, log/ln, log10, sqrt, abs, plus the constants pi and e.

Last updated: