DOUBLE PENDULUM ANIMATION PROBLEM
from numpy import sin , cos import numpy as np import matplotlib.pyplot as plt import scipy.integrate as integrate import matplotlib.animation as animation G = 9.8 # acceleration due to gravity, in m/s^2 L1 = 1.0 # length of pendulum 1 in m L2 = 1.0 # length of pendulum 2 in m M1 = 1.0 # mass of pendulum 1 in kg M2 = 1.0 # mass of pendulum 2 in kg def derivs ( state , t ): dydx = np . zeros_like ( state ) dydx [ 0 ] = state [ 1 ] del_ = state [ 2 ] - state [ 0 ] den1 = ( M1 + M2 ) * L1 - M2 * L1 * cos ( del_ ) * cos ( del_ ) dydx [ 1 ] = ( M2 * L1 * state [ 1 ] * state [ 1 ] * sin ( del_ ) * cos ( del_ ) + M2 * G * sin ( state [ 2 ]) * cos ( del_ ) + M2 * L2 * state [ 3 ] * state [ 3 ] * sin ( del_ ) - ( M1 + M2 ) * G * sin ( state [ 0 ])) / den1 dydx [ 2 ] = state [ 3 ] den2 = ( L2 / L1 ) * den1 dydx [ 3 ] = ( - M2 ...