INFO-F-305 - TP 1¶

Rappel sur les équations différentielles ordinaires¶

Jacopo De Stefani - jdestefa@ulb.ac.be¶

Organisation¶

  • TP - Via Zoom: 30/09, 07/10, 14/10, 21/10, 30/10, 04/11, 09/11, 18/11, 25/11, 02/12, 09/12
  • Projet - A réaliser avec Octave
  • Rendez-vous: Fixer par email (jdestefa@ulb.ac.be) en spécifiant nom, raison et durée prévue

Ressources¶

  • Université Virtuelle (PDF):https://uv.ulb.ac.be
  • Github (Notebooks): https://github.com/jdestefani/ulb-infof305-1819

Comment installer Octave?¶

  • Octave: Plus d'informations ici: https://www.gnu.org/software/octave/
  • Jupyter Notebook: https://jupyter.readthedocs.io/en/latest/install.html
  • Octave kernel for Jupyter: https://github.com/Calysto/octave_kernel

Rappels Théoriques¶

Cf UV.¶

Rappels Théoriques - Système du second ordre¶

$\begin{bmatrix}\dot{x_{1}}\\ \dot{x_{2}}\end{bmatrix}=\begin{bmatrix}a & b\\ c & d\end{bmatrix}\begin{bmatrix}x_{1}\\ x_{2}\end{bmatrix}$

Equation caractéristique¶

$\det(A-\lambda I) = \lambda^{2}-\tau\lambda+\Delta=0$

$\lambda_{1,2} = \frac{\tau \pm \sqrt{\tau^2 - 4 \Delta}}{2}$

où:

  • $\tau=a+d=tr(A)$
  • $\Delta=ad-bc=\det(A)$

Cas 1 - Racines réelles et distinctes - $\lambda_1,\lambda_2$¶

Solution générale - Théoreme 5.11¶

$\mathbf{X}(t) = C_1 \mathbf{X}^{(1)}(t) + C_2 \mathbf{X}^{(2)}(t) $

Solution particulières¶

$\mathbf{X}^{(1)}(t) = e^{\lambda_1 t} \mathbf{v_1} $

$\mathbf{X}^{(2)}(t) = e^{\lambda_2 t} \mathbf{v_2} $

Exemple¶

$\mathbf{\dot{x}}=\begin{bmatrix}1 & 3\\ 3 & 1\end{bmatrix}\mathbf{x}$

In [2]:
A = [1 3; 3 1]
[v, lambda] = eig(A)
A =

   1   3
   3   1

v =

  -0.70711   0.70711
   0.70711   0.70711

lambda =

Diagonal Matrix

  -2   0
   0   4

Cas 2 - Racines réelles et multiples - $\lambda=\lambda_1=\lambda_2$¶

Solution générale - Théoreme 5.11¶

$\mathbf{X}(t) = C_1 \mathbf{X}^{(1)}(t) + C_2 \mathbf{X}^{(2)}(t) $

Solution particulières¶

$\mathbf{X}^{(1)}(t) = e^{\lambda t} \mathbf{v_1} $

$\mathbf{X}^{(2)}(t) = e^{\lambda t} (\mathbf{v_2} + t\mathbf{v_1}) $

Exemple¶

$\mathbf{\dot{x}}=\begin{bmatrix}3 & -4\\ 1 & -1\end{bmatrix}\mathbf{x}$

In [1]:
A = [3 -4; 1 -1]
[v, lambda] = eig(A)
A =

   3  -4
   1  -1

v =

   0.89443   0.89443
   0.44721   0.44721

lambda =

Diagonal Matrix

   1   0
   0   1

Cas 3 - Racines complexes et conjuguées - $\lambda_{1,2} = \alpha \pm i\beta$¶

Solution générale - Théoreme 5.11¶

$\mathbf{X}(t) = C_1 \mathbf{X}^{(1)}(t) + C_2 \mathbf{X}^{(2)}(t) $

Solution particulières - $\mathbf{v_{1,2}} = \mathbf{u} + i \mathbf{v}$¶

$\mathbf{X}^{(1)}(t) = e^{\alpha t} (\cos(\beta t)\mathbf{u} - \sin(\beta t)\mathbf{v} ) $

$\mathbf{X}^{(2)}(t) = e^{\alpha t} (\sin(\beta t)\mathbf{u} + \cos(\beta t)\mathbf{v}) $

Exemple¶

$\mathbf{\dot{x}}=\begin{bmatrix}0 & 4\\ -1 & 0\end{bmatrix}\mathbf{x}$

In [4]:
A = [0 4; -1 0]
[v, lambda] = eig(A)
A =

   0   4
  -1   0

v =

   0.89443 + 0.00000i   0.89443 - 0.00000i
   0.00000 + 0.44721i   0.00000 - 0.44721i

lambda =

Diagonal Matrix

   0.0000 + 2.0000i                  0
                  0   0.0000 - 2.0000i

Exercice 1 - Solutions¶

(1) - Calculer les valeurs propres¶

$ \lambda_1 = -2$ , $\lambda_2 =4$

(2) - Calculer les vecteurs propres¶

$ \mathbf{v_1} = \begin{bmatrix} 1 \\ -1 \end{bmatrix} $ , $\mathbf{v_2} = \begin{bmatrix} 1 \\ 1 \end{bmatrix}$

(3) - En deduire la forme générale de $x_1(t)$ et $x_2(t)$¶

$ \mathbf{x}(t) = \begin{cases} x_1(t) &= c_1 e^{-2t} + c2 e^{4t} \\ x_2(t) &= -c_1 e^{-2t} + c2 e^{4t} \end{cases}$

