Beruflich Dokumente
Kultur Dokumente
numriques et Solution
M.LICHOURI
11 mai 2013
1 Exercice 1 : (4pts)
Ecrire un script(programme) Matlab permettant de calculer la racine de la
fonction f pxq x3 2x 3 situe dans l'intervalle [0 3] par la mthode de
dichotomie.
Indications : On prendra un test d'arrt de la forme |xn 1 xn | 106 .
Listing 1 Exercice 1
1 clc;
2 clear;
3 a=0;
4 b=3;
5 f=inline( 'x.^3-2*x+3')
6 eps=0.000001;
7 nb=0;
13 x=(a+b)/2;
14 if f(a)f(x)<0
15 b=x;
16 else
17 a=x;
18 end
19 fprintf('%i | %10.5f | %10.5f \n',nb,x,f(x))
20 end
21 end
2 Exercice 2 : (4pts)
Soit le polynme P pxq x3 6x2 72x 27.
Listing 2 Exercice 2
1 >> p=[1
6 72 27]
2
3 p =
4
5 1
6 72 27
6
7 >> x=[
10:0.01:10];
8 >> f=x.^3
6 x.^2
72 x
27;
9 >> plot(x,f)
10 >> title('Courbe Representative de P(x)')
11 >> polyval(p,5)
12
13 ans =
14
15 412
16
17 >> roots(p)
18
19 ans =
20
21 12.1229
22 5.7345
23 0.3884
24
25 >>
3 Exercice 3 : (12pts)
Soit le systme liniaire suivant :
$ x1+-4x2-x3-x4=12,
'
& x1+7x2+x3-2x4=16,
'
% x1+4x2-x3+2x4=1 ,
3x1-10x2-2x3+5x4=-15,
Listing 3 Exercice 3
1 >> A=[1
4 1 1; 1 7 1 2; 1 4 1 2; 3
10 2 5]
2
3 A =
4
5 1
4 1 1
6 1 7 1 2
7 1 4 1 2
8 3
10 2 5
9
10 >> b=[12 16 1 15]'
11
12 b =
13
14 12
15 16
16 1
17 15
18
19 >> A(2:3,2:3)
20
21 ans =
22
23 7 1
24 4 1
25
26 >> A(1:3,2:4)
27
28 ans =
29
30 4 1 1
31 7 1 2
32 4 1 2
33
34 >> A(2,3)
35
36 ans =
37
38 1
39
40 >> A(1:4,3)
41
42 ans =
43
44 1
45 1
46 1
47 2
48
49 >> A(1,:)
50
51 ans =
52
53 1
4 1 1
54
55 >> diag(A)
56
57 ans =
58
59 1
60 7
61 1
62 5
63
64 >> D= eye(4,4)AA';
65 >> eye(4,4)
66
67 ans =
68
69 1 0 0 0
70 0 1 0 0
71 0 0 1 0
72 0 0 0 1
73
74 >> A
75
76 A =
77
78 1
4 1 1
79 1 7 1 2
80 1 4 1 2
81 3
10 2 5
82
83 >> A'
84
85 ans =
86
87 1 1 1 3
88 4 7 4 10
89 1 1 1 2
90 1 2 2 5
91
92 >> D= eye(4,4)AA'
93
94 D =
95
96 18 30 12 50
97 30 54 24 79
98 12 24 21 25
99 50 79 25 137
100
101 >> B=[ones(4,2) 0.5 ones(4,2)/0.5];
103
104 ans =
105
106 1 1
107 1 1
108 1 1
109 1 1
110
111 >> ones(4,2) 0.5
112
113 ans =
114
115 0.5000 0.5000
119
120 >> ones(4,2)/0.5
121
122 ans =
123
124 2 2
125 2 2
126 2 2
127 2 2
128
129
>> B=[ones(4,2) 0.5 ones(4,2)/0.5]
130
131 B =
132
133 0.5000 0.5000
2.0000 2.0000
137
138 >> %le produit de A et B est possible car le nombre
139 >> % de colonnes de A est 4
140 >> % il est egale au nombre de ligne de B.
141 >> det(A);
142 >> inv(A);
143 >> x=A\b
144
145 x =
146
147 5.9683
148 0.4603
149 22.5556
150 14.6825
151
152 >>