Please note I am no mathematician, and this has been a struggle for me to understand the concepts below. I have several questions regarding the Runge-Kutta 4th order formula. "deltaTime" is my overall fixed time step.
(Q1) How to perform the math in the parenthesis?
(Q2) The second formula uses [t] in the function, but the first does not. How does that [t] calculate into it?
(Q3) I am understanding that this is used for finding the [Y] position at a given time step. Is this incorrect? If so, how can this be applied to an [X] coordinate as well?
(Q4) Is there a way to calculate angular positions and velocities with RK4?
(Q5) [f] & [g] simply mean: value(of everything in here) ???
Here is one version of the formula I have come across:
k1 = f(Position.Y, Velocity.Y)
k2 = f(Position.Y + (deltaTime / 2), Velocity.Y + (k1 / 2) * deltaTime)
k3 = f(Position.Y + (deltaTime / 2), Velocity.Y + (k2 / 2) * deltaTime)
k4 = f(Position.Y + deltaTime, Velocity.Y + k3 * deltaTime)
Position.Y += (1 / 6) * (k1 + (2 * k2) + (2 * k3) + k4) * deltaTime
Here is a second version I have come across:
k1 = deltaTime * f(Position.Y, Velocity.Y, t)
l1 = deltaTime * g(Velocity.Y)
k2 = deltaTime * f(Position.Y + (l1 / 2), Velocity.Y + (k1 / 2), t + (1 / 2))
l2 = deltaTime * g(Velocity.Y + (k1 / 2))
k3 = deltaTime * f(Position.Y + (l2 / 2), Velocity.Y + (k2 / 2), t + (1 / 2))
l3 = deltaTime * g(Velocity.Y + (k2 / 2))
k4 = deltaTime * f(Position.Y + l3, Velocity.Y + k3, t + 1.0)
l4 = deltaTime * g(Velocity.Y + k3)
Velocity.Y += (1.0 / 6.0) * (k1 + (2 * k2) + (2 * k3) + k4)
Position.Y += (1.0 / 6.0) * (l1 + (2 * l2) + (2 * l3) + l4)
(Q5) I see the difference in those two (one has more math in it) but what is one used for over the second one?
I have spent the last 3 days looking up how to apply these methods to a programming problem I am having, so I have already read the (overly complicated) wiki page, as well as several topics on various forums. That being said, I would appreciate any assistance I can get with my specific questions.
k2,k3, andk4the first parameter offis the sum of a position and an elapsed time; the dimensions are incompatible. – David K Oct 03 '16 at 05:23