Vous êtes sur la page 1sur 41

PROJET DE METHODE

NUMERIQUE
Résolution des problèmes demandés

Membres du projet
-guibinga dann yannick/20170340
- Mohamed D Diarra / 20170785

2017/2018
L3D/S5B
2Ei
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Remerciement

L’ensemble de cet ouvrage a été réalisé grâce au logiciel Word (qui appartient à
la suite Microsoft office) et le logiciel scilab qui nous ont permis réaliser les
différents algorithmes. Je remercie vivement tous les acteurs du monde de
l’éducation libre pour leur programme et leur mise à disposition du public.
Nous sommes également reconnaissants envers M. Babacar Lèye Professeur de
Méthode numérique. Enfin nous adressons nos remerciements à nos camarades
de la classe de la L3D-S5D pour leur contribution majeure aux efforts rendus et
nous disons merci à la TERRE AFRICAINE pour ces biens faits.

1
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Table des matières


Avant-propos ................................................................................................................................................... 3
Introduction..................................................................................................................................................... 4
Problème 1 ...................................................................................................................................................... 5
Résolution du problème 1 ............................................................................................................................... 6
Tracé demandé............................................................................................................................................ 7
Interprétation .............................................................................................................................................. 9
Problème 2 .................................................................................................................................................... 10
Résolution du problème 2 ............................................................................................................................. 11
Tracé de la courbe ..................................................................................................................................... 13
Graphe de la solution exacte et des solutions approchées pour h=0.05 .................................................. 19
Graphe de la solution exacte et des solutions approchées avec h=0.1.............................................. 20
Graphe de la solution exacte et des solutions approchées avec h=0.5 .................................................... 21
Graphe de la solution exacte et des solutions approchées pour h=0.9 ................................................... 22
Interprétation ............................................................................................................................................ 23
RUNG KUTTA ......................................................................................................................................... 23
EULER EXPLICITE .................................................................................................................................... 23
EULER IMPLICITE ................................................................................................................................... 23
Problème 3 .................................................................................................................................................... 24
Résolution du problème ................................................................................................................................ 25
Cas de la stabilité................................................................................................................................... 29
Cas de l’instabilité ................................................................................................................................. 30
Conclusion ..................................................................................................................................................... 31
Annexe des codes .......................................................................................................................................... 32

2
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Avant-propos

La méthode numérique est une discipline des mathématiques. Elle s’intéresse


tant aux fondements théoriques qu’à la mise en pratique des méthodes
permettant de résoudre, par des calculs purement numériques, des problèmes
d’analyse mathématique.
L’objet de la méthode numérique est de concevoir et d’étudier des méthodes de
résolution de certains problèmes mathématiques, en général issus de la
modélisation de problèmes “réels", et dont on cherche à calculer la solution à
l’aide d’un ordinateur.
Plus formellement, la méthode numérique est l’étude des algorithmes
permettant de résoudre les problèmes de mathématiques continues (distinguées
des mathématiques discrètes). Cela signifie qu’elle s’occupe principalement de
répondre numériquement à des questions à variable réelle ou complexe comme
l’algèbre linéaire numérique sur les champs réels ou complexes, la recherche de
solution numérique d’équations différentielles et d’autres problèmes liés
survenant dans les sciences physiques et l’ingénierie.

3
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Introduction

Certains problèmes de mathématique continue peuvent être résolus de façon


exacte par un algorithme. Ces algorithmes sont appelés méthodes directes. Des
exemples sont l’élimination de Gauss-Jordan pour la résolution d’un système
d’équations linéaires et l’algorithme du simplexe en programmation linéaire. Par
ailleurs, certains problèmes continus peuvent parfois être remplacés par un
problème discret dont la solution est connue pour approcher celle du problème
continu ; ce procédé est appelé discrétisation. Par exemple la solution d’une
équation différentielle est une fonction. Cette fonction peut être représentée de
façon approchée par une quantité finie de données, par exemple par sa valeur en
un nombre fini de points de son domaine de définition, même si ce domaine est
continu.
L’utilisation de la méthode numérique est grandement facilitée par les
ordinateurs. L’accroissement de la disponibilité et de la puissance des
ordinateurs depuis la seconde moitié du XXe siècle a permis l’application de
l’analyse numérique dans de nombreux domaines scientifiques, techniques et
économiques, avec souvent des effets révolutionnaires.

