Analyse 3 - TD - Systèmes différentiels¶

In [1]:
import numpy as np
import matplotlib.pyplot as plt
from scipy import linalg
from scipy.integrate import solve_ivp
%config InlineBackend.figure_format = 'retina'

x, y = np.meshgrid(
    np.arange(-2, 2, 0.1),
    np.arange(-2, 2, 0.1)
)

Exercice 82¶

Système différentiel : $$\left\lbrace\begin{aligned} x_1'(t) &= 5x_1(t) - 2x_2(t) \\ x_2'(t) &= 15x_1(t) - 6x_2(t) \end{aligned}\right.$$

In [2]:
A = np.array([[5, -2],
              [15, -6]])

vp, P = linalg.eig(A)
vp = vp.real
print("Valeurs propres :", vp)
print("Vecteurs propres (normalisés):\n", P)
Valeurs propres : [-1.77635684e-15 -1.00000000e+00]
Vecteurs propres (normalisés):
 [[0.37139068 0.31622777]
 [0.92847669 0.9486833 ]]

La matrice $A$ a pour valeurs propres $\lambda_1 = 0$ et $\lambda_2 = -1$. En notant $P$ la matrice des vecteurs propres $V_1$ et $V_2$, on a : $$ A = PDP^{-1},\qquad D = \begin{pmatrix} 0 & 0 \\ 0 & -1 \end{pmatrix},\qquad P = \begin{pmatrix} 2 & 1\\ 5 & 3\end{pmatrix}$$

In [3]:
# Champs de vecteurs
X = np.array([x, y])
X_prime = np.einsum("ij,jkl", A, X)
norm = linalg.norm(X_prime, axis=0)
norm_seuil = np.maximum(norm, 1)
U, V = X_prime / norm_seuil

# Tracé du champs de vecteur
plt.figure(figsize=(8,8))
plt.quiver(x, y, U, V, angles = "xy", width = 0.0015)
plt.axhline(0, color='gray', linewidth=0.8)
plt.axvline(0, color='gray', linewidth=0.8)
plt.axline((0, 0), P[:,0], linewidth=1, linestyle="--", color='r', label="$V_1$")
plt.axline((0, 0), P[:,1], linewidth=1, linestyle="--", color='b', label="$V_2$")
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.axis('equal')
plt.xlabel("$x_1$")
plt.ylabel("$x_2$")
plt.grid(True, alpha=0.3)
plt.legend()
plt.title("Champs de vecteurs associé au système $X'=AX$")
plt.tight_layout()
plt.show()
No description has been provided for this image

Avec le changement de variable $X = PY$, le système différentiel $X' = AX$ est équivelent à $Y' = DY$, c'est-à-dire : $$\left\lbrace\begin{aligned} y_1'(t) &= 0 \\ y_2'(t) &= -y_2 \end{aligned}\right.$$

In [4]:
U = np.zeros_like(x)
V = -y / np.maximum(np.abs(y), 1)

sol = solve_ivp(lambda t, X : np.diag(vp) @ X, t_span=[0, 10], y0=[1, 1.9], dense_output=True)
t = np.linspace(0, 10, 500)
traj = sol.sol(t)

plt.figure(figsize=(8, 8))
plt.quiver(x, y, U, V, width=0.0015)
plt.axhline(0, color='r', linewidth=1, linestyle='--', label="$V_1$")
plt.axvline(0, color='b', linewidth=1, linestyle='--', label="$V_2$")
plt.plot(traj[0], traj[1], color='g', linewidth=1, label="trajectoire")
plt.plot(*traj[:, 0], 'o', color='g', markersize=5)   # point initial
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.axis('equal')
plt.xlabel("$y_1$")
plt.ylabel("$y_2$")
plt.legend()
plt.grid(True, alpha=0.3)
plt.title("Champs de vecteurs associé au système $Y'=DY$")
plt.tight_layout()
plt.show()
No description has been provided for this image

Exercice 85¶

Sytème différentiel homogène : $$\left\lbrace\begin{aligned} x_1'(t) &= 8x_1(t) -6x_2(t) \\ x_2'(t) &= 4x_1(t) - 2x_2(t) \end{aligned}\right.$$

