import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import odeint

# La matrice A

A = np.array([
[-1,1,-1],
[-4,-5,4],
[-2,-1,0]])

def syst(y, t) :
    dydt = np.dot(A,y)
    return dydt

# Intervalle de temps, subdivisé
t = np.linspace (0, 10, 501)

# Conditions initiales
y0 = [0,5,-5]

# Tracé des trajectoires
sol = odeint (syst, y0, t)

plt.plot (t, sol[:, 0], "b-", label = "x1(t)")
plt.plot (t, sol[:, 1], "g:", label = "x2(t)")
plt.plot (t, sol[:, 2], "r--", label = "x3(t)")

# Légende, axes, titre
plt.legend(loc="best")
plt.xlabel("t")
plt.title(f"[x1(0), x2(0), x3(0)] = [{y0[0]},{y0[1]},{y0[2]}]")
plt.grid()
plt.show()