4
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Problème 1
On résout numériquement l’intégrale

10 1
I(f)= ∫−10 𝑑𝑥 = 2 arctan(10) ≃ 2.9422553
1+𝑥 2
1
(i) Tracer la courbe de 𝑥 → sur l’intervalle [-10,10].
1+𝑥 2

(ii) Tracer la solution obtenue avec:


(a) la méthode du rectangle,
(b) la méthode du trapèze,
(c) la méthode de Simpson

(En ordonnée) en fonction du nombre de sous-intervalles (en abscisse). On


prendra comme nombre de sous-intervalles, N = 10, 20, 30, 40, 50 et 60.

5
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Résolution du problème 1

1
(i) traçons la courbe de 𝑥 →
1+𝑥 2
1
Ainsi le tracer de la courbe 𝑥 → fait avec le logiciel scilab nous donne
1+𝑥 2
la figure ci-dessous :

Figure 1

6
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

(ii) traçons la solution obtenue avec :

(a) La méthode du rectangle


(b) La méthode du trapèze
(c) La méthode de Simpson

(En ordonnée) en fonction du nombre de sous-intervalles (en abscisse). On


prendra comme nombre de sous-intervalles, N = 10, 20, 30, 40, 50 et 60.

Tracé demandé

7
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

8
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Interprétation
La solution exacte est 2.95. Lorsque le pas augmente la valeur de la solution
approchée se rapproche de la valeur de la solution exacte. Cela s’observe pour
toutes les méthodes.