In [5]:
A = np.array([[8, -6],
              [4, -2]])

vp, P = linalg.eig(A)
vp = vp.real
print("Valeurs propres :", vp)
print("Vecteurs propres (normalisés):\n", P)
Valeurs propres : [4. 2.]
Vecteurs propres (normalisés):
 [[0.83205029 0.70710678]
 [0.5547002  0.70710678]]

La matrice $A$ a pour valeurs propres $\lambda_1 = 4$ et $\lambda_2 = 2$. En notant $P$ la matrice des vecteurs propres $V_1$ et $V_2$, on a : $$ A = PDP^{-1},\qquad D = \begin{pmatrix} 4 & 0 \\ 0 & 2 \end{pmatrix},\qquad P = \begin{pmatrix} 3 & 1\\ 2 & 1\end{pmatrix}$$

In [6]:
# Champs de vecteurs
X = np.array([x, y])
X_prime = np.einsum("ij,jkl", A, X)
norm = linalg.norm(X_prime, axis=0)
norm_seuil = np.maximum(norm, 1)
U, V = X_prime / norm_seuil

# Tracé du champs de vecteur
plt.figure(figsize=(8,8))
plt.axline((0, 0), P[:,0], linewidth=1, linestyle="--", color='r', label="$V_1$")
plt.axline((0, 0), P[:,1], linewidth=1, linestyle="--", color='b', label="$V_2$")
plt.quiver(x, y, U, V, angles = "xy", width = 0.0015)
plt.axhline(0, color='gray', linewidth=0.8)
plt.axvline(0, color='gray', linewidth=0.8)
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.axis('equal')
plt.xlabel("$x_1$")
plt.ylabel("$x_2$")
plt.grid(True, alpha=0.3)
plt.legend()
plt.title("Champs de vecteurs associé au système $X'=AX$")
plt.tight_layout()
plt.show()
No description has been provided for this image

Avec le changement de variable $X = PY$, le système différentiel $X' = AX$ est équivelent à $Y' = DY$, c'est-à-dire : $$\left\lbrace\begin{aligned} y_1'(t) &= 4y_1(t) \\ y_2'(t) &= 2y_2(t) \end{aligned}\right.$$

In [7]:
Y = np.array([x, y])
Y_prime = np.einsum("ij,jkl", np.diag(vp), Y)
norm = linalg.norm(Y_prime, axis=0)
norm_seuil = np.maximum(norm, 1)
U, V = Y_prime / norm_seuil

sol = solve_ivp(lambda t, X : np.diag(vp) @ X, t_span=[0, 10], y0=[0.01, 0.02], dense_output=True)
t = np.linspace(0, 1.3, 500)
traj = sol.sol(t)


plt.figure(figsize=(8, 8))
plt.quiver(x, y, U, V, width=0.0015)
plt.axhline(0, color='r', linewidth=1, linestyle='--', label="$V_1$")
plt.axvline(0, color='b', linewidth=1, linestyle='--', label="$V_2$")
plt.plot(traj[0], traj[1], color='g', linewidth=1, label="trajectoire")
plt.plot(*traj[:, 0], 'o', color='g', markersize=5)   # point initial
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.axis('equal')
plt.xlabel("$y_1$")
plt.ylabel("$y_2$")
plt.legend()
plt.grid(True, alpha=0.3)
plt.title("Champs de vecteurs associé au système $Y'=DY$")
plt.tight_layout()
plt.show()
No description has been provided for this image

Exercice 86¶

Sytème différentiel homogène : $$\left\lbrace\begin{aligned} x_1'(t) &= 8x_1(t) -6x_2(t) \\ x_2'(t) &= 9x_1(t) - 7x_2(t) \end{aligned}\right.$$

In [8]:
A = np.array([[8, -6],
              [9, -7]])

vp, P = linalg.eig(A)
vp = vp.real
print("Valeurs propres :", vp)
print("Vecteurs propres (normalisés):\n", P)
Valeurs propres : [ 2. -1.]
Vecteurs propres (normalisés):
 [[0.70710678 0.5547002 ]
 [0.70710678 0.83205029]]

