Algorithme :
Obtenir racineAvant (une racine de départ)
nbIterations = 1
Répéter
Si (|fPrime(racineAvant)| <= EPSILON )
On termine : ne peut pas diviser par zero
Continuer = faux (pour quitter)
Sinon
racine = racineAvant-( f(racineAvant) / fPrime(racineAvant))
continuer = |racine – racineAvant| > EPSILON
Si (continuer)
Incrémenter nbIterations
racineAvant = racine
Tant que (continuer ET nbIter <= MAX_ITER)
Si (nbIter > MAX_ITER)
Afficher "On n'a pas encore la convergence vers la racine"
Manipulation :
1-
Cos(xy)=1/2
x²-exp(-y)=3
Programme en matlab :
clear
all; close all; clc ;
x=10;
y=10;
variable=[x;y];
t=[0.5;3];
delta=1;
iteration=1;
while
(abs(delta) > 1e-20)
f=[cos(variable(1)*variable(2));
variable(1)^2-exp(-variable(2))];
jacop=[-variable(2)*sin(variable(1)*variable(2))
-variable(1)*sin(variable(1)*variable(2)); 2*variable(1) exp(-variable(2))];
delta=(jacop)*(t-f);
variable=variable+delta;
iteration=iteration+1;
end
format long
x_optimise=variable(1)
y_optimise=variable(2)
résultat :
x =
-0.166656653479945
y =
-0.014807086255684
2-
3x+cos(yz)-1/2=0
x²-81(y+0.1)²+sin(z)+1.06=0
Programme en matlab :
clear all; close all; clc ;
x=5;
y=5;
z=5;
variable=[x;y;z]; t=[0.5;-0.25;-9.4719];
delta=1; iteration=1;
while (abs(delta)
> 1e-30)
f=[3*variable(1)+cos(variable(2)*variable(3));
variable(1)^2-81*variable(2)*variable(2)-16.2*variable(2)+sin(variable(3));
exp(-variable(1)*variable(2))+20*variable(3)];
jacob=[3
variable(3)*sin(variable(2)*variable(3))
variable(2)*sin(variable(2)*variable(3));
2*variable(1)
-162*variable(2)-16.2 cos(variable(3));
-variable(2)*exp(-variable(1)*variable(2))
-variable(1)*exp(-variable(1)*variable(2)) 20];
delta=inv(jacob)*(t-f);
variable=variable+delta;
iteration=iteration+1;
end
format long
x=variable(1)
y=variable(2)
z=variable(3)
résultat :
x =
-0.166656653479945
y =
-0.014807086255684
z = -0.523471767141206