9
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Problème 2
On veut résoudre numériquement l’équation différentielle suivante :
1
𝑦 ′ (𝑡) = 𝑦(𝑡) 𝑡 ∈ ]0, 10[,
{ 1+𝑡 2 (2)
𝑦(0) = 1

1
(i) Calculer la solution exacte, sachant que la primitive de est
1+𝑡 2
arctan(t).
(ii) Afficher la courbe t → y(t).
(iii) Résoudre cette équation en utilisant:

(a) la méthode d’Euler explicite,


(b) la méthode d’Euler implicite,

10
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Résolution du problème 2

1
(i) calculons la solution du problème sachant que la primitive de est
1+𝑡 2
arctan(t).

Dans un premier temps on a :

1
𝑦 ′ (𝑡) = 𝑦(𝑡) (*)
1+𝑡 2

Or nous savons que :

𝑑𝑦(𝑡)
y’(t)=
𝑑𝑡
Donc (*) devient :

𝑑𝑦(𝑡) 1
= y(t)
𝑑𝑡 1+𝑡 2

Ensuite,
𝑑𝑦(𝑡) 1
= dt
𝑦(𝑡) 1+𝑡 2

En intégrant,
𝑑𝑦(𝑡) 1
∫ =∫ dt (**)
𝑦(𝑡) 1+𝑡 2

𝑑𝑦(𝑡)
Or nous connaissons une primitive de ∫ qui est ln( ∣ 𝑦(𝑡) ∣)
𝑦(𝑡)

Ainsi (**) devient :

ln( ∣ 𝑦(𝑡) ∣) = arctan(t) +k

11
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

En appliquant l’exponentielle on obtient :

𝑒 ln(∣𝑦(𝑡)∣) = 𝑒 arctan(t) +k (***)


Or nous savons que :
𝑒 ln(∣𝑥∣) = x , pour tout x > 0
Ainsi (***) devient :

y(t) = k1𝑒 arctan(t)

Or la condition initiale est :


y(0)=1

en remplaçant on a :
y(0) = k1𝑒 arctan(0) =1
D’où
k1= 1

En définitive la solution exacte est :

y(t) = 𝑒 arctan(t)

12
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

(ii) affichage courbe

Tracé de la courbe

(iii) Résolvons cette équation en utilisant :

(a) La méthode explicite


(𝑡 𝑛 )
-Formule d’itération
𝑦 𝑛+1 = 𝑦 𝑛 + ℎ𝑓(𝑡 𝑛 , 𝑦 𝑛 )

13
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Ensuite,
1
Yn+ 1 = yn +h[ ]yn
1+tn2

Et puis

Yn+ 1 = yn[1+ ]
1+tn2

Ainsi on obtient la formule d’itération suivante :



Yn + 1 = Yn[1 + ]
{ 1 + 𝑡𝑛²
𝑦0 = 1

-définissons la formule de récurrence pour tout entier naturel k



Yk= y0[1+ ]k, avec y0=1
1+tk

-condition de stabilité :
Ainsi Le schéma est stable si et seulement si :

∣1+ ∣˂1
1+tk2

Ce qui entraine que :



-1˂ 1+ ˂1
1+tk2

Suivit de,

1+𝑡𝑘 2 +ℎ
-1˂ ˂1
1+𝑡𝑘 2

Suivit de,
-1-𝑡𝑘 2 ˂1 + 𝑡𝑘 2 + ℎ˂ 1 + 𝑡𝑘 2
Suivit de,

14
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

-2-𝑡𝑘 2 ˂ h˂ 0
Enfin
0˂∣h∣˂2+𝑡𝑘 2

Schéma inconditionnellement stable

(b) Méthode d’Euler implicite


-Formule d’itération
Yn+ 1 = yn +hf(tn+1,yn+1)
Ensuite,
1
Yn+ 1 = yn +h× 𝑦 𝑛+1
1+𝑡 𝑛+1

Ensuite,
1
Yn+ 1 - h× 𝑦 𝑛+1 = yn
1+𝑡 𝑛+1

Ensuite,

𝑦 𝑛+1 (1 − ) = 𝑦𝑛
1 + 𝑡 𝑛+1
Ensuite,
1
𝑦 𝑛+1 = × 𝑦𝑛

1−
1 + 𝑡 𝑛+1

Enfin,
1
𝑦𝑛 = × 𝑦0

(1 − )𝑛+1
1 + 𝑡 𝑛+1

15
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Ainsi on a la formule d’itération suivante :


1
𝑦𝑛 = × 𝑦0

{ (1 − )𝑛+1
1 + 𝑡 𝑛+1
𝑦0 = 1
-définissons la formule de récurrence pour tout entier naturel k :

1
𝑦𝑘 = × 𝑦0

{ (1 − )𝑘+1
1 + 𝑡𝑘+1
𝑦0 = 1

-condition de stabilité
Ainsi Le schéma est stable si et seulement si :
1
∣ ∣ ˂1
ℎ 𝑘+1
(1 − )
1 + 𝑡𝑘+1
Ensuite,
1
∣ ∣ ˂1𝑘+1

(1 − )𝑘+1
1 + 𝑡𝑘+1
Ensuite,
1
∣ ∣ ˂1

1−
1 + 𝑡𝑘+1
Ensuite,
1
−1˂ ˂1

1−
1 + 𝑡𝑘+1

Ensuite,

16
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

ℎ ℎ
− 1˂ 1 ˂ 1 −
1 + 𝑡𝑘+1 1 + 𝑡𝑘+1
Ensuite,


˂2
1 + 𝑡𝑘+1

Donc le schéma inconditionnellement stable

(c) ) la méthode de Runge Kutta d’ordre 4


𝑘1 = ℎ𝑓 (𝑡𝑘 , 𝑦𝑘 ) 𝑘1 = 𝑦
1+𝑡𝑘 2 𝑘

ℎ 𝑘1 ℎ 𝑘1
𝑘2 = ℎ𝑓 (𝑡𝑘 + , 𝑦𝑘 + ) 𝑘2 = ( ℎ ) (𝑦𝑘 + )
2 2 1+(𝑡𝑘 + 2 )2 2

ℎ 𝑘2 ℎ 𝑘2
𝑘3 = ℎ𝑓 (𝑡𝑘 + , 𝑦𝑘 + ) 𝑘3 = ( ℎ ) (𝑦𝑘 + )
2 2 1+(𝑡𝑘 + 2 ) 2 2


𝑘4 = ℎ𝑓 (𝑡𝑘 + ℎ, 𝑦𝑘 + 𝑘3 ) 𝑘1 = 𝑦
1+𝑡𝑘 2 𝑘

17
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

1
𝑦𝑘+1 = 𝑦𝑘 + (𝑘1 +2𝑘2 + 2𝑘3 + 𝑘4 )
6

Le nombre d’intervalle est obtenu à l’aide de la formule


10
𝑁=

De ce fait, lorsque h varie N aussi varie en sens contraire.
Le tableau suivant nous donne la différente valeur ne prise pas N pour
chaque pas
Valeur de h Valeur de
N
0.05 200
0.1 100
0.5 20
0.9 11

Pour h=0.05

18
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Graphe de la solution exacte et des solutions approchées pour


h=0.05

Pour h=0.1

19
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Graphe de la solution exacte et des solutions approchées avec h=0.1

Pour h=0.5

20
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Graphe de la solution exacte et des solutions approchées avec


h=0.5

Pour h=0.9

21
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Graphe de la solution exacte et des solutions approchées pour


h=0.9

22
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Interprétation

Nous remarquons pour toutes ces valeurs du pas h donné la méthode de Runge
Kutta (d’ordre 4) est toujours plus proche de la solution exacte par rapport aux
deux autres méthodes.
De plus, lorsque le pas diminue les courbes représentatives des solutions
approchées convergent vers la solution exacte c’est à dire la diminution du pas
augmente la précision des méthodes ou des formules utilisées comme approche

RUNG KUTTA

1. Lorsque le pas diminue la valeur de la solution approche de plus en plus


de celle de la solution exacte. Elles suivent de près la solution analytique.
2. Avec une valeur du pas relativement élevé.
3. . Moins coûteux que les autres méthodes
4. Pas encore d’approximation de l’erreur commise.
5. Nécessité de choisir le pas en fonction de l’erreur maximale recherchée.
6. Solution : calculer avec un pas égal à h, h/2, ... Jusqu’à la stabilité de la
solution. Coût élevé !
Les méthodes qui ajustent le pas sont dites méthodes à pas adaptatif

EULER EXPLICITE
Lorsque le pas diminue la valeur de la solution approche de plus en plus de
celle de la solution exacte et nous avons un Schéma inconditionnellement stable

EULER IMPLICITE
Lorsque le pas diminue la valeur de la solution approche de plus en plus de
celle de la solution exacte et nous avons un Schéma inconditionnellement stable

23
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Problème 3
On considère l’équation de la chaleur
𝜕𝑢 𝜕2 𝑢
= µ 𝜕𝑥 2 , 𝑥 𝜖 ] − 𝑙, 𝑙 [, 𝑡 𝜖 ]0, 𝑇[,
𝜕𝑡

Ou µ > 0, et une condition initiale,


u(x,0) =u0(x), x ϵ [-L,L].
On impose des conditions aux limites de Dirichlet
U (−L, t) = u (L, t) = 0, t ∈ [0, T]
1. Donner une discrétisation du domaine [−L, L] × [0, T].
2. . Donner une semi-discrétisation en espace avec la méthode des
différences finies.
3. Donner la discrétisation en temps avec le schéma d’Euler explicite.
4. . Se ramener a un problème d’itération

U n+1 = MUn,
Ou la matrice M et le vecteur Un sont à préciser.

24
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

5. Quelle est la condition de stabilité du schéma obtenu, sachant que le


schéma explicite correspond au θ-schéma lorsque θ = 0.
6. Quel est l’inconvénient de ce schéma lorsque ∆x → 0.
7. Ecrire un programme Scilab qui calcule U n pour n∆ ≤ T.
8. Par des choix de ∆t et ∆x, illustrer la stabilité et l’instabilité du schéma en
affichant la solution en divers pas de temps. On fixe pour les calculs µ =
1, L = 10, T = 1 et
2
U0 (x) ={1 − 𝑥 𝑠𝑖 ∣ 𝑥 ∣≤ 1,
0 𝑠𝑖𝑛𝑜𝑛.

Résolution du problème
1- Discrétisation du domaine
Subdivisons les intervalles [−𝐿, 𝐿]𝑒𝑡[0, 𝑇] respectivement en N et
M 𝑥
𝑥𝑖 𝑖+1 𝑡𝑖 𝑡𝑖+1 𝑡𝑀
𝑥𝑁 𝑡0

∆𝑥 ∆𝑡

N : nombre de subdivision en espace


M : nombre de subdivision en temps
xi : nœud en espace
tk : nœud en temps
∆x : Pas en espace
∆t : pas en temps
L−(−L) 2𝐿
∆x = =
N N

25
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

T−0 𝑇
∆t= =
M M

xi= -L+i∆x i= {0,1,2,3,4,………,N}


tk = k∆t k={0,1,2,3,4,………,M}

2-) Semi-discrétisation en espace avec la méthode des différences finies


On a :
𝜕𝑢 𝜕2 𝑢 𝜕𝑢 𝜕2 𝑢
=𝜇 ⇔ −𝜇 =0
𝜕𝑡 𝜕𝑥 2 𝜕𝑡 𝜕𝑥 2

𝜕2 𝑢
Déterminons une discrétisation de :
𝜕𝑥 2

𝜕 𝑢
𝑢(𝑥𝑖+1 , 𝑡𝑘, ) = 𝑢(𝑥𝑖 + ∆x, 𝑡𝑘, ) = 𝑢(𝑥𝑖 , 𝑡𝑘, ) + ∆x (𝑥𝑖, 𝑡𝑘, ) +
𝜕𝑥
∆x2 𝜕2 𝑢
2! 𝜕𝑥 2
(𝑥𝑖, 𝑡𝑘, ) + ∆x 2 𝜀1 (∆x 2 ) (*)

𝜕 𝑢 ∆x2 𝜕2 𝑢
𝑢(𝑥𝑖−1 ) = 𝑢(𝑥𝑖 − ∆x, 𝑡𝑘, ) = 𝑢(𝑥𝑖 , 𝑡𝑘, ) − ∆x (𝑥𝑖, 𝑡𝑘, ) + (𝑥𝑖, 𝑡𝑘, ) +
𝜕𝑥 2! 𝜕𝑥 2
∆x 2 𝜀2 (∆x 2 ) (**)

(*)+(**)

∆x2
𝑢(𝑥𝑖+1 , 𝑡𝑘, ) + 𝑢(𝑥𝑖−1 , 𝑡𝑘, ) = 2 𝑢(𝑥𝑖 , 𝑡𝑘, ) + 𝑢(𝑥𝑖 , 𝑡𝑘, ) + 2 𝑢′′(𝑥𝑖 , 𝑡𝑘, ) + 𝜀(ℎ)
2!

𝜕2 𝑢 −𝑢(𝑥𝑖−1 ,𝑡𝑘 )+2𝑢(𝑥𝑖 ,𝑡𝑘 )−𝑢(𝑥𝑖−1 ,𝑡𝑘 )


− (𝑥𝑖, 𝑡𝑘, ) = + 𝜀(𝑑𝑥)
𝜕𝑥 2 (∆x)2

Posons 𝑢𝑖 (𝑡𝑘 ) ≃ 𝑢(𝑥𝑖 , 𝑡𝑘 )


𝜕2 𝑢(𝑥𝑖 ,𝑡𝑘 ) −𝑢𝑖−1 (𝑡𝑘 )+2𝑢𝑖 (𝑡𝑘 )−𝑢𝑖+1 (𝑡𝑘 )
Donc −𝜇 ≈𝜇 avec 𝜀(𝑑𝑥) ≃ 0
𝜕𝑥 2 (∆x)2

26
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

On obtient le schéma suivant


𝑑𝑢𝑖 (𝑡𝑘 ) −𝑢(𝑥𝑖−1 , 𝑡𝑘 ) + 2𝑢(𝑥𝑖 , 𝑡𝑘 ) − 𝑢(𝑥𝑖−1 , 𝑡𝑘 )
+𝜇 =0
𝑑𝑡 (∆x)2

3-) Donnons la discrétisation en temps avec le schéma d’Euler explicite


𝑢1 (𝑡𝑘 ) 2 -1 0 0 𝑢1 (𝑡𝑘 ) 0
-1 2 -1 0
𝑢2 (𝑡𝑘 ) 𝑢2 (𝑡𝑘 ) 0
. 0
𝑑 𝜇
. + (∆x)2 =
𝑑𝑡
.
𝑢𝑁−2 (𝑡𝑘 ) -1
0
(𝑢𝑁−1 (𝑡𝑘 )) 0 0 -1 2 𝑢𝑁−1 (𝑡𝑘 ) 0

Posons
𝑢1 (𝑡𝑘 )
𝑢2 (𝑡𝑘 ) 2 −1 ⋯ ⋯ 0
. −1 2 −1 … 0
𝑑 𝜇
𝑈= . 𝐴 = (∆x)2 0 −1 ⋱ ⋱ 0
𝑑𝑡
. 0 ⋱ ⋱ −1
𝑢𝑁−2 (𝑡𝑘 ) (0 0 −1 2)
(𝑢𝑁−1 (𝑡𝑘 ))
𝑑(𝑈(𝑡𝑘 ))
Alors + 𝐴𝑈 = 0
𝑑𝑡
𝑑(𝑈(𝑡𝑘 ))
= −𝐴𝑈
𝑑𝑡
𝑑𝑈(𝑡𝑘 )
= 𝑓(𝑡, 𝑈) ⇒ 𝑓(𝑡𝑘 , 𝑈(𝑡𝑘 ) ) = −𝐴𝑈(𝑡𝑘 )
𝑑𝑡

𝑈 𝑛+1 = 𝑈 𝑛 + ∆𝑡𝑓(𝑡𝑛 , 𝑈 𝑛 )

𝑈 𝑛+1 = 𝑈 𝑛 − ∆𝑡𝐴𝑈 𝑛

4-) Itération
𝑈 𝑛+1 = 𝑈 𝑛 − ∆𝑡𝐴𝑈 𝑛
𝑈 𝑛+1 = (𝐼 − ∆𝑡𝐴)𝑈 𝑛
Posons = (𝐼 − ∆𝑡𝐴) = 𝑀
𝑈 𝑛+1 = 𝑀𝑈 𝑛 avec 𝑛 ∈ {0,1,2, … , 𝑀}
5-) Condition de stabilité du schéma obtenu
27
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

2∆𝑡 1
< Pour θ = 0 on a :
(∆𝑥)2 1−2𝜃

2∆𝑡
<1
(∆𝑥)2

6-) Inconvénient de ce schéma lorsque ∆x → 0


