• Aucun résultat trouvé

TP 7 – Splines cubiques – Correction

N/A
N/A
Protected

Academic year: 2022

Partager "TP 7 – Splines cubiques – Correction"

Copied!
4
0
0

Texte intégral

(1)

ULCO 2019 - 2020

M1 Reherche IMAO

TP 7 – Splines cubiques – Correction Exercice 1. a.

Pour i = 1, 2, 3, on a q i (x) = a i,1 + a i,2 (x − x i ). De q i (x i ) = a i,1 = y i , on ontient a 1,1 = 1, a 2,1 = 3 et a 3,1 = 2. De q i (x i+1 ) = a i,1 + a i,2 (x i+1 − x i ) = y i+1 , on obtient

a i,2 = y i+1 − a i,1 x i+1 − x i

= y i+1 − a i,1 = y i+1 − y i ,

et donc a 1,2 = 3 − 1 = 2, a 2,2 = 2 − 3 = −1 et a 3,2 = 3 − 2 = 1. Ainsi on obtient :

X =

 0 1 2 3

 et

1 2

3 −1

2 1

b. On obient

polynome(M,X,i,k):=block([j,q], q:0,

for j:1 thru k+1 do(

q:q+M[i][j]*(x-X[i][1])**(j-1) ),

return(q) )

c. On obtient

polynomes(M,X):=block([k,n,size], size:matrix_size(M),

n:size[1]+1, k:size[2]-1,

return(makelist(polynome(M,X,i,k),i,1,n-1)) )

d. On obtient les polynˆ ome ` a partir de X et M grˆ ace aux fonctions pr´ ec´ edents. Pour i = 1, ..., n − 1 on a x i = X[i] et y i = q i (x i ). De plus x n = X[n] et y n = q n (x n+1 ).

e. On obtient

affiche spline(M,X):=block([a,b,n,P,Q], Q:polynomes(M,X),

n:length(Q)+1, a:X[1][1], b:X[n][1],

P:makelist([X[i][1],subst(x=X[i][1],Q[i])],i,1,n-1), P:append(P,[[X[n][1],subst(x=X[n][1],Q[n-1])]]),

C:makelist(explicit(Q[i],x,X[i][1],X[i+1][1]),i,1,n-1),

wxdraw2d(point type=circle,points(P),color=red,C,proportional axes = ’xy)

)

(2)

2

f. On obtient

g. Il y’a n − 1 polynˆ omes q i de degr´ e 2 et donc 3(n − 1) = 3n − 3 inconnues. On a n − 1 ´ equations de la forme q i (x i ) = y i , n − 1 ´ equations de la forme q i (x i+1 ) = y i+1 et n − 2 ´ equations de la forme q 0 i (x i + 1) = q i+1 0 (x i ). Au finale on a 2(n − 1) + (n −2) = 3n −4 ´ equations. Il manque donc une condition.

h. On obtient

i. On obtient

j. On obtient

k. La valeur de la d´ eriv´ ee en x 0 ` a un impact majeur sur l’allure globale de la courbe : ce n’est pas

raisonnable en pratique.

(3)

3

Exercice 2.

a. Il y’a n − 1 polynˆ omes q i de degr´ e 3 et donc 4(n − 1) = 4n − 4 inconnues. On a n − 1 ´ equations de la forme q i (x i ) = y i , n − 1 ´ equations de la forme q i (x i+1 ) = y i+1 , n − 2 ´ equations de la forme q 0 i (x i + 1) = q i+1 0 (x i ). Au finale on a 2(n − 1) + 2(n − 2) = 4n − 6 ´ equations. Il manque donc deux conditions.

b. On a q 0 i (x) = 3a i (x − x i ) 2 + 2b i (x − x i ) + c i et q i 00 (x) = 6a i (x − x i ) + 2b i . L’´ equation (1) devient

d i = y i (5)

L’´ eqution (2) devient

a i (x i+1 − x i ) 3 + b i (x i+1 − x i ) 2 + c i (x i+1 − x i ) + d i = y i+1 . (6) L’´ eqution (3) devient

3a i (x i+1 − x i ) 2 + 2b i (x − x i ) + c i = c i+1 (7) L’´ equation (4) devient

3a i (x i+1 − x i ) + b i = b i+1 (8)

Exercice 3.

a. On a m i = q 00 i (x i ) = 2b i et donc