La matrice $A$ a pour valeurs propres $\lambda_1 = 2$ et $\lambda_2 = -1$. En notant $P$ la matrice des vecteurs propres $V_1$ et $V_2$, on a : $$ A = PDP^{-1},\qquad D = \begin{pmatrix} 2 & 0 \\ 0 & -1 \end{pmatrix},\qquad P = \begin{pmatrix} 1 & 2\\ 1 & 3\end{pmatrix}$$

In [9]:
# Champs de vecteurs
X = np.array([x, y])
X_prime = np.einsum("ij,jkl", A, X)
norm = linalg.norm(X_prime, axis=0)
norm_seuil = np.maximum(norm, 1)
U, V = X_prime / norm_seuil

# Tracé du champs de vecteur
plt.figure(figsize=(8,8))
plt.axline((0, 0), P[:,0], linewidth=1, linestyle="--", color='r', label="$V_1$")
plt.axline((0, 0), P[:,1], linewidth=1, linestyle="--", color='b', label="$V_2$")
plt.quiver(x, y, U, V, angles = "xy", width = 0.0015)
plt.axhline(0, color='gray', linewidth=0.8)
plt.axvline(0, color='gray', linewidth=0.8)
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.axis('equal')
plt.xlabel("$x_1$")
plt.ylabel("$x_2$")
plt.grid(True, alpha=0.3)
plt.legend()
plt.title("Champs de vecteurs associé au système $X'=AX$")
plt.tight_layout()
plt.show()
No description has been provided for this image

Avec le changement de variable $X = PY$, le système différentiel $X' = AX$ est équivelent à $Y' = DY$, c'est-à-dire : $$\left\lbrace\begin{aligned} y_1'(t) &= 2y_1 \\ y_2'(t) &= -y_2 \end{aligned}\right.$$

In [10]:
Y = np.array([x, y])
Y_prime = np.einsum("ij,jkl", np.diag(vp), Y)
norm = linalg.norm(Y_prime, axis=0)
norm_seuil = np.maximum(norm, 1)
U, V = Y_prime / norm_seuil

# Trajectoire d'une solution
sol = solve_ivp(lambda t, X : np.diag(vp) @ X, t_span=[0, 10], y0=[0.1, 1.9], dense_output=True)
t = np.linspace(0, 1.45, 500)
traj = sol.sol(t)

plt.figure(figsize=(8, 8))
plt.quiver(x, y, U, V, width=0.0015)
plt.axhline(0, color='r', linewidth=1, linestyle='--', label="$V_1$")
plt.axvline(0, color='b', linewidth=1, linestyle='--', label="$V_2$")
plt.plot(traj[0], traj[1], color='g', linewidth=1, label="trajectoire")
plt.plot(*traj[:, 0], 'o', color='g', markersize=5)   # point initial
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.axis('equal')
plt.xlabel("$y_1$")
plt.ylabel("$y_2$")
plt.legend()
plt.grid(True, alpha=0.3)
plt.title("Champs de vecteurs associé au système $Y'=DY$")
plt.tight_layout()
plt.show()
No description has been provided for this image

Exercice 87¶

Sytème différentiel homogène : $$\left\lbrace\begin{aligned} x_1'(t) &= 7x_1(t) - 9x_2(t) \\ x_2'(t) &= 4x_1(t) - 5x_2(t) \end{aligned}\right.$$

In [11]:
A = np.array([[7, -9],
              [4, -5]])

vp, P = linalg.eig(A)
vp = vp.real
print("Valeurs propres :", vp)
print("Vecteurs propres (normalisés):\n", P.real)
Valeurs propres : [1. 1.]
Vecteurs propres (normalisés):
 [[0.83205029 0.83205029]
 [0.5547002  0.5547002 ]]

La matrice $A$ a pour unique valeur propre $\lambda_1 = 1$, et le sous-espace propre associé est de dimension 1. Un vecteur propre est $V_1 = \begin{pmatrix} 3\\2 \end{pmatrix}$, que l'on complète par $V_2 = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$ pour former une base de $\mathbb R^2$. On a : $$ A = PTP^{-1},\qquad T = \begin{pmatrix} 1 & 2 \\ 0 & 1 \end{pmatrix},\qquad P = \begin{pmatrix} 3 & 1\\ 2 & 0\end{pmatrix}$$

