École Nationale Polytechnique de Constantine
Analyse Numérique
2ème année classe préparatoire 2022-2023
Série de T. P. No 1
Exercice 1.
En utilisant la méthode de dichotomie on disère trouver la racine α de la fonction
10
f (x) = x + ex + −5
1 + x2
1. Trouver graphiquement un encadrement de la racine de f .
2. Écrire un programme Matlab pour calculer une approximation de α en prenant une
tolérance égal à 10−8 .
3. Quel est le nombre maximal d’itérations nécessaires pour atteindre une précision sur
la racine au rang de 10−3 (Utiliser un programme Matlab pour le trouver).
Solution.
% %%% Question 1%%%%%%%%%%%%
t = -1:0.001:1;
f=@(t)(t + exp ( t ) +(10./(1+ t .^2) ) -5) ;
plot (t ,f ( t ) )
grid on
xlabel ( 't ')
ylabel ( 'f ( t ) ')
title ( ' localisation de z é ro de f ')
% %%%%%%%%% Question 2%%%%%%%%%%%
a = -1; b = -0.8; x =( a + b ) /2;
k =0; tol =10^( -8)
while (( abs (b - a ) ) /2 > tol & f ( x ) ~=0)
k=k +1;
if ( f ( a ) * f ( x ) <0)
b=x;
else
a=x;
end
x =( a + b ) /2;
end
k
x
f(x)
1
Exercice 2.
Nous allons résoudre l’équation : f (x) = x + ex + 1. Nous choisissons x0 = −1/2 comme
valeur initiale. Écrire un code Matlab, portant sur l’implémentation de la méthode de point
fixe, en suivant les étapes suivantes :
1. Le critère d’arrêt est : |xn+1 − xn | < ε, xn étant la solution approchée et ε la tolérance
considérée.
2. Afficher la solution approchée xn , en prenant ε = 10−9 .
3. Afficher le nombre d’itérations conduisant à la solution approchée.
4. Afficher sur le même graphe, la fonction f (x) et la solution approchée xn .
Solution.
x0 = -0.5;
g=@(t)(- exp ( t ) -1) ;
eps =10^( -9) ;
x1 =g( x0 ) ;
k =0;
while ( abs ( x1 - x0 ) > eps )
x0 = x1 ;
x1 = g ( x0 ) ;
k=k +1;
end
k
x1
x = -2:0.001:0;
f=@(t)(t + exp ( t ) +1) ;
plot (x ,f ( x ) )
hold on
plot (x1 , f ( x1 ) ,'+ ')
Exercice 3. Voici une application de la méthode de Guass
A =[2 1 2 ;6 4 4 ;3 2 -1];
b =[10;26;4];
n= length ( A ) ;
for k =1: n -1
for i = k +1: n
if A (k , k ) ==0
c = A (k ,:) ;
A (k ,:) = A ( k +1 ,:) ;
A ( k +1 ,:) = c ;
end
m = A (i , k ) / A (k , k ) ;
2
b ( i ) = b ( i ) -m * b ( k ) ;
for j =1: n
A (i , j ) = A (i , j ) -m * A (k , j ) ;
end
end
end
x(n)=b(n ) / A (n , n ) ;
for i=n -1: -1:1
S =0;
for j = i +1: n
S = S + A (i , j ) * x ( j ) ;
x ( i ) =(1/ A (i , i ) ) *( b ( i ) -S ) ;
end
end
x
A
b