b i = m i

2 (9)

b. par l’´ equation (8) on a 3a i h i = b i+1 − b i = m

i+1

2m 2

i

et donc

a i = m i+1 − m i 6h i

. (10)

c. L’´ equation (6) devient a i h 3 i + b i h 2 i + c i h i = y i+1 − d i = y i+1 − y i et donc apr` es calcul

c i = y i+1 − y i

h i

− h i

m i+1 − m i

6 − h i

m i

2 . (11)

Exercice 4.

La seule ´ equation pas encore untilis´ ee est la (7). En remplaceant a i , b i , c i et d i = y i par leurs expressions en fonction de h i , m i et y i on obtient

h i m i + 2(h i + h i+1 )m i+1 + h i+1 m i+2 = 6

y i+2 − y i+1 h i+1

− y i+1 − y i h i

(12)

Exercice 5. En ajoutant les conditions m 1 = 0 et m n = 0 on est amen´ e ` a r´ esoudre le syst` eme AY = B suivant :

 1

h 1 2(h 1 + h 2 ) h 2

h 2 2(h 2 + h 3 ) h 3

. . . . . . . . .

h n−2 2(h n−2 + h n−1 ) h n−1

1

| {z }

A

×

 m 1

m 2

m 3

.. . m n−1

m n

| {z }

Y

= 6

0

y

3

−y

2

h

2

y

2

h −y

1

y

4

−y

3 1

h

3

y

3

h −y

2

..

2

.

y

n

−y

n−1

h

n−1

y

n−1

h −y

n−2

n−2

0

| {z }

B

b. On r´ esoud construit puis r´ esoud le syst` eme pr´ ec´ edent. Pour l’affichage de la spline cubique, on

utilise les fonctions de l’exercice 1.

(4)

4

spline_cubique(P):=block([i,n,A,B,h,Y,m], n:length(P),

h:makelist(P[i+1][1]-P[i][1],i,1,n-1), A:zeromatrix(n,n),

B:zeromatrix(n,1), for i:2 thru n-1 do (

B[i][1]:6*((P[i+1][2]-P[i][2])/h[i]-(P[i][2]-P[i-1][2])/h[i-1]) ),

A[1,1]:1, A[n,n]:1,

for i:2 thru n-1 do(

A[i,i-1]:h[i-1],

A[i,i]:2*(h[i-1]+h[i]), A[i,i+1]:h[i]

),

Y:A^^(-1).B,

m:makelist(Y[i][1],i,1,n), d:makelist(P[i][2],i,1,n-1), b:makelist(m[i]/2,i,1,n-1),

a:makelist((m[i+1]-m[i])/(6*h[i]),i,1,n-1),

c:makelist((P[i+1][2]-P[i][2])/h[i]-h[i]*(m[i+1]-m[i])/6-h[i]*m[i]/2,i,1,n-1), M:zeromatrix(n-1,4),

for i:1 thru n-1 do(

M[i,4]:a[i], M[i,3]:b[i], M[i,2]:c[i], M[i,1]:d[i]

),

X:zeromatrix(n,1), for i:1 thru n do(

X[i][1]:P[i][1]

),

affiche_spline(M,X) )

c. Avec les point d´ efinis pr´ ec´ edement, on obtient

Références

Documents relatifs

[r]

Dans ce qui suit, nous chercherons ` a ´ etablir un certain nombre de propri´ et´ es alg´ e- briques de la d´ eriv´ ee qui peuvent servir ` a la d´ etermination des fonctions

Dans ce qui suit, nous chercherons ` a ´ etablir un certain nombre de propri´ et´ es alg´ e- briques de la d´ eriv´ ee qui peuvent servir ` a la d´ etermination des fonctions

Pour signer un message, on choisit la feuille correspondant au premier sch´ ema de signature non encore utilis´ e, on signe le message normalement avec cette instance, puis on

Modifier la fonction void Spline::dessine() du fichier spline.cpp pour afficher la spline en plus des points de contrˆ oles lorsque la spline a un statut diff´ erent de

Formules ´ el´ ementaires : Les formules ci-dessous valident sur leur domaine de l’existence. Soit a un nombre

Donc Int(A)

Propriété : La représentation graphique d'une fonction linéaire est une droite qui passe par l'origine du repère.. Les points de la droite ont pour coordonnées: ( a ; ax) ; ici a