How to evolve a 3D pendulum over time

51 Views Asked by At

I wrote the differential equaltions for a 3d pendulum and I would like to evolve it with time. The equations are:

$T \, L = \vec{x}^T \vec{g}+\dot{\vec{x}}^{T}\dot{\vec{x}} $

$\ddot{\vec{x}} \, m= \vec{g} - \vec{x} \, \frac{T}{L}$

A could use Euler's discretization to approximate the derivatives $\dot{x}$ and $\ddot{x}$, example: $\dot{x}(t)=\frac{x(n \, \Delta t) - x((n-1) \, \Delta t)}{\Delta t}$, but when I do this, my system loses energy over time and eventualy stops.

I would be gratefull if someone could present me another technique to approximate the derivatives and evolve the system.