1
Si ∆x → 0 alors deviendra de plus en grand ,le schéma sera donc
(∆𝑥)2
instable.
7-) Ecriture d’un programme Scilab qui calculera Un pour n∆ ≤ T(voir
annexe)
8-) Par des choix de ∆t et ∆x, illustration de la stabilité et l’instabilité du
schéma
en affichant la solution en divers pas de temps. On fixe pour les calculs
µ = 1, L = 10, T = 1

28
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Cas de la stabilité

29
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Cas de l’instabilité

30
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Conclusion
Avec le problème 1, on a pu établir les tracé de la méthode du rectangle, du
trapèze de Simpson en fonction du nombre de sous-intervalle (abscisse), cela
nous permis de dire que La solution exacte est 2.95 .Lorsque le pas augmente la
valeur de la solution approchée se rapproche de la valeur de la solution exacte.
Cela s’observe pour toutes les méthodes.
Le problème 2, nous permis d’évaluer les formules de quadrature d’Euler
explicite, implicite et de RUNGE KUTTA, pour finalement dire que Nous
remarquons pour toutes ces valeurs du pas h donné la méthode de Runge Kutta
(d’ordre 4) est toujours plus proche de la solution exacte par rapport aux deux
autres méthodes. De plus, lorsque le pas diminue les courbes représentatives des
solutions approchées convergent vers la solution exacte c’est à dire la
diminution du pas augmente la précision des méthodes ou des formules utilisées
comme approche.
Le problème 3, à consterné la méthode de différence finies ainsi nous avons pu
conclure sur la stabilité et l’instabilité du schéma.

