• Aucun résultat trouvé

ASI 3 Méthodes numériques pour l’ingénieur

N/A
N/A
Protected

Academic year: 2021

Partager "ASI 3 Méthodes numériques pour l’ingénieur"

Copied!
26
0
0

Texte intégral

(1)

ASI 3

Méthodes numériques pour l’ingénieur

la méthode des moindres carrés Le point de vue numérique

(factorisation QR)

(2)

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 -4

-3 -2 -1 0 1 2

Approximation/interpollation:

moindres carrés

 

 

carrés moindres

des

équationset inconnues( ) approximation au sens )

( min

)

(

ion approximat

tion interpolla

)

(

, : données

1

2 1

1 1

1 , 1

k

n

i i i

i k

j

ij j i

i

k j

j j

n i i

i

n n

y x

f y

x y

x f

n k

n x k

x f

y x

 

f(x)

xi yi

(3)

Posons le problème matriciellement

 

 

 

 









k n n j k

n j n

k i i j k

i j i

k k j j

k k j j

x f x

x x

x f x

x x

x f x

x x

x f x

x x

) 1 ( )

1 ( )

1 2 ( 1

) 1 ( )

1 ( )

1 2 ( 1

) 2 1 2( )

1 2( )

1 2( 2 1

) 1 1 1( )

1 1( )

1 1( 2 1

...

...

...

...

...

...

...

...

i i

i n

k j

j x j x y

x

f 1,

1

1 pour , )

(

 

(4)

Posons le problème matriciellement

 

 

 

 









k n n j k

n j n

k i i j k

i j i

k k j j

k k j j

x f x

x x

x f x

x x

x f x

x x

x f x

x x

) 1 ( )

1 ( )

1 2 ( 1

) 1 ( )

1 ( )

1 2 ( 1

) 2 1 2( )

1 2( )

1 2( 2 1

) 1 1 1( )

1 1( )

1 1( 2 1

...

...

...

...

...

...

...

...

   

 

 









k n j n

n n

k i j i

i i

k j

k j

x f x

x x

x f x

x x

x f x

x x

x f x

x x

...

...

1

...

...

1

...

...

1

...

...

1

) 1 ( )

1 ( )

1 (

) 1 ( )

1 ( )

1 (

) 2 1 2( )

1 2( )

1 2(

) 1 1 1( )

1 1( )

1 1(

 =

i i

i n

k j

j j

y x

x x

f

, 1 1

1

, pour

)

(

  Xa = f

(5)

Approximation au sens des moindres carrés

 

 

 

 

 

 

 

 

 

 

 

 

 



 

 

n i

ij i

k n

i

ij i

n i

ij i k

i j

j

n

i i

k j

ij j n

i i i

x y x

x x

y J x

k J j

J

y x

J J

y x

f

1

1

1 1

1 1

1

1 1

1

1

2

1

1 1

2

0 2

,..., 1

; 0

*) (

) ( argmin

* : principe

) ( avec

) ( min )

( min

 

 

Système linéaire de k équations et k inconnues

(6)

Approximation : version matricielle

 

X y

J

X X

X y

X J

y X

e J

y y y

x x

x x

x x

e e e

y X

e

y x

y x

f e

y x

J J

y x

f

n i

k j ik

i

ik i

k

n i

i k

j

ij j i

i i

n

i i

k j

ij j n

i i i

' '

0 )

( ' '

2 )

( '

) (

1 1 1

) (

) ( avec

) ( min )

( min

2 2

1 1

1 1 1 1 1 1

0

1

2

0 1

2















































 

 

 

 

Système linéaire de k équations et k inconnues Erreur

d’approximation

(7)

Approximation : version matricielle

 

X y

J

X X

X y

X J

y X

e J

y y y

x x

x x

x x

e e e

y X

e

y x

y x

f e

y x

J J

y x

f

n i

k j ik

i

ik i

k

n i

i k

j

ij j i

i i

n

i i

k j

ij j n

i i i

' '

0 )

( ' '

2 )

( '

) (

1 1 1

) (

) ( avec

) ( min )

( min

2 2

1 1

1 1 1 1 1 1

0

1

2

0 1

2















































 

 

 

 

Système linéaire de k équations et k inconnues Erreur

d’approximation Matrice de Vandermonde

(1735-1796)

(8)

Forme quadratique

   

 

y X X

XG h J

y X

X J

h G

J

y y y

X X

X

y X

y X

y X

e J

 

' '

'( ) 2 ' '( ) 0 '

2 2 '

min 1 )

