[Turn off line numbering]
1: arg x, y, h, f, data;
2: var k1, k2, k3, k4, s;
3:
4: // returns the next timestep for differential equation y'=f(x,y,data)
5: s = sender();
6: k1 = s.f(x, y, data);
7: k2 = s.f(x + 0.5 * h, .add(y, .scale(0.5 * h, k1)), data);
8: k3 = s.f(x + 0.5 * h, .add(y, .scale(0.5 * h, k2)), data);
9: k4 = s.f(x + h, .add(y, .scale(h, k3)), data);
10: return .add(y, .scale(h / 6.0, .add(.add(k1, .scale(2.0, .add(k2, k3))), k4)));
// Miroslav Silovic
// Created 19-Oct-1996 as a part of ColdCore, see: @help Credit