31
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

Annexe des codes

Problème 1
Code du Premier tracé

clear; clf();
function y=f(x) // la fonction intervenant dans l'intégrale
y=1 ./(1+x^2)
endfunction
//on fait tracer la courbe de f en vert
a=-10:0.1:10
plot2d(a,f(a),style=3)

Code du deuxième tracé

a=-10;
b=10;

function res=f(x)
res=1/(1+x^2);
endfunction

function meth_rect=meth_rect(N)// methode du rectangle


h=(b-a)/N;
meth_rect=0;
for i=1:N
meth_rect=meth_rect+h*f(a+h*(i-0.5));
end

endfunction
for i=1:6
T(i)=meth_rect(10*i);
end
N=[10:10:60]';
plot2d(N,T(N/10),style=color("red3"));// affichage methode du rectangle

32
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

function meth_trap=meth_trap(N)// methode du trapeze


h=(b-a)/N;
meth_trap=0;
for i=1:N
meth_trap=meth_trap+(h/2)*(f(a+(i-1)*h)+f(a+i*h));

end
endfunction
for i=1:6
T(i)=meth_trap(10*i);
end
N=[10:10:60]';
plot2d(N,T(N/10),style=color("green"));// affichage methode du trapeze

function meth_simp=meth_simp(N)// methode de Simpson