In [12]:
P = P.real
P[:,1] = np.array([1,0])
T = np.array([
    [1, 2],
    [0, 1]
])
In [13]:
# Champs de vecteurs
X = np.array([x, y])
X_prime = np.einsum("ij,jkl", A, X)
norm = linalg.norm(X_prime, axis=0)
norm_seuil = np.maximum(norm, 1)
U, V = X_prime / norm_seuil

# Tracé du champs de vecteur
plt.figure(figsize=(8,8))
plt.axline((0, 0), P[:,0], linewidth=1, linestyle="--", color='r', label="$V_1$")
plt.quiver(x, y, U, V, angles = "xy", width = 0.0015)
plt.axhline(0, color='gray', linewidth=0.8)
plt.axvline(0, color='gray', linewidth=0.8)
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.axis('equal')
plt.xlabel("$x_1$")
plt.ylabel("$x_2$")
plt.grid(True, alpha=0.3)
plt.legend()
plt.title("Champs de vecteurs associé au système $X'=AX$")
plt.tight_layout()
plt.show()
No description has been provided for this image

Avec le changement de variable $X = PY$, le système différentiel $X' = AX$ est équivelent à $Y' = TY$, c'est-à-dire : $$\left\lbrace\begin{aligned} y_1'(t) &= y_1 + 2y_2 \\ y_2'(t) &= y_2 \end{aligned}\right.$$

In [14]:
Y = np.array([x, y])
Y_prime = np.einsum("ij,jkl", T, Y)
norm = linalg.norm(Y_prime, axis=0)
norm_seuil = np.maximum(norm, 1)
U, V = Y_prime / norm_seuil

# Trajectoire d'une solution
sol = solve_ivp(lambda t, X : T @ X, t_span=[0, 10], y0=[-0.1, 0.01], dense_output=True)
t = np.linspace(0, 5.2, 500)
traj = sol.sol(t)

plt.figure(figsize=(8, 8))
plt.quiver(x, y, U, V, width=0.0015)
plt.axhline(0, color='r', linewidth=1, linestyle='--', label="$V_1$")
plt.axvline(0, color='b', linewidth=1, linestyle='--', label="$V_2$")
plt.plot(traj[0], traj[1], color='g', linewidth=1, label="trajectoire")
plt.plot(*traj[:, 0], 'o', color='g', markersize=5)   # point initial
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.axis('equal')
plt.xlabel("$y_1$")
plt.ylabel("$y_2$")
plt.legend()
plt.grid(True, alpha=0.3)
plt.title("Champs de vecteurs associé au système $Y'=DY$")
plt.tight_layout()
plt.show()
No description has been provided for this image

Exercice 88¶

Sytème différentiel homogène : $$\left\lbrace\begin{aligned} x_1'(t) &= -2x_1(t) - x_2(t) \\ x_2'(t) &= 5x_1(t) + 2x_2(t) \end{aligned}\right.$$

In [15]:
A = np.array([[-2, -1],
              [5, 2]])

vp, P = linalg.eig(A)
print("Valeurs propres :", vp)
print("Vecteurs propres (normalisés):\n", P)
Valeurs propres : [8.95517857e-17+1.j 8.95517857e-17-1.j]
Vecteurs propres (normalisés):
 [[ 0.36514837-0.18257419j  0.36514837+0.18257419j]
 [-0.91287093+0.j         -0.91287093-0.j        ]]

La matrice $A$ a pour valeurs propres $\lambda_1 = i$ et $\lambda_2 = -i$. En notant $P$ la matrice des vecteurs propres $V_1$ et $V_2$ dans $\mathbb C$, on a : $$ A = PDP^{-1},\qquad D = \begin{pmatrix} i & 0 \\ 0 & -i \end{pmatrix} = \begin{pmatrix} \mathrm e^{i\frac \pi2} & 0 \\ 0 & \mathrm e^{-i\frac \pi2} \end{pmatrix},\qquad P = \begin{pmatrix} -2+i & -2-i\\ 5 & 5\end{pmatrix}$$

