Numerical Methods | |
|
Solving a second order differential equation by fourth order Runge-KuttaAny second order differential equation can be written as two coupled first order equations, \[ \begin{equation} \frac{dx_1}{dt} =f_1(x_1,x_2,t)\qquad\frac{dx_2}{dt} =f_2(x_1,x_2,t). \end{equation} \]These coupled equations can be solved numerically using a fourth order Runge-Kutta routine. The equations for a damped driven pendulum, $f_1(x_1,x_2,t) = x2$, $f_2(x_1,x_2,t) = -x_2 - \sin (x_1) +\sin (t)$ is coded below for the intial conditions $x_1(t=0)=0$, $x_2(t=0)=1$. |