h=(b-a)/N;
meth_simp=0;
for i=1:N
meth_simp=meth_simp+(h/6)*(f(a+(i-1)*h)+f(a+i*h)+4*f((2*a+(2*i-1)*h)/2));

end
endfunction
for i=1:6
T(i)=meth_simp(10*i);
end
N=[10:10:60]';
plot2d(N,T(N/10),style=color("blue"));// affichage methode de Simpson

hl=legend(['rectangle';'trapeze';'simpson'],('in_upper_left'));

Problème 2
Code premier trace

x=[0:0.1:10];
plot2d(x,exp(atan(x)),style=color("blue4"));
legend('solution exacte','in_upper_left');

Code deuxième tracé


function y=f(t)
y=exp(atan(t));

endfunction
a=0;
b=10;

33
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

h=(b-a)/100;
X=a:h:b;
Y=f(X);
//plot(X,Y);
//title(SOLUTION EXACTE")
// solutions approchees

function z=g(t, y)
z=y/(1+t.^2);
endfunction
// solution approchee d'Euler Explicite
function y=EulerExplicite(h)
N=10/h;
t=0:h:10;
y=zeros(N+1);
y(1)=1;
for i=1:N
y(i+1)=y(i)+h*g(t(i),y(i));
end
endfunction
// solution approchee d'Euler Implicite
function y=EulerImplicite(h)
N=10/h;
t=0:h:10;
y=zeros(N+1);
y(1)=1;
for i=1:N