Géométriquement, $D$ correspond à une rotation d'angle $\frac\pi2$. Dans la base $(\mathfrak{Re}(V_1), \mathfrak{Im}(V_1))$ de $\mathbb R^2$: $$A = QRQ^{-1},\qquad R = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix},\qquad Q = \begin{pmatrix} -2 & 1 \\ 5 & 0 \end{pmatrix}$$

In [16]:
# Champs de vecteurs
X = np.array([x, y])
X_prime = np.einsum("ij,jkl", A, X)
norm = linalg.norm(X_prime, axis=0)
norm_seuil = np.maximum(norm, 1)
U, V = X_prime / norm_seuil

# Trajectoire d'une solution
sol = solve_ivp(lambda t, X : A @ X, t_span=[0, 10], y0=[.1, .1], dense_output=True)
t = np.linspace(0, 10, 500)
traj = sol.sol(t)

# Tracé du champs de vecteur
plt.figure(figsize=(8,8))
plt.axline((0, 0), P[:,0].real, linewidth=1, linestyle="--", color='r', label="$V_1$")
plt.axline((0, 0), P[:,0].imag, linewidth=1, linestyle="--", color='b', label="$V_2$")
plt.quiver(x, y, U, V, angles = "xy", width = 0.0015)
plt.axhline(0, color='gray', linewidth=0.8)
plt.axvline(0, color='gray', linewidth=0.8)
plt.plot(traj[0], traj[1], color='g', linewidth=1, label="trajectoire")
plt.plot(*traj[:, 0], 'o', color='g', markersize=5)   # point initial
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.axis('equal')
plt.xlabel("$x_1$")
plt.ylabel("$x_2$")
plt.grid(True, alpha=0.3)
plt.legend()
plt.title("Champs de vecteurs associé au système $X'=AX$")
plt.tight_layout()
plt.show()
No description has been provided for this image

Avec le changement de variable $X = QY$, le système différentiel $X' = AX$ est équivelent à $Y' = RY$, c'est-à-dire : $$\left\lbrace\begin{aligned} y_1'(t) &= y_2(t) \\ y_2'(t) &= -y_1(t) \end{aligned}\right.$$

In [17]:
Y = np.array([x, y])
R = np.array([[0, -1],[1, 0]])
Y_prime = np.einsum("ij,jkl", R, Y)
norm = linalg.norm(Y_prime, axis=0)
norm_seuil = np.maximum(norm, 1)
U, V = Y_prime / norm_seuil

# Trajectoire d'une solution
sol = solve_ivp(lambda t, X : R @ X, t_span=[0, 10], y0=[0.5, 0.5], dense_output=True)
t = np.linspace(0, 10, 500)
traj = sol.sol(t)

plt.figure(figsize=(8, 8))
plt.quiver(x, y, U, V, width=0.0015)
plt.axhline(0, color='r', linewidth=1, linestyle='--', label="$V_1$")
plt.axvline(0, color='b', linewidth=1, linestyle='--', label="$V_2$")
plt.plot(traj[0], traj[1], color='g', linewidth=1, label="trajectoire")
plt.plot(*traj[:, 0], 'o', color='g', markersize=5)   # point initial
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.axis('equal')
plt.xlabel("$y_1$")
plt.ylabel("$y_2$")
plt.legend()
plt.grid(True, alpha=0.3)
plt.title("Champs de vecteurs associé au système $Y'=RY$")
plt.tight_layout()
plt.show()
No description has been provided for this image

Exercice 89¶

Sytème différentiel homogène : $$\left\lbrace\begin{aligned} x_1'(t) &= 5x_1(t) + 2x_2(t) \\ x_2'(t) &= -5x_1(t) - x_2(t) \end{aligned}\right.$$

In [18]:
A = np.array([[5, 2],
              [-5, -1]])

vp, P = linalg.eig(A)
print("Valeurs propres :", vp)
print("Vecteurs propres (normalisés):\n", P)
Valeurs propres : [2.+1.j 2.-1.j]
Vecteurs propres (normalisés):
 [[-0.50709255-0.16903085j -0.50709255+0.16903085j]
 [ 0.84515425+0.j          0.84515425-0.j        ]]

