I have set up a spreadsheet in Excel to solve the double pendulum problem using RK4 on the four first order DEs. However it isn't working, as the energy in the system is increasing drastically, instead of staying constant. I have spent days (literally) checking the Lagrangian and the spreadsheet entries, and I can't find any faults. I wonder if I am mis-applying the RK4 procedure. I can't find any examples of this in Excel - only Matlab, which is quite different, and I don't have it! I'm desperate and so thought I would post here.
I have four first order DEs. The first two are simple W'=Y, X'=Z. Y' & Z' are both very long with terms in W, X, Y & Z. So, I have
W'=f(t,Y)
X'=f(t,Z)
Y'=f(t,X,Y,Z)
Z'=f(t,X,Y,Z)
I calculate
Wn+1 = Wn + h/6*(J1 + 2*J2 + 2*J3 + J4)
Xn+1 = Xn + h/6*(K1 + 2*K2 + 2*K3 + K4)
Yn+1 = Yn + h/6*(L1 + 2*L2 + 2*L3 + L4)
Zn+1 = Zn + h/6*(M1 + 2*M2 + 2*M3 + M4)
The values of these constants are worked out as follows: (Is this where I'm going wrong?)
J1 = f(tn, Yn)
J2 = f(tn + h/2, Yn + h/2*L1)
J3 = f(tn + h/2, Yn + h/2*L2)
J4 = f(tn + h, Yn + h*L3)
The values for K1, K2, K3 & K4 are calculated in the same way using Zn & M1, M2 M3 & M4.
As Y is a function f(t, W, X, Y, Z), I calculate as follows:
L1 = f(tn, Wn, Xn, Yn, Zn)
L2 = f(tn + h/2, Wn + h/2*J1, Xn + h/2*K1, Yn + h/2*L1, Zn + h/2*M1)
L3 = f(tn + h/2, Wn + h/2*J2, Xn + h/2*K2, Yn + h/2*L2, Zn + h/2*M2)
L4 = f(tn + h, Wn + h*J3, Xn + h*K3, Yn + h*L3, Zn + h*M3).
The values for M1, M2, M3 & M4 used to calculate Z were computed in the exact same manner as for L1 etc. above.
If anyone can identify a flaw in my methodology and let me know I would be very grateful.





