0% ont trouvé ce document utile (0 vote)
4 vues3 pages

Interpolation de fonctions par polynômes

Transféré par

safia ouyoub
Copyright
© All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
4 vues3 pages

Interpolation de fonctions par polynômes

Transféré par

safia ouyoub
Copyright
© All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd

Chap2, série 2: Analyse Numérique 1

Enseignant : SALEM NAFIRI

Exercice 1 : énoncé
Le but de cet exercice est de compléter un programme permettant d’interpoler une fonction
continue par un polynôme. Soit f : [a, b] → R une fonction continue donnée et soit t0 < t1 < t2 <
· · · < tn , (n + 1) points de [a, b]. On cherche un polynôme pn de degré inférieur ou égal à n tel que

pn (tj ) = f (tj ), 0 6 j 6 n.

Question 1 : Rappeler la formule du cours permettant d’expliciter pn en fonction de la base de


Lagrange de Pn associée aux points t0 < t1 < t2 < · · · < tn .

Question 2 : Le programme [Link] est à votre disposition à la fin de ce document. En


s’inspirant de ce programme faites un programme équivalent avec Python pour répondre aux
questions de cet exercice.
A partir de la donnée de f et n, ce programme permet de calculer le polynôme pn qui interpole
f aux points tj , 0 6 j 6 n, équidistribués uniformément sur l’intervalle [a, b]. Ce programme est
incomplet, vous devez en particulier programmer les formules issues de la question 1 ci-dessus.
Pour lancer le programme avec n = 5, tapez

[err,t,f,x,p]=intlag(5);

dans la fenêtre de commande scilab. Ceci aura pour effet de créer les vecteurs t,f,x,p. Les
résultats pourront être visualisés en tapant ensuite

plot(t,f,’o’,x,p);

Taper

err

1
dans la fenêtre de commande scilab pour obtenir une approximation de

max |f (t) − pn (t)|.


−16t61

Dans la suite on va considérer deux cas de figures : le cas où f (t) = sin(t) et [a, b] = [−π, π]. Ensuite
1
le cas où f (t) = et [a, b] = [−1, 1]. Trois lignes sont à compléter dans le programme.
1 + 25t2

Question 3 : On considère le cas où f (t) = sin(t). Remplir le tableau suivant

n err
5
10
20

Que vaut lim max |f (t) − pn (t)| ? Expliquer ce résultat grâce au théorème du cours.
n→∞ −π≤t≤π

1
Question 4 (Phénomène de Runge) : On considère le cas où f (t) = . Remplir le
1 + 25t2
tableau suivant
n err
5
10
20
40

Que vaut lim max |f (t) − pn (t)|?


n→∞ −1≤t≤1

1
Question 5 : On considère le cas où f (t) = mais avec
1 + 25t2
(2j − 1)π
tj = cos , j = 1, · · · , n + 1,
2(n + 1)

qui sont les points dits de Chebyshev. Que vaut lim max |f (t) − pn (t)|?.
n→∞ −1≤t≤1

2
Le fichier scilab [Link]

// Etant donne un entier n et une fonction continue f,


// le programme interpole la fonction f par un polynome p
// de degre n aux points d interpolation t(1),t(2),...,t(n).
// parametres: entree : n
// sortie : err : erreur max entre la fonction f et l interpolant p
// t : (n+1) vecteur contenant les points d interpolation
// f : (n+1) vecteur contenant les valeurs de la fonction f
// aux points d interpolation
// x : vecteur contenant 1001 points uniformement distribues
// sur [-1,1]
// p : vecteur contenant les valeurs du polynome p au point x(i)
//
function [err,t,f,x,p]=intlag(n)
//
// initialisation des vecteurs t et f
//
for i=1:n+1
t(i)=-1+(2.*(i-1))/n;
f(i)=funct(t(i));
end
//
//calcul de la valeur du polynome d interpolation au point x(i)
//
m=1000;
err=0;
for i=1:m+1
x(i)=-1+(2.*(i-1))/m;
p(i)=0;
for j=1:n+1
p(i) = p(i) + f(j) * ?????;
end
err = max(err,abs(p(i)-funct(x(i))));
end
endfunction
// // calcul de phij (la j ieme fonction de la base de Lagrange)
//
function basis = phi(j,n,xx,t)
basis=1;
for k=1:n+1
if k ~= j then
basis = basis * ?????;
end
end
endfunction
// // fonction a interpoler
// function f = funct(xx)
f = ????? ;
endfunction

Common questions

Alimenté par l’IA