(4) - Fixer les paramètres constants $c_{1}$ et $c_{2}$ de manière à satisfaire les conditions initiales $\mathbf{x}(0)=[0.5,0]$, et donner l'expression analytique de $x_{1}(t)$ et $x_{2}(t)$¶

$ \mathbf{x}(t) = \begin{cases} x_1(t) &= c_1 e^{-2t} + c_2 e^{4t} \\ x_2(t) &= -c_1 e^{-2t} + c_2 e^{4t} \end{cases}$

In [2]:
C = [1 1; -1 1]
x_0 = [0.5; 0]
c = C \ x_0 # Solve the system with fixed initial conditions
lambda_1 = -2;
lambda_2 = 4;
c_1 = c(1,1);
c_2 = c(2,1);
C =

   1   1
  -1   1

x_0 =

   0.50000
   0.00000

c =

   0.25000
   0.25000

lambda_1 = -2
lambda_2 =  4
c_1 =  0.25000
c_2 =  0.25000

(5) Dessiner la trajectoire à partir de $\mathbf{x}(0)$, en calculant les points pour $t=\{0,0.1,0.2,0.3,0.4,0.5\}$.¶

In [2]:
t = 0:0.1:0.5
x_1 = c_1 * exp(t*lambda_1) + c_2 * exp(t*lambda_2)
x_2 = -c_1 * exp(t*lambda_1) + c_2 * exp(t*lambda_2)
t =

    0.00000    0.10000    0.20000    0.30000    0.40000    0.50000

x_1 =

   0.50000   0.57764   0.72397   0.96723   1.35059   1.93923

x_2 =

   0.00000   0.16827   0.38881   0.69283   1.12593   1.75529

In [3]:
axis([-2 2 -2 2])
hold on
plot(x_1,x_2,"o-","color","k")
title(sprintf("Trajectoire pour x_0 = [%d %d]",x_0))
In [4]:
subplot(1,2,1);
plot(t, x_1);
title("x_1(t)")
subplot(1,2,2);
plot(t, x_2);
title("x_2(t)")

(6) Mêmes questions que (4,5) pour les conditions initiales $\mathbf{x}(0)=[0,-0.5]$, $\mathbf{x}(0)=[0,0]$, $\mathbf{x}(0)=[1,1]$ et $\mathbf{x}(0)=[1,-1]$¶

In [26]:
## Compute the trajectories given the initial condition, coefficient matrix and eigenvalues
## usage: [x1 x2] = sode_ex1(C,x_0,lambda_1,lambda_2)
##
## Parameters:
## C = Coefficient matrix
## x_0 = Initial condition vector
## lambda_1 = First eigenvalue
## lambda_2 = Second eigenvalue

function [x_1 x_2] = sode_ex1(C,x_0,lambda_1,lambda_2,t)
    c = C \ x_0; # Solve the system with fixed initial conditions to get c_1 and c_2
    c_1 = c(1,1);
    c_2 = c(2,1);
    
    x_1 = c_1 * exp(t*lambda_1) + c_2 * exp(t*lambda_2);
    x_2 = -c_1 * exp(t*lambda_1) + c_2 * exp(t*lambda_2);
endfunction
#N.B. Carriage return in the end of the function
In [53]:
t = 0:0.1:0.5
[x_1 x_2] = sode_ex1(C,[0 ;-0.5],lambda_1,lambda_2,t)
t =

    0.00000    0.10000    0.20000    0.30000    0.40000    0.50000

x_1 =

   0.00000  -0.16827  -0.38881  -0.69283  -1.12593  -1.75529

x_2 =

  -0.50000  -0.57764  -0.72397  -0.96723  -1.35059  -1.93923

In [51]:
axis([-2 2 -2 2])
hold on
plot(x_1,x_2,"o-","color","k")
title(sprintf("Trajectoire pour x_0 = [%d %d]",x_0))
In [11]:
subplot(1,2,1);
plot(t, x_1);
title("x_1(t)")
subplot(1,2,2);
plot(t, x_2);
title("x_2(t)")
In [73]:
t = 0:0.1:0.5; X_0 = [[0,0.5];[0,-0.5];[0,0];[1,1];[1,-1]]'; #cbind like
for x_0 = X_0 # Column-wise iteration
    [x_1 x_2] = sode_ex1(C,x_0,lambda_1,lambda_2,t);
    hold on
    plot(x_1,x_2,sprintf(";[%d %d];o-",x_0))
    hold on
endfor
h = legend; legend(h,"location","southeast");
In [75]:
for x_0 = X_0 # Column-wise iteration
    [x_1 x_2] = sode_ex1(C,x_0,lambda_1,lambda_2,t)
endfor
x_1 =

   0.00000   0.16827   0.38881   0.69283   1.12593   1.75529

x_2 =

   0.50000   0.57764   0.72397   0.96723   1.35059   1.93923

x_1 =

   0.00000  -0.16827  -0.38881  -0.69283  -1.12593  -1.75529

x_2 =

  -0.50000  -0.57764  -0.72397  -0.96723  -1.35059  -1.93923

x_1 =

   0   0   0   0   0   0

x_2 =

   0   0   0   0   0   0

x_1 =

   1.0000   1.4918   2.2255   3.3201   4.9530   7.3891

x_2 =

   1.0000   1.4918   2.2255   3.3201   4.9530   7.3891

x_1 =

   1.00000   0.81873   0.67032   0.54881   0.44933   0.36788

x_2 =

  -1.00000  -0.81873  -0.67032  -0.54881  -0.44933  -0.36788