( min

' '

' 2 '

'

) (

' 2 2





Équations normales

(9)

Point de vue algèbrique (géométrique)

X représente une application linéaire de Rp sur Rn Projection de y (les résultats des expériences)

sur le sous espace vectoriel engendré par X (les données)

 

 

 

 

0

'

ˆ est orthogonalà ' ˆ 0

projecteur un

est '

' que montrons

' '

' ˆ

1 1

  

y X

XX y y X

y y

X X

X X

Xy X

X X

X y

y

 

X0 R p

Im 

Rn

y y

 

X y

e  ˆ    

p

j X j j

X

1

)

(

(10)

Comment résoudre le problème des moindres carrées ?













2 2

2

1 1

1

1 1

1

1 1

1

0

0

0 0

0 0

1 1

1

X X

X T

Rang(X’X) = Rang(X) = 3

cond(X’X) = cond(X)*cond(X) régulière est

machine, précision

si précision machine, est singulière si 2

XX T X





Il faut mieux travailler sur X que sur X’X … si possible !

(11)

Un principe, deux idées

ire) (triangula

' '

' : ainsi

avec

ion factorisat

y Q R

y X Xa

X

I Q'Q

QR X

R

G

0

HH

R 0

X

X

Orthogonalisation de Schmidt Orthogonalisation de Householder QR

X R

HX    Car H orthogonale

Matrice orthogonale

1 p

1

n

1

n

(12)

Base orthogonale (Schmidt)

y G

R GR G GG y

G GG y

GR y

GG X

y GGX y y

I G

G

R GR G

X

'

' ' '

' '

' ˆ '

'

supérieure ire

triangula :

e

orthogonal base

:

 

 





 

 

R

G X

0

G,R = decompose(A) x = triang(R,G’b) Fonction x = mmc(A,b)

(13)

Décompose : X=GR

 

 

( ) (( ))

1 1

) ( ) ( ) ( )

( )

