Vous êtes sur la page 1sur 6

Facha mohammed

Kaddour djebbar faris


Haddadi kocila

Groupe: 03
Point Fixe
clear;clc;
syms x
d=input('f(x)= \n')
f=inline(d);
n=input('n= \n')
eps=input('E= \n')
x0=input('x0 \n')
x=x0
for i=0:n
y=x
x=f(x);
end

solution

f(x)=

sin(x)+0.25

d=

sin(x) + 1/4

n=

20

n=

20

E=

10^(-7)

eps =

1.0000e-07

x0

3*pi/4

x0 =

2.3562

x=
2.3562

y=

2.3562

y=

0.9571

y=

1.0675

y=

1.1260

y=

1.1527

y=

1.1639

y=

1.1683

y=

1.1701

y=

1.1708

y=

1.1711

y=

1.1712

y=

1.1712

y=

1.1712

y=

1.1712

y=
1.1712

y=

1.1712

y=

1.1712

y=

1.1712

y=

1.1712

y=

1.1712

y=

1.1712

Méthode de newton
clear;clc;
syms x
f=exp(x)-3*x; %input('f(x)= ');
df=diff(f);
newton=x-f/df;
f=inline(f);
df=inline(df);
newton=inline(newton);
x0=1; %input('x0= ');
n=20; %input('n= ');
eps=0.001; %input('E= ');
k=0;
while k<n;
x1=newton(x0);
fprintf('\n%d %6.3f %6.3f %6.3f\n',k,x0,x1,abs(x1-x0));
if abs(x1-x0)<eps
x0
break
end
x0=x1;
k=k+1;
end

Solution  :
0 1.000 0.000 1.000

1 0.000 0.500 0.500

2 0.500 0.610 0.110

3 0.610 0.619 0.009

4 0.619 0.619 0.000

x0 =

0.6190

Exercice 03 :
clc; clear all
syms x
f = input('donner la fonction f(x)=')
df=diff(f);
nw=x-f/df;
f= inline(f);
df= inline(df);
nw= inline(nw);
x0= input('donner le premier nombre:')
n=input('n= ');
e= input('donner la valeur de eps=');
k=0;
while k<n
x1= nw(x0);
fprintf('\n%d %12.7f %12.7f\n' ,k,x0,x1,abs(x1-x0));
if abs(x1-x0)<e;
disp('la racine de la fonction est:')
fprintf('\n%d %12.7f/n',k,x1)
break;
end
x0=x1;
k=k+1;
end

Solution

donner la fonction f(x)=x^3-4*x+1

f=

x^3 - 4*x + 1

donner le premier nombre:-2.5

x0 =
-2.5000

n= 20

donner la valeur de eps=10^(-6)

0 -2.5000000 -2.1864407

3.135593e-01

1 -2.1864407 -2.1181177

6.832299e-02

2 -2.1181177 -2.1149145

3.203227e-03

3 -2.1149145 -2.1149075

6.918979e-06

4 -2.1149075 -2.1149075

3.224887e-11 la racine de la fonction est:

4 -2.1149075/n>>

Exercice 04 :
clear; clc;
syms x
f=exp(x)-3*x;
df=diff(f);
f=inline(f);
df=inline(df);
n=10; x0=1;eps=1.e-3;
xx=newton(x0,n,eps,f,df)

function x=newton(x0,n,eps,f,df)
x=x0;
i=1;
while i<=n
x=x-f(x)/df(x);
if abs(x-x0)<=eps
x=x0;
break
end
i=i+1;
end
end

Solution
xx =

0.6191

Vous aimerez peut-être aussi