The Wikipedia page on RK methods seems pretty good: . If you have trouble understanding that page, please ask a more concrete question.
To use RK4 you need to be able to recompute f after half a step, so you need to have f specified as a function of time and x, not a single number.
However, if you are trying to integrate a system with stiff springs you probably should consider an implicit method.
Hm... The problem is that the wikipedia page uses 't' parameter which doesn't exist in game. That 't' parameter hardcodes it to curve. However, game's don't need it.
The implicit method is impossible in games, cause it has a closed loop. Current velocity calculation requires current position and current position calculation requires current velocity. You need to know one to calculate other one.
I need to replace this with Runge-Kutta somehow.
No, you don't.
I don't think that most physics engines use RK4 at all, most use semi-implicit euler for its balance of speed and stability. It's ok for simple stuff like mass/spring systems, but once you incorporate collision detection and response with RK4 there is not much benefit except in certain cases. For each substep you still need to test for collisions and respond so the performance is about 4x worse than 1st-order integration methods. The integration accuracy is better than just performing 4 1st order steps, but there are many headaches involved with using RK4 in a full physics simulation for games.
Yep. RK4, in short, is garbage. I always found it bizarre that Gaffer on Games recommends it by citing its accuracy, which isn't a particularly important integration property for a game. Stability (energy conservation/symplectic) is a vastly more useful property, and RK4 doesn't have it. In most cases, you can simply use semi-implicit euler and be on your way. Hell, it's faster performance to drive semi-implicit euler at higher frequency than to run RK4.
Either I suck at implementing the semi-implicit method or either it's still not stable enaugh. I tried it, but it's UNSTABLE. You can take a look at the last video in my BATMA post. If implicit was possible, that one may be better.