y(i+1)=y(i)/(1-h/(1+(t(i+1)).^2));
end
endfunction
// solution approchee RK4
function y=RK4(h)
N=10/h;
t=0:h:10;
y=zeros(N+1);
y(1)=1;
for i=1:N
t1=t(i);
y1=y(i);
K1=h*g(t1,y1);
t2=t1+h/2;
y2=y1+K1/2;

34
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

K2=h*g(t2,y2);
t3=t1+h/2;
y3=y1+K2/2;
K3=h*g(t3,y3);
t4=t1+h;
y4=y1+K3;
K4=h*g(t4,y4);
y(i+1)=y(i)+(K1+2*K2+2*K3+K4)/6;
end
endfunction

//tracer de la solution exacte et des solutions approchees obtenues avec


eulerexplicite, implicite et RK4 pour h=0.05
h=0.05;
t=a:h:b;
//Exacte1=f(t);
//Explicite1=EulerExplicite(h);
//Implicite1=EulerImplicite(h);
//RK1=RK4(h);

//plot2d(t',[f(t)' EulerExplicite(0.05) EulerImplicite(0.05)


RK4(0.05)],style=[color("magenta"),color("black"),color("red"),color("blue")],
leg="solutionexacte@EulerExpliciye@EulerImplicite@RK4");
//title("pas h=0.05");
//tracer de la solution exacte et des solutions approchees obtenues avec
eulerexplicite, implicite et RK4 pour h=0.05
h=0.1;
t=a:h:b;
//Exacte2=f(t);
//Explicite2=EulerExplicite(h);
//Implicite2=EulerImplicite(h);
//RK2=RK4(h);

//plot2d(t',[f(t)' EulerExplicite(0.1) EulerImplicite(0.1)


RK4(0.1)],style=[color("magenta"),color("black"),color("red"),color("blue")],l
eg="solutionexacte@EulerExpliciye@EulerImplicite@RK4");
//title("pas h=0.1");
//tracer de la solution exacte et des solutions approchees obtenues avec
eulerexplicite, implicite et RK4 pour h=0.05
h=0.5;
t=a:h:b;
//Exacte3=f(t);
//Explicite3=EulerExplicite(h);

35
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

//Implicite3=EulerImplicite(h);
//RK3=RK4(h);

