[pstricks] Searching for a numeric solution for coupled differential equation systems of order 2

Manfred Braun manfred.braun at uni-due.de
Fri May 25 12:52:18 CEST 2012

On 25.05.2012, at 12:15, Alexander Grahn wrote:

> On Thu, May 24, 2012 at 10:21:06PM +0200, Juergen Gilg wrote:
>> Dear PSTricks list,
>> is there anybody out there, knowing about how to generate a PS code for 
>> "Runge-Kutta 4" to solve a "coupled differential equation system of 
>> order 2"?
>> There is the need for such a code to animate a double-pendulum in real 
>> time, following the coupled differential equations with the variables 
>> (\varphi_1, \varphi_2) and their derivatives like:
>> (1) 
>> l_1\ddot{\varphi}_1+\frac{m_2}{m_1+m_2}l_2\ddot{\varphi}_2\cos(\varphi_1-\varphi_2)-\frac{m_2}{m_1+m_2}l_2\dot{\varphi}_2^2\sin(\varphi_1-\varphi_2)+g\sin\varphi_1=0
>> (2) 
>> l_2\ddot{\varphi}_2+l_1\ddot{\varphi}_1\cos(\varphi_1-\varphi_2)-l_1\dot{\varphi}_1^2\sin(\varphi_1-\varphi_2)+g\sin\varphi_2=0
> I'd first transform this set of DEs of second order into a set of four
> DEs of first order,

Yes, this is the right way.
> However, it may still not be amenable to Runge-Kutta, because the right
> hand sides of the resulting four equation set of DEs, put into normal
> form, still contain derivatives:

No! Take the following steps:

1. Solve the two equations for \ddot{\varphi_1} and \ddot{\varphi_2}:
    \ddot{\varphi}_1 = f_1(\varphi_1, \dot{\varphi}_1, \varphi_2, \dot{\varphi}_2)
    \ddot{\varphi}_2 = f_2(\varphi_1, \dot{\varphi}_1, \varphi_2, \dot{\varphi}_2)

2. Define  x_1 = \varphi_1,  x_2 = \dot{\varphi}_1,  x_3 = \varphi_2,  x_4 = \dot{\varphi}_2

3. The new variables satisfy the system of four 1st-order equations
    \dot{x}_1 = x_2
    \dot{x}_2 = f_1(x_1, x_2, x_3, x_4)
    \dot{x}_3 = x_4
    \dot{x}_4 = f_2(x_1, x_2, x_3, x_4)

This can be solved by Runge-Kutta or any other procedure.


More information about the PSTricks mailing list