80
6
•
Moindres carrés
Pour cela,ondiscrétise ]0, 1[ par x i = ih avec h =
1
n +1
et i = 1 ,..., n et on minimise
J ( p ) = p (0)
2
+ p (1)
2
+
n
i = 1
− p
( x i )+ p ( x i ) − f ( x i )
2
(6.1)
On a
p (0) =
M
j = 1
a j w j (0) = a 1
p (1) =
M
j = 1
a j
p
( x i ) =
M
j = 3
a j ( j − 1)( j − 2)x
j − 3
i
p ( x i ) =
M
j = 1
a j x
j − 1
i
On construit la matrice A pour que le problème (6.1) se ramène à:min
a
A a − b
2
.Donc
A =
⎛
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎝
10...
...
0
. . .
. . .
. . .
− ( j − 1)( j − 2)x
j − 3
i
+ x
j − 1
i
. . .
11...
...
1
⎞
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎠
M colonnes
, b =
⎛
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎝
0
f ( x 1 )
. . .
. . .
f ( x n )
0
⎞
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎟
⎠
Attention aux décalages d’indice, Matlab n’acceptant pas lesindices 0.
1. Créeru nt ableau d’abscisses x i = ih pour 1 i n .P uis construire la matrice A .
Sauvegarder sous EQD1.m.T ester avec M = 4, n = 6. Afficher A .
✞
☎
>> EQD1
A=
1.0000
000
1.0000
0.1429
-1.9796
-0.8542
1.0000
0.2857
-1.9184
-1.6910
1.0000
0.4286
-1.8163
-2.4927
1.0000
0.5714
-1.6735
-3.2420
1.0000
0.7143
-1.4898
-3.9213
1.0000
0.8571
-1.2653
-4.5131
1.0000
1.0000
1.0000
1.0000
✝
✆
2. Construire le second membre b .Pour cela créer un fichier function f.m .Afficher b .Sauvegarder sous EQD2.m.T ester avec M = 4, n = 6et f ( x ) = exp(x ).
Précédent

- 64/188

Suivant