//plot2d(t',[f(t)' EulerExplicite(0.5) EulerImplicite(0.5)


RK4(0.5)],style=[color("green"),color("black"),color("red"),color("blue")],leg
="solutionexacte@EulerExpliciye@EulerImplicite@RK4");
//title("pas h=0.5");

//tracer de la solution exacte et des solutions approchees obtenues avec


eulerexplicite, implicite et RK4 pour h=0.05
h=0.9;
t=a:h:b;
//Exacte4=f(t);
//Explicite4=EulerExplicite(h);
//Implicite4=EulerImplicite(h);
//RK4=RK4(h);

plot2d(t',[f(t)' EulerExplicite(0.9) EulerImplicite(0.9)


RK4(0.9)],style=[color("green"),color("red"),color("blue"),color("black")],leg="
solutionexacte@EulerExplicite@EulerImplicite@RK4");
title("pas h=0.9");

Problème 3
Code premier tracé
//CODE POUR CALCULER Un

N=201;//espace
M=1010;//temps
dt=0.001; // choix du pas en temps
dx=0.1;//choix du pas en espace
mu=1;
a=(mu*dt)/(dx*dx);

U=zeros(N,M);

//conditions initiales
for i=1:90
U(i,1)=0;
end

36
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

for i=91:111
x=-1+0.1*(i-91);
U(i,1)=1-x^2;
end

for i=112:201
U(i,1)=0;
end

//schéma d'Euler explicite


for n=1:M
for i=2:N-1
U(i,n+1)=a*U(i-1,n)+(1-2*a)*U(i,n)+a*U(i+1,n);
end
end

Code deuxième tracé

//ILLUSTRATION DE LA STABILITE

x=0;
t=0;
N=201;//espace
M=1010;//temps
dt=0.001; // choix du pas en temps
dx=0.1;//choix du pas en espace
mu=1;
a=(mu*dt)/(dx*dx); // a=0.1 inferieur à 0.5 donc schema stable

y=zeros(N,M);

//conditions initiales
for i=1:90
y(i,1)=0;
end

for i=91:111
x=-1+0.1*(i-91);
y(i,1)=1-x^2;

37
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

end

for i=112:201
y(i,1)=0;
end

//schéma d'Euler explicite


for k=1:M
for i=2:N-1
y(i,k+1)=a*y(i-1,k)+(1-2*a)*y(i,k)+a*y(i+1,k);
end
end
i=[1:1:201]';

//affichage à differents instants

plot2d((i-101)/10,y(i,1),style=color("yellow")) ;
plot2d((i-101)/10,y(i,201),style=color("blue4"));
plot2d((i-101)/10,y(i,401),style=color("green4"));
plot2d((i-101)/10,y(i,601),style=color("red2"));
plot2d((i-101)/10,y(i,801),style=color("magenta3"));
plot2d((i-101)/10,y(i,1001),style=color("black"));

hl=legend(['t=0s';'t=0.2s';'t=0.4s';'t=0.6s';'t=0.8s';'t=1s'],('in_upper_left'));

Code troisième tracé


//ILLUSTRATION DE L'INSTABILITE

x=0;
t=0;
N=201;//espace
M=1010;//temps
dt=0.008; // choix du pas en temps
dx=0.1;//choix du pas en espace
mu=1;
a=(mu*dt)/(dx*dx); // a=0.8 superieur à 0.5 donc schema instable

y=zeros(N,M);

//conditions initiales

38
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

for i=1:90
y(i,1)=0;
end

for i=91:111
x=-1+0.1*(i-91);
y(i,1)=1-x^2;
end

for i=112:201
y(i,1)=0;
end

//schéma d'Euler explicite


for k=1:M
for i=2:N-1
y(i,k+1)=a*y(i-1,k)+(1-2*a)*y(i,k)+a*y(i+1,k);
end
end
i=[1:1:201]';

//affichage à differents instants

plot2d((i-101)/10,y(i,1),style=color("BLUE")) ;
plot2d((i-101)/10,y(i,125),style=color("GREEN"));

hl=legend(['t=0s';'t=1s'],('in_upper_left'));

39
Error! Use the Home tab to apply Titre 1 to the text that you want to appear here.

40

Vous aimerez peut-être aussi