(

) 2 (

) 2 ) (

2 ( )

1 ( ) 1 ( ) 2 ( )

2 ( )

2 (

) 1 1 (

) 1 1 ( )

1 (

~

~

;

~ '

~

~

;

~ '

1 avec

k k k

k i

i i

k k

k

G G G

G G

X X

G

G G G

G G

X X

G

k X X

k G

R

G X

0 Théorème :

dans tout espace vectoriel de dimension finie,

il existe des bases orthogonales

) (k

G X (k)

rki

~

{

(14)

Décompose : X=GR

fait

fait 2

/

; à jusqu' 1

pour fait

2

-

pour 1 jusqu'à ; 2 0

fait

fait

; à jusqu' 1

pour

fait

; à jusqu' 1

pour

0

1 à

jusqu' 1

pour

fait 0

; à jusqu' 1

pour

1 jusqu'à pour

g g

g n j

g g g

g x

g n

g j

g ps g

g n j

g a ps

ps n

ps j

k i

g n

j p

k

jk jk

kj kj

jk jk

jk

ji jk

jk

ji jk jk



 

  

 

 

Fonction G,R = décompose(A)

Problème d’accumulation d’erreurs d’arrondi

(15)

La méthode QR

Il est si facile le résoudre un système « triangulaire » !

Rx Q 1b b

Ax

QR

A   

Q « facilement » inversible et R triangulaire

Définition : on appelle matrice de Householder du vecteur normé u une matrice H de la forme suivante

2uuT I

H  

Propriété : une matrice de Householder est symétrique et orthogonale HTH=I

x Hx

Les transformations orthogonales « conservent » la norme

(16)

Orthogonalisation : X = QR

) , ( '

: norme la

concerve symétrique

1 Q n n

Q Q

x Qx

QQ

L

R

Q X

0

)

Q(k X (k) Transformation de Householder

'

e orthogonal matrice

une

est produit de deux matrices orthogonales le

...

...

LU) pour

(comme colonne

par colonne

) ' (

' ( orthogonale)

1

) 1 ( ) 2 ( )

( )

2 ( ) 1 (

1

H H

Q

H H

H H

H H

H Q

QRH R H R

H X

R HX

j k

k



Définir H

(17)

Householder et moindres carrés

 

ire) triangula (système

min

min

min min

carrées moindres

des problème

au appliquons

-

: norme la

concerve -

e orthogonal ation

transform une

est

T

y Q R

y Q R

y QR

Q

y QR

y X

I Q Q

x x

Q Q

Q

T T

T

T



(18)

Transformation de Householder

ation transform

première la

: axe d'

Symétrie

' 2 '

à e

orthogonaltransformation de Householder

e x y

e Hx

y Hy

y y y I yy

H

y

(19)

Transformation de Householder

Théorème : pour tout vecteur normé x, pour le vecteur unitaire e1 il existe une matrice H telle que : Hx=e1

Démonstration : posons

 

    

 

 

 

  

 

1

1

1 2

1

2 11 1 1

2 1 1 1 1

2 2 1 1

1 1

ou

d' 2 1

or 1

1 2

2

' '

' '

2

' 2

' 2

: effet en

question, la

à répond

' 2

alors

1 avec

e e

x x

Hx x

e x x

x

e x x e

x x

x e e xe

x e xx x

x e

x e

x x

x yy I

Hx

yy I

H

e e x

x y



    

    

     

 



 

(20)

Transformation de Householder

H(k) H

R 0

X

) (k

X 0

  

(1) (1)

 

' (1) (1)

) ' 1 ( )

1 ( )

1 ( )

1 ) (

1 (

) 1 ( )

1 ( )

1 ( )

1 ( ) 1 (

2

ation transform

première la

' 2 '

à e

orthogonaltransformation de Householder

e X

e X

e X

e I X

H

e X

y e

X H

y y I yy

H

y

 

H(k)

H = H~H(k) 1

1 0

0 ation

transform la kème

) ( ) (

) ( ) ) (

(

) 1 ( )

( )

(

' 2 '

~

~

k k

k k k

k k

k

y y

y I y

H

e X

y

(21)

Quels calculs ?

 

k j i ij

ij

n k

i k ij

i j

k k

k k

k k k

s y x

x

x y

s

X y

y X

y X y

y I y

X H

) ( )

(

) ( ) (

) ( ) (

) ( ) ) (

(

1 1 '

'

~ '



 

 





(22)

QR : algorithme de Householder

• Rangement des variables

• produit des H : (si besoin)

à la fin en commençant par le plus simple

• formules à l’étape k

 

n j

k p

i k

y s a

a

p j

k a

y s

a

a n

n i

k a

y a

y

a a

sign

ik j j

i j

i

n k

i k i j

i j

k k k

k k k

k

k k i

k i k

k k k

n k

i i k

k k k

1 et

1

pour

1 pour

1

1 pour

et

) (

) , (

,

) , ( ) , (

) , 2 (

) (

) , ( )

, ( )

(

2, ) ,

(

Diag(R)

yk

Partie

non encore factorisée

y1

k premières lignes de R

p n

(23)

L’algorithme QR

 

fait fait pour pour 0/ jusqu'jusqu'àà ;; fait fait

; à jusqu' 1

pour

si 0 alors finsi s ;

fait

pour jusqu'à ; s 0

1 jusqu'à pour

2

i ij

ij

i ij kk

kk

kk k

k

j jk j

y s x

x n k

si s

y x s

s n k

s i

p k

j x

xy s y x y s

s

x

y k n

j

p k

   

 



   





 

     Fonction Q,R = décomposeQR(X)

(24)

Retour des moindres carrées la méthode QR

 

c Rx

x b

Ax

d c b Rx

Q QRx

Q b

Q Ax

Q

d b c

Q

b Q Ax

Q b

Ax Q

b Ax

x   



 





 

 



 

 

: en résoudre min

' 0 '

' '

' posons

' '

'

2

2 2

2

Mise en œuvre : on calcule directement Q’b pendant la décomposition

(25)

Remarques

MMC sans Q

e x

x w

ReR wy XX r r

r X Xe

X X

y r

y R z X y R

R R X

X QR X

y X X

X y

X

 

  

 

 

564 ' '

3

' '

: résidus

2 ' '

1

' '

' '

min 2

R=chol(A’A)

Si on ajoute ou on enlève une variable Q et R changent « peu »

(26)

Matlab

 

y Q

Hk H

H H

H X y

b X X

y y

b X

k

' vecteur le

t directemen mais

, matrice de

calculer sans

puis

puis en faisant une bouclesur 1:3sanscalculer les matrices

et ,

matrices les

calculant en

boucle de

faire sans

abord d'

matrice la

sur r

Householde de

méthode la

z implémente

3. 2 .construirerésoudre - - -en en en utilisant utilisant utilisant le problème telqueleslala fonction \fonction équation des moindres* qr normalesdedematlabmatlabcarrées , 1.

1 1 3

; 0

0

0 0

0 0

1 1

1

) (

) 3 ( )

2 ( )

1 (













ATTENTION : cette semaine il faut un compte rendu par binôme

unCR est une page recto verso : recto ce que vous avez fait, verso : ce que vous en pensez !

Références

Documents relatifs

Approximation de fonction : la méthode des

la méthode des moindres carrés Le point de vue numérique.

• voir les méthodes semi directes pour les problèmes de grande taille (cf les méthodes «

alors T et A sont équivalentes (elles ont les même valeurs propres) et T est une matrice triangulaire. Comment construire

Résolution de systèmes d’équation non linéaires. f ( x )=0.. Gauss-Siedel pour les

f(x)=0.. Gauss-Siedel pour les systèmes linéaires). –

– on prend des polynômes de degré faible (3) pour éviter les

le minimum est sur la frontière minimisation sous