La matrice $A$ a pour valeurs propres $\lambda_1 = i$ et $\lambda_2 = -i$. En notant $P$ la matrice des vecteurs propres $V_1$ et $V_2$ dans $\mathbb C$, on a : $$ A = PDP^{-1},\qquad D = \begin{pmatrix} 2+i & 0 \\ 0 & 2-i \end{pmatrix} = \begin{pmatrix} r\,\mathrm e^{i\theta} & 0 \\ 0 & r\,\mathrm e^{-i\theta} \end{pmatrix},\qquad P = \begin{pmatrix} -3-i & -3+i\\ 5 & 5\end{pmatrix}$$ où $r = \sqrt 5$ et $\theta \equiv \arg(2+i) \bmod{2\pi}$.

Géométriquement, $D$ correspond à une similitude directe (composée d'une rotation et d'une homothétie). Dans la base $(\mathfrak{Re}(V_1), \mathfrak{Im}(V_1))$ de $\mathbb R^2$: $$A = Q S Q^{-1},\qquad S = \begin{pmatrix} 2 & -1 \\ 1 & 2 \end{pmatrix},\qquad Q = \begin{pmatrix} -3 & -1 \\ 5 & 0 \end{pmatrix}$$

In [19]:
# Champs de vecteurs
X = np.array([x, y])
X_prime = np.einsum("ij,jkl", A, X)
norm = linalg.norm(X_prime, axis=0)
norm_seuil = np.maximum(norm, 1)
U, V = X_prime / norm_seuil

# Tracé du champs de vecteur
plt.figure(figsize=(8,8))
plt.axline((0, 0), P[:,0].real, linewidth=1, linestyle="--", color='r', label="$V_1$")
plt.axline((0, 0), P[:,0].imag, linewidth=1, linestyle="--", color='b', label="$V_2$")
plt.quiver(x, y, U, V, angles = "xy", width = 0.0015)
plt.axhline(0, color='gray', linewidth=0.8)
plt.axvline(0, color='gray', linewidth=0.8)
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.axis('equal')
plt.xlabel("$x_1$")
plt.ylabel("$x_2$")
plt.grid(True, alpha=0.3)
plt.legend()
plt.title("Champs de vecteurs associé au système $X'=AX$")
plt.tight_layout()
plt.show()
No description has been provided for this image

Avec le changement de variable $X = QY$, le système différentiel $X' = AX$ est équivelent à $Y' = SY$, c'est-à-dire : $$\left\lbrace\begin{aligned} y_1'(t) &= 2y_1(t) - y_2(t) \\ y_2'(t) &= y_1(t) + 2y_2(t) \end{aligned}\right.$$

In [20]:
Y = np.array([x, y])
S = np.array([[2, -1],[1, 2]])
Y_prime = np.einsum("ij,jkl", S, Y)
norm = linalg.norm(Y_prime, axis=0)
norm_seuil = np.maximum(norm, 1)
U, V = Y_prime / norm_seuil

# Trajectoire d'une solution
sol = solve_ivp(lambda t, X : S @ X, t_span=[0, 10], y0=[0.01, 0.01], dense_output=True)
t = np.linspace(0, 2.4, 500)
traj = sol.sol(t)

plt.figure(figsize=(8, 8))
plt.quiver(x, y, U, V, width=0.0015)
plt.axhline(0, color='r', linewidth=1, linestyle='--', label="$V_1$")
plt.axvline(0, color='b', linewidth=1, linestyle='--', label="$V_2$")
plt.plot(traj[0], traj[1], color='g', linewidth=1, label="trajectoire")
plt.plot(*traj[:, 0], 'o', color='g', markersize=5)   # point initial
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.axis('equal')
plt.xlabel("$y_1$")
plt.ylabel("$y_2$")
plt.legend()
plt.grid(True, alpha=0.3)
plt.title("Champs de vecteurs associé au système $Y'=SY$")
plt.tight_layout()
plt.show()
No description has been provided for this image