# 4th order Runge-Kutta Method for Driven Damped Pendulum

Although I've been looking everywhere, I have been unable to find an answer to my question so here it is. For a driven damped pendulum the equation of motion in dimensionless units is,

$$\alpha(\omega,\theta,t)=-c\ \omega -\sin \theta +F(t).$$

My question is obtaining my next step $\omega(t + \Delta t)$. I know what to do for time $t$ and $\omega$, but not for $\theta$. The fourth order RK method can be found pretty much anywhere

$$\omega(t+ \Delta t) = \omega(t) + (k_1 +2k_2 +2k_3 + k_4)*\Delta t/6,$$

and I am specifically confused on what to enter for $\theta$ in the $k_1, k_2$. . . calculations. The first one is easy but I'm unsure on the rest:

$$k_1 = \alpha(\omega(t),\ \theta(t),\ t) \\ k_2=\alpha(\omega(t) + k_1\Delta t/2,\ \theta(t) + \ ???,\ t +\Delta t/2) \\ k_3=\alpha(\omega(t) + k_2\Delta t/2,\ \theta(t) + \ ???,\ t +\Delta t/2) \\ k_4=\alpha(\omega(t) + k_3\Delta t,\ \theta(t) + \ ???,\ t +\Delta t).$$

From here solving for the next $\theta(t+\Delta t)$ is simple enough I just need help knowing what to do the above equation. It seems like all the examples that I've seen show examples for only two variables and not three.

• You need to write your system as a first order one first. That's the first step, check the Wikipedia article, they start from there. In your case, you have a second derivative in the left hand side. – nicoguaro May 1 '17 at 23:09
• As @nicoguaro mentions, you have not yet represented your problem as a system of 1st order Ordinary Differential Equations. Once you do that, you just view Runge-Kutta formula in a vector sense and it will be clear what you need to do. – spektr May 1 '17 at 23:51
• I'm still not sure how this would help @nicoguaro. Letting $\omega = y$ and $\theta = x$, then I get two equations of motion, $\dot x = y$ and $\dot y = -cy - \sin x + F(t)$. The second equation is still a function of $y, x,$ and $t$ so I'm not sure how this helps. The Wikipedia and everywhere else starts with a function of only two variables, which is why I need help with the above example. – Josh May 2 '17 at 1:36
• Then you write it down in vector form $$\mathbf{x}' = \begin{bmatrix}x_2\\ -cx_2 - \sin x_1 + F(t)\end{bmatrix}$$ and apply the iteration considering the vector form of your equation. – nicoguaro May 2 '17 at 1:38

Let's define $\boldsymbol{u} = [\theta, \omega ]^{T} = [u_1, u_2]^{T}$. The system of differential equations to solve can then be represented as:
where $t_j = t_{0} + j\Delta t$ and $\boldsymbol{u}_j = \boldsymbol{u}(t_{j})$. As noted by nicoguaro, this is just the vector form of the Runge-Kutta equations. All it assumes is that your function $f(\cdot,\cdot)$ takes a vector input for the state you are integrating.