""" TD 1 """

""" Exercice 3 """

import numpy as np
import matplotlib.pyplot as plt
import scipy.integrate as sp

# Entrée des valeurs

y_0 = 0
ypoint_0 = 0.1

X_ini = (y_0,ypoint_0)

a = 3
b = 1
omega0 = 7

def F(X,t):
    return(X[1],-(omega0**2)*X[0]-a*(((X[0]**2)/(b**2))-1)*X[1])

t = np.linspace(0,15,1000)

# Résolution avec odeint

X_sol = sp.odeint(F, X_ini, t)

# Récupération des résultats

y = X_sol[:,0]
ypoint = X_sol[:,1]

# Tracés
plt.plot(t,y,label = 'courbe y = f(t)')
plt.xlabel('temps t(s)')
plt.ylabel('angle y(rad)')
plt.legend()
plt.show()
