Académique Documents
Professionnel Documents
Culture Documents
:
Réalisé par : MOHAMMED BABI (groupe :1)
I. TP1 :
Exercice 1 :
On considère les trois fonctions suivantes :
F1(x)=sin(x)*√ x+1
F2(x)=exp(x)+x²
F3(x)=1/1+IxI
1)
>>x=0:0.1:1
x=
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000
>> f1=sin(x).*sqrt(x+1)
f1 =
0 0.1047 0.2176 0.3369 0.4608 0.5872 0.7142 0.8400 0.9624 1.0797 1.1900
>> plot(x,f1)
>> f2=exp(x)+x.*x
f2 =
1.0000 1.1152 1.2614 1.4399 1.6518 1.8987 2.1821 2.5038 2.8655 3.2696
3.7183
>> plot(x,f2)
>> f3=1/1+abs(x)
f3 =
1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000
2.0000
plot(x,f3)
Présentation de trois fonctions dans la même figure :
>> plot(x,f1);
>> plot(x,f2);
>> plot(x,f3);
a=impact('max')
b=impact('max')
else c=impact('max')
end
2) fonction[P]=parente(a)
If mod(a,2)==0
else
end
end
Exercice 3 :
1)
A- (condition : i<100)
5
(While) ∑ ¿1+2+3+4+5
i=1
i =1 ; s=0
while (i<=5)
s= s + i
i=i + 1
end
for i=1 :5
s=s + i
end
B-
(while) : i=1 ;s=0 ;
while (i<=100)
s=s + 2*sin(i)
i=i+1
end
100
s=0 ;
for i=1 :100
s=s+2*sin(i) ;
end
2)
for i=60 :100
if mod(i,2)==0
i
end
end
Exercice4 :
>> U0=1;
V=[];
U1=0.5*U0+(1/5)
e=abs(U1-U0);
while (e>10^(-3))
U0=1 ;
>> U1=0.5*U0+(1/5);
>> e=abs(U1-U0);
>> v=[v u0]
Exercice5 :
1) U1 est une matrice triangulaire sup de U
U1=triu(U) ;
A=I-U*U ;
A=eye(4)-U.*U ;
Série TP2 :
I. Méthode d’Horner :
Function S=Horner(a,x)
K=length(a) ;
S=a(k) ;
For i=k-1 :-1 :1
S=S*x+a(i) ;
end
S ;
End
II. Matrice de Vandermonde :
function a= vandermande(x,y)
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
n=length(x);
n=length(y);
A=zeros(n);
for i=1:n
for j=1:n
A(i,j)=x(i)^((j-1));
end
end
a=inv(A)*y;
end
Série TP5 :
I) Méthode de Gauss :
C’est une méthode pour transformer un système équivalant qui est
triangulaire et est donc facile à résoudre.
-Algorithme de Gauss :
function x = Gauss(A,b)
%UNTITLED8 Summary of this function goes here
% Detailed explanation goes here
x=[];
U=[A b];
n=length(U);
for k=1:n-2
for i=k+1:n-1
w=U(i,k)/U(k,k);
for j=k:n-1
U(i,j)=U(i,j)-(w*U(k,j));
end
end
end
for i=n-1:-1:1
s=0;
for j=i+1:n-1
s=s+(U(i,j)*x(j));
end
x(i)=(U(i,i)-s)/U(i,i);
end
end
I) Méthode de RLU :
function x = RLU(A,b)
%UNTITLED11 Summary of this function goes here
% Detailed explanation goes here
n=length(A);
L=[];
U=[];
[L,U]=decomposition(A);
y=[];
y(1)=b(1);
for i=2:n
s=0;
for k=1:i-1
s=s+(L(i,k)*y(k));
end
y(i)=b(i)-s;
end
x=[];
x(n)=y(n)/U(n,n);
for i=n-1:-1:1
s=0;
for j=i+1:n
s=s+(U(i,j)*x(j));
end
x(i)=(y(i)-s)/U(i,i);
end
x
end