The distribution of points significantly impacts the error in polynomial interpolation. For uniformly distributed points, especially when interpolating functions with steep gradients or high oscillations, the error can increase dramatically with the degree of the polynomial (n) due to Runge's phenomenon. However, when using point distributions like Chebyshev nodes, which concentrate more points near the boundaries of the interval, the interpolation error is reduced, achieving better approximation properties even for higher n. This is notably effective for functions such as f(t)=1/(1+25t^2), which tend to suffer from Runge's phenomenon when uniform point spacing is used .

The Lagrange interpolation formula is used to express the polynomial pn that interpolates a function f at given points t0, t1, ..., tn. The polynomial pn can be described as pn(x) = Σ (f(tj) * L_j(x)), where L_j(x) are the Lagrange basis polynomials defined by L_j(x) = Π ((x - ti) / (tj - ti)) for i ≠ j, ensuring that L_j(x) = 1 at x = tj and 0 at all other data points. This results in pn interpolating f at each tj, meaning pn(tj) = f(tj) for each j .

As n approaches infinity, polynomial interpolation may not converge uniformly to the function f over the interval [a, b]. The Weierstrass approximation theorem states that continuous functions can be uniformly approximated on [a, b] by polynomials, yet this doesn't imply interpolation will provide such convergence. For example, increased oscillations in polynomial interpolants can result from higher degrees, especially in Runge's phenomenon, where evenly spaced interpolation points cause divergence as illustrated by the interpolation of f(t)=1/(1+25t^2) on [-1,1].

When selecting interpolation nodes for a function on a closed interval, it is crucial to consider how to minimize interpolation error and avoid phenomena such as Runge's phenomenon. Essential considerations include the nature of the function (such as smoothness and behavior at the endpoints) and the distribution of nodes. For functions with large curvatures at interval edges, Chebyshev nodes are preferred as they provide a better spread and minimize the maximum error. The goal is to achieve a node distribution that approximates the minimax optimal distribution, reducing oscillatory behavior and ensuring better convergence properties .

For the function f(t) = sin(t) over the interval [-π, π], as the degree n of the interpolating polynomial increases, the approximation error generally decreases, aligning with D'Alembert's principle that polynomial interpolation converges to the function as the number of interpolating nodes increases. Particularly for sinusoidal functions, which are already periodic and smooth, polynomial interpolation performs well, leading to a smaller maximum approximation error as n becomes larger. Consequently, one could expect lim n→∞ max -π≤t≤π|f(t) - pn(t)| to approach zero, demonstrating uniform convergence .

The maximum interpolation error for a given function is calculated by finding max |f(t) - pn(t)| over the interval of interest. This error is affected by the degree of the interpolating polynomial, node distribution, and the function's properties like its derivatives. For evenly distributed points, functions with high-order derivatives can cause larger errors due to oscillations at the edges (Runge's phenomenon), while using Chebyshev nodes generally reduces this error by effectively balancing the node distribution according to the function's behavior .

To implement polynomial interpolation using Python, one can use libraries such as NumPy for numerical operations and Matplotlib for visualization. A Python implementation can define a function to compute Lagrange bases and use them to construct the interpolating polynomial, similar to Scilab's intlag.sci but utilizing Python's comprehensive ecosystem for matrix operations and scripting flexibility. Python's higher abstraction level and powerful data handling capabilities can streamline operations and enhance the implementation with additional features like dynamic plotting, whereas Scilab's implementation may require more manual handling of loops and indices .

Chebyshev nodes distribute points more densely near the endpoints of the interval, which reduces the effect of Runge's phenomenon by minimizing the maximum error in polynomial interpolation. In polynomial interpolation, using equally spaced points often leads to large oscillations at the boundaries (Runge's phenomenon), especially for high-degree polynomials. Using Chebyshev nodes, which are determined by tj = cos((2j-1)π/(2n+2)), clusters these interpolation points towards the edges of the interval, thereby reducing the interpolation error significantly as n increases, particularly for smooth functions like f(t)=1/(1+25t^2).

When interpolating f(t)=1/(1+25t^2) using uniform nodes, the error trends show a significant increase with higher n due to Runge's phenomenon, reflecting large oscillations at interval edges. Conversely, with Chebyshev nodes, the error is substantially reduced and more stable across different n values. Chebyshev nodes distribute closer near interval boundaries, leading to a more balanced interpolation that controls oscillatory behavior and minimizes the maximum error, thereby achieving improved convergence as n increases .

The function f(t) = 1/(1+25t^2) suffers from Runge's phenomenon when interpolated at equally spaced points due to its rapid changes at the interval's edges. This results in increasing oscillations and divergence as n increases, unlike f(t) = sin(t), which is smoother and periodic, hence not as susceptible to such issues. This difference is tied to the shape and smoothness of the function being interpolated; f(t) = 1/(1+25t^2) has high curvature near the domain edges, causing interpolation polynomials to oscillate more severely with higher degrees .

Vous aimerez peut-être aussi