Chapter 1
Numerical approximation of data :
interpolation, least squares method
I. Motivation
1
Approximation of functions
Evaluation of a function
Which functions (f : R → R ) can be effectively evaluated in any point ?
Þ the power functions : f (x) = x m , m ∈ N Þ the polynomial functions :
f (x) = a 0 + a 1 x + a 2 x 2 + · · · + a m x m How can we evaluate other functions in a given point ?
for instance : f(x) = cos(x), f (x) = sin(x) exp(x),... Þ approximation by a polynomial function :
H using a Taylor series about the given point,
H searching a polynomial having the same values as the function in some close points
á Lagrange interpolation
Evaluation of a function
Which functions (f : R → R ) can be effectively evaluated in any point ?
Þ the power functions : f (x) = x m , m ∈ N Þ the polynomial functions :
f (x) = a 0 + a 1 x + a 2 x 2 + · · · + a m x m
How can we evaluate other functions in a given point ? for instance : f(x) = cos(x), f (x) = sin(x) exp(x),... Þ approximation by a polynomial function :
H using a Taylor series about the given point,
H searching a polynomial having the same values as the function in some close points
á Lagrange interpolation
Evaluation of a function
Which functions (f : R → R ) can be effectively evaluated in any point ?
Þ the power functions : f (x) = x m , m ∈ N Þ the polynomial functions :
f (x) = a 0 + a 1 x + a 2 x 2 + · · · + a m x m How can we evaluate other functions in a given point ?
for instance : f(x) = cos(x), f (x) = sin(x) exp(x),...
Þ approximation by a polynomial function : H using a Taylor series about the given point,
H searching a polynomial having the same values as the function in some close points
á Lagrange interpolation
Evaluation of a function
Which functions (f : R → R ) can be effectively evaluated in any point ?
Þ the power functions : f (x) = x m , m ∈ N Þ the polynomial functions :
f (x) = a 0 + a 1 x + a 2 x 2 + · · · + a m x m How can we evaluate other functions in a given point ?
for instance : f(x) = cos(x), f (x) = sin(x) exp(x),...
Þ approximation by a polynomial function : H using a Taylor series about the given point,
H searching a polynomial having the same values as the function in some close points
á Lagrange interpolation
Principles of Lagrange interpolation
f (x) = sin( πx
2 )(x 2 + 3)
Principles of Lagrange interpolation
f (x) = sin( πx
2 )(x 2 + 3)
4 points on the curve : (−1, −4),
(1, 4),
(2, 0),
(3, −12)
Principles of Lagrange interpolation
f (x) = sin( πx
2 )(x 2 + 3) Lagrange interpolating polynomial
4 points on the curve : P polynomial of degree ≤ 3 satisfying
(−1, −4), P (−1) = −4
(1, 4), P (1) = 4
(2, 0), P (2) = 0
(3, −12) P(3) = −12
Principles of Lagrange interpolation, with 6 points
f (x) = sin( πx
2 )(x 2 + 3) Lagrange interpolating polynomial
6 points on the curve : P polynomial of degree ≤ 5 satisfying
(x i , y i ) 0≤i≤5 , P (x i ) = y i for 0 ≤ i ≤ 5
Remark : ouside the interval defined by the (x i ), the Lagrange
interpolating polynomial has nothing to do with f .
I. Motivation
1
Approximation of functions
2
Curve approximation
Piecewise interpolation
f (x) = sin( πx
2 )(x 2 + 3)
piecewise affine approximation
Piecewise interpolation
f (x) = sin( πx
2 )(x 2 + 3) piecewise affine approximation
Piecewise interpolation
f (x) = sin( πx
2 )(x 2 + 3) piecewise affine approximation
Applications : Calculation of an approximate value of the length of the curve
the area under the curve (here Z 5
−5
f(x)dx)
Þ see chapter 2
Piecewise interpolation
f (x) = sin( πx
2 )(x 2 + 3) piecewise affine approximation
Applications : Calculation of an approximate value of the length of the curve
the area under the curve (here Z 5
−5
f (x)dx)
Þ see chapter 2
Cubic spline
f (x) = sin( πx
2 )(x 2 + 3) s cubic spline
Principle :
between two consecutive points, s is a cubic polynomial s(x i ) = f (x i )
s ∈ C 2
+ two conditions on the boundary points
Cubic spline
f (x) = sin( πx
2 )(x 2 + 3) s cubic spline
Principle :
between two consecutive points, s is a cubic polynomial s(x i ) = f (x i )
s ∈ C 2
+ two conditions on the boundary points
B´ ezier curves : principle
P 0 , P 1 , · · · , P n , are n + 1 given control points
The corresponding B´ ezier curve is defined by M (t) =
n
X
i=0
B n i (t)P i , 0 ≤ t ≤ 1 where B n i are Bernstein polynomial defined by
B n i = C n i X i (1 − X) n−i , with C n i = n!
i!(n − i)! .
B´ ezier curves : principle
P 0 , P 1 , · · · , P n , are n + 1 given control points The corresponding B´ ezier curve is defined by
M (t) =
n
X
i=0
B n i (t)P i , 0 ≤ t ≤ 1 where B n i are Bernstein polynomial defined by
B n i = C n i X i (1 − X) n−i , with C n i = n!
i!(n − i)! .
B´ ezier curves : with more points
Application of the B´ ezier curves
I. Motivation
1
Approximation of functions
2
Curve approximation
3
Fitting of statistical data
Study of statistical data
Some experimental measurements
H X : noise level in the factory (in dB),
H Y : time used to do a definite work (in minutes)
X 73 78 76 63 81 70 75 81 79 84 50 76 65 58 Y 77 85 79 67 83 73 72 83 81 82 52 77 65 58
A physical measure always contains some noise. Can we find a law linking Y and X (Y = f (X)) ?
Can we predict the value of
Y for X = 66dB ?
Linear regression
Principle
We are looking for a and b such that d(a, b) = X
(y i − (ax i + b)) 2 is minimal.
The straight line y = ax + b is the linear regression line.
The polynomial P = aX + b is the least squares fitting
polynomial of the cloud of points.
II. Lagrange interpolating polynomial : theoretical study
1
Study of an example
Lagrange interpolation in 1 point
f (x) = sin( πx
2 )(x 2 + 3)
1 point on the curve : Search for P 0 , such that (x 0 , y 0 ) = (1, 4) deg P 0 ≤ 0 and
P 0 (x 0 ) = y 0
P 0 = 4
Lagrange interpolation in 1 point
f (x) = sin( πx
2 )(x 2 + 3)
1 point on the curve : Search for P 0 , such that (x 0 , y 0 ) = (1, 4) deg P 0 ≤ 0 and
P 0 (x 0 ) = y 0
P 0 = 4
Lagrange interpolation in 1 point
f (x) = sin( πx
2 )(x 2 + 3)
1 point on the curve : Search for P 0 , such that (x 0 , y 0 ) = (1, 4) deg P 0 ≤ 0 and
P 0 (x 0 ) = y 0
P 0 = 4
Lagrange interpolation in 2 points
f (x) = sin( πx
2 )(x 2 + 3)
2 points on the curve : Search for P 1 , such that (x 0 , y 0 ) = (1, 4) deg P 1 ≤ 1 and (x 1 , y 1 ) = (−1, −4) P 1 (x 0 ) = y 0 and P 1 (x 1 ) = y 1
P 1 = 4X
Lagrange interpolation in 2 points
f (x) = sin( πx
2 )(x 2 + 3)
2 points on the curve : Search for P 1 , such that (x 0 , y 0 ) = (1, 4) deg P 1 ≤ 1 and (x 1 , y 1 ) = (−1, −4) P 1 (x 0 ) = y 0 and P 1 (x 1 ) = y 1
P 1 = 4X
Lagrange interpolation in 2 points
f (x) = sin( πx
2 )(x 2 + 3)
2 points on the curve : Search for P 1 , such that (x 0 , y 0 ) = (1, 4) deg P 1 ≤ 1 and (x 1 , y 1 ) = (−1, −4) P 1 (x 0 ) = y 0 and P 1 (x 1 ) = y 1
P 1 = 4X
Lagrange interpolation in 3 points
f (x) = sin( πx
2 )(x 2 + 3)
3 points on the curve : Search for P 2 , such that (x 0 , y 0 ) = (1, 4) deg P 2 ≤ 2 and (x 1 , y 1 ) = (−1, −4) P 2 (x 0 ) = y 0 , P 2 (x 1 ) = y 1
(x 2 , y 2 ) = (3, −12) and P 2 (x 2 ) = y 2
Lagrange interpolation in 3 points
f (x) = sin( πx
2 )(x 2 + 3)
3 points on the curve : Search for P 2 , such that (x 0 , y 0 ) = (1, 4) deg P 2 ≤ 2 and (x 1 , y 1 ) = (−1, −4) P 2 (x 0 ) = y 0 , P 2 (x 1 ) = y 1
(x 2 , y 2 ) = (3, −12) and P 2 (x 2 ) = y 2
Lagrange interpolation in 3 points
Idea
Search for L 0 , such that deg L 0 = 2 and
L 0 (x 1 ) = L 0 (x 2 ) = 0 and L 0 (x 0 ) = 1.
Search for L 1 , such that deg L 1 = 2 and
L 1 (x 0 ) = L 1 (x 2 ) = 0 and L 1 (x 1 ) = 1.
Search for L 2 , such that deg L 0 = 2 and
L 2 (x 0 ) = L 2 (x 1 ) = 0 and L 2 (x 2 ) = 1.
Prove that P 2 = y 0 L 0 + y 1 L 1 + y 2 L 2 is a solution of the pb.
Give the expression of P .
á P 2 = −3X 2 + 4X + 3
Lagrange interpolation in 3 points
Idea
Search for L 0 , such that deg L 0 = 2 and
L 0 (x 1 ) = L 0 (x 2 ) = 0 and L 0 (x 0 ) = 1.
Search for L 1 , such that deg L 1 = 2 and
L 1 (x 0 ) = L 1 (x 2 ) = 0 and L 1 (x 1 ) = 1.
Search for L 2 , such that deg L 0 = 2 and
L 2 (x 0 ) = L 2 (x 1 ) = 0 and L 2 (x 2 ) = 1.
Prove that P 2 = y 0 L 0 + y 1 L 1 + y 2 L 2 is a solution of the pb.
Give the expression of P .
á P 2 = −3X 2 + 4X + 3
Lagrange interpolation in 3 points
Other idea
P 1 = 4X satisfies P 1 (1) = 4, P 1 (−1) = −4 and deg P 1 = 1.
Q = (X + 1)(X − 1) satisfies Q(1) = Q(−1) = 0 and deg Q = 2 (in fact Q = −L 2 )
Search for P 2 under the form
P 2 = P 1 + αQ = 4X + α(X + 1)(X − 1).
P 2 (3) = −12 ⇐⇒ α = −3 and
P 2 = 4X − 3(X + 1)(X − 1) = −3X 2 + 4X + 3
Lagrange interpolation in 3 points
Other idea
P 1 = 4X satisfies P 1 (1) = 4, P 1 (−1) = −4 and deg P 1 = 1.
Q = (X + 1)(X − 1) satisfies Q(1) = Q(−1) = 0 and deg Q = 2 (in fact Q = −L 2 )
Search for P 2 under the form
P 2 = P 1 + αQ = 4X + α(X + 1)(X − 1).
P 2 (3) = −12 ⇐⇒ α = −3 and
P 2 = 4X − 3(X + 1)(X − 1) = −3X 2 + 4X + 3
II. Lagrange interpolating polynomial : theoretical study
1
Study of an example
2
Existence and uniqueness of the Lagrange interpolating
polynomial
The mathematical problem
Formulation
Let (n + 1) points be given :
(x i , y i ) 0≤i≤n with (x i , y i ) ∈ R 2 for all i, x i 6= x j for all i 6= j.
Is it possible to find a polynomial P with real coefficients satisfying P (x i ) = y i ∀0 ≤ i ≤ n?
Degree of P ?
number of equations : n + 1
Þ number of unknowns (coefficients (a i )) less that n + 1
Þ deg P ≤ n
The Lagrange basis
For 0 ≤ j ≤ n, let us define L j =
n
Y
i=0,i6=j
X − x i x j − x i . It satisfies :
L j (x j ) = 1 and L j (x i ) = 0 for all i 6= j
⇐⇒ L j (x i ) = δ i,j . and
deg L j = n ∀0 ≤ j ≤ n.
Solution of the problem + uniqueness
Existence of a solution Let P =
n
X
j=0
y j L j , we have deg P ≤ n,
P (x i ) =
n
X
j=0
y j L j (x i ) = y i for all 0 ≤ i ≤ n.
á P is a solution of the Lagrange interpolation problem.
Uniqueness
Can we find another solution to the problem, Q ? If Q exists, deg Q ≤ n and deg(P − Q) ≤ n,
P (x i ) − Q(x i ) = (P − Q)(x i ) = 0 for 0 ≤ i ≤ n.
á P − Q = 0 and the solution is unique.
Main theorem
Theorem Hypotheses :
Let us consider (n + 1) points of R 2 : (x i , y i ) 0≤i≤n , x i 6= x j for all i 6= j
Then, there exists a unique polynomial P ∈ R n [X] satisfying P (x i ) = y i ∀0 ≤ i ≤ n.
P is the Lagrange interpolating polynomial that passes through the (n + 1) points (x i , y i ) 0≤i≤n .
In the case where y i = f (x i ) for all 0 ≤ i ≤ n (with f a given
function), P is the Lagrange interpolating polynomial of f in the
points (x i ) 0≤i≤n .
II. Lagrange interpolating polynomial : theoretical study
1
Study of an example
2
Existence and uniqueness of the Lagrange interpolating polynomial
3
Interpolation error result
Presentation of the problem
Comparison of f and P (4 points)
E(x) = f (x) − P (x)
Presentation of the problem
Comparison of f and P (4 points)
E(x) = f (x) − P (x)
with a zoom around the points
Presentation of the problem
Comparison of f and P (6 points)
E(x) = f (x) − P (x)
Presentation of the problem
Comparison of f and P (6 points)
E(x) = f (x) − P (x)
with a zoom around the points
What can be said about E(x) ? Can it be bounded ?...
Interpolation error
Theorem Hypotheses :
f : [a, b] → R , f ∈ C n+1 ([a, b]),
(x i ) 0≤i≤n , n + 1 distinct real numbers of [a, b].
P n : Lagrange interpolating polynomial of f in the points (x i ) 0≤i≤n . Then, for all x ∈ [a, b], there exists ξ x ∈ [a, b] such that
f(x) − P n (x) = 1
(n + 1)! Π n (x)f (n+1) (ξ x ), with Π n =
n
Y
i=0
(X − x i ).
Consequence
As a consequence, we get :
∀x ∈ [a, b] |f (x) − P n (x)| ≤ 1
(n + 1)! M n+1 |Π n (x)|,
with M n+1 = max
ξ∈[a,b] |f (n+1) (ξ)|.
It does not imply the convergence of P n (x) towards f(x).
It is not necessary interesting to increase n.
III. Lagrange interpolating polynomial : practical computation
1
Cost of the computation of the interpolating polynomial
With the Lagrange basis
L j (x) =
n
Y
i=0,i6=j
(x − x i )
n
Y
i=0,i6=j
(x j − x i ) ,
for j = 0 to n
Cost of the computation :
(n + 1) ×
2(n − 1) mult. + 1 div.
P (x) =
n
X
j=0
y j L j (x) Þ final cost ≈ 2n 2 .
Other main drawback of the method : what happens if we finally want to add one more point (x n+1 , y n+1 ) ?
Þ All must be started again from zero.
With the Lagrange basis
L j (x) =
n
Y
i=0,i6=j
(x − x i )
n
Y
i=0,i6=j
(x j − x i )
, for j = 0 to n
Cost of the computation : (n + 1) ×
2(n − 1) mult. + 1 div.
P (x) =
n
X
j=0
y j L j (x) Þ final cost ≈ 2n 2 .
Other main drawback of the method : what happens if we finally want to add one more point (x n+1 , y n+1 ) ?
Þ All must be started again from zero.
With the Lagrange basis
L j (x) =
n
Y
i=0,i6=j
(x − x i )
n
Y
i=0,i6=j
(x j − x i )
, for j = 0 to n
Cost of the computation : (n + 1) ×
2(n − 1) mult. + 1 div.
P (x) =
n
X
j=0
y j L j (x) Þ final cost ≈ 2n 2 .
Other main drawback of the method : what happens if we finally want to add one more point (x n+1 , y n+1 ) ?
Þ All must be started again from zero.
With the Lagrange basis
L j (x) =
n
Y
i=0,i6=j
(x − x i )
n
Y
i=0,i6=j
(x j − x i )
, for j = 0 to n
Cost of the computation : (n + 1) ×
2(n − 1) mult. + 1 div.
P (x) =
n
X
j=0
y j L j (x) Þ final cost ≈ 2n 2 .
Other main drawback of the method : what happens if we finally want to add one more point (x n+1 , y n+1 ) ?
Þ All must be started again from zero.
With an other basis
Idea
Write the polynomial in the basis
1, (X − x 0 ), (X − x 0 )(X − x 1 ), · · · ,
n−1
Y
j=0
(X − x j )
.
Þ P
n
= α 0 + α 1 (X − x 0 ) + · · · + α n n−1
Y
j=0
(X − x j ).
Now, if we add one point (x n+1 , y n+1 ) , we have : P n+1 = P n + α n+1
n
Y
j=0
(X − x j )
Þ we just need to calculate α n+1 to get P n+1 .
With an other basis
Idea
Write the polynomial in the basis
1, (X − x 0 ), (X − x 0 )(X − x 1 ), · · · ,
n−1
Y
j=0
(X − x j )
.
Þ P n = α 0 + α 1 (X − x 0 ) + · · · + α n n−1
Y
j=0
(X − x j ).
Now, if we add one point (x n+1 , y n+1 ) , we have : P n+1 = P n + α n+1
n
Y
j=0
(X − x j )
Þ we just need to calculate α n+1 to get P n+1 .
With an other basis
Idea
Write the polynomial in the basis
1, (X − x 0 ), (X − x 0 )(X − x 1 ), · · · ,
n−1
Y
j=0
(X − x j )
.
Þ P n = α 0 + α 1 (X − x 0 ) + · · · + α n n−1
Y
j=0
(X − x j ).
Now, if we add one point (x n+1 , y n+1 ) , we have : P n+1 = P n + α n+1
n
Y
j=0
(X − x j )
Þ we just need to calculate α n+1 to get P n+1 .
Cost of the computation of P n (x)
P n (x) = α 0 + α 1 (x − x 0 ) + · · · + α n
n−1
Y
j=0
(x − x j )
= α 0 + (x − x 0 )
α 1 + (x − x 1 )
α 2 + · · · .
H¨ orner’s algorithm for the computation of p = P n (x) p ← α n
for k from n − 1 to 0 p ← α k + (x − x k )p end
Cost
n additions + n multiplications
Þ and the computation of the coefficients α i ?
Cost of the computation of P n (x)
P n (x) = α 0 + α 1 (x − x 0 ) + · · · + α n
n−1
Y
j=0
(x − x j )
= α 0 + (x − x 0 )
α 1 + (x − x 1 )
α 2 + · · · .
H¨ orner’s algorithm for the computation of p = P n (x) p ← α n
for k from n − 1 to 0 p ← α k + (x − x k )p end
Cost
n additions + n multiplications
Þ and the computation of the coefficients α i ?
III. Lagrange interpolating polynomial : practical computation
1
Cost of the computation of the interpolating polynomial
2
The divided difference method
Calculation of the first α i
n = 0, 1 first point (x 0 , y 0 ), P 0 = α 0 : P 0 (x 0 ) = y 0 = ⇒ α 0 = y 0
n = 1, + (x 1 , y 1 ), P 1 = y 0 + α 1 (X − x 0 ) : P 1 (x 1 ) = y 1 = ⇒ α 1 = y 1 − y 0
x 1 − x 0 n = 2, + (x 2 , y 2 ),
P 2 = y 0 + y 1 − y 0
x 1 − x 0
(X − x 0 ) + α 2 (X − x 0 )(X − x 1 )
P 2 (x 2 ) = y 2 = ⇒ α 2 =
y 2 − y 1
x 2 − x 1 − y 1 − y 0
x 1 − x 0
x 2 − x 0
Recurrence formula
Assume we have :
Interpolating points : (x 0 , y 0 ) · · · (x n−1 , y n−1 ), P n−1 = α 0 +
n−1
X
j=1
α j j−1
Y
k=0
(X − x k ), (α j ) 0≤j≤n−1 known Interpolating points : (x 1 , y 1 ) · · · (x n , y n ),
Q n−1 = β 0 +
n−1
X
j=1
β j
j
Y
k=1
(X − x k ), (β j ) 0≤j≤n−1 known Then,
X − x 0
x n − x 0 Q n−1 + x n − X x n − x 0 P n−1
= P n
and
α n = 1
x n − x 0 β n−1 − 1
x n − x 0 α n−1 = β n−1 − α n−1
x n − x 0 .
Recurrence formula
Assume we have :
Interpolating points : (x 0 , y 0 ) · · · (x n−1 , y n−1 ), P n−1 = α 0 +
n−1
X
j=1
α j j−1
Y
k=0
(X − x k ), (α j ) 0≤j≤n−1 known Interpolating points : (x 1 , y 1 ) · · · (x n , y n ),
Q n−1 = β 0 +
n−1
X
j=1
β j
j
Y
k=1
(X − x k ), (β j ) 0≤j≤n−1 known Then,
X − x 0
x n − x 0 Q n−1 + x n − X
x n − x 0 P n−1 = P n
and
α n = 1
x n − x 0 β n−1 − 1
x n − x 0 α n−1 = β n−1 − α n−1
x n − x 0 .
Recurrence formula
Assume we have :
Interpolating points : (x 0 , y 0 ) · · · (x n−1 , y n−1 ), P n−1 = α 0 +
n−1
X
j=1
α j j−1
Y
k=0
(X − x k ), (α j ) 0≤j≤n−1 known Interpolating points : (x 1 , y 1 ) · · · (x n , y n ),
Q n−1 = β 0 +
n−1
X
j=1
β j
j
Y
k=1
(X − x k ), (β j ) 0≤j≤n−1 known Then,
X − x 0
x n − x 0 Q n−1 + x n − X
x n − x 0 P n−1 = P n and
α n = 1
x n − x 0 β n−1 − 1
x n − x 0 α n−1 = β n−1 − α n−1
x n − x 0 .
The divided differences
x 0 f (x 0 ) x 1 f (x 1 ) x 2 f (x 2 )
.. . .. .
.. . .. . . ..
x n−1 f (x n−1 )
. ..
x n f (x n )
· · · · f [x 0 , · · · , x n ] with
f [x 0 , · · · , x n ] = f[x 1 , · · · , x n ] − f [x 0 , · · · , x n−1 ] x n − x 0
.
The divided differences
x 0 f [x 0 ] x 1 f [x 1 ] x 2 f [x 2 ]
.. . .. .
.. . .. . . ..
x n−1 f [x n−1 ]
. ..
x n f [x n ]
· · · · f [x 0 , · · · , x n ] with
f [x 0 , · · · , x n ] = f[x 1 , · · · , x n ] − f [x 0 , · · · , x n−1 ] x n − x 0
.
The divided differences
x 0 f [x 0 ]
x 1 f [x 1 ] f [x 1 ] − f [x 0 ] x 1 − x 0
x 2 f [x 2 ] f [x 2 ] − f [x 1 ] x 2 − x 1
.. . .. . .. .
.. . . ..
x n−1 f [x n−1 ] f[x n−1 ] − f [x n−2 ] x n−1 − x n−2
. ..
x n f [x n ] f[x n ] − f [x n−1 ] x n − x n−1
· · · · f [x 0 , · · · , x n ] with
f [x 0 , · · · , x n ] = f[x 1 , · · · , x n ] − f [x 0 , · · · , x n−1 ]
x n − x 0 .
The divided differences
x 0 f [x 0 ]
x 1 f [x 1 ] f [x 0 , x 1 ] x 2 f [x 2 ] f [x 1 , x 2 ]
.. . .. . .. .
.. . . ..
x n−1 f [x n−1 ] f [x n−2 , x n−1 ]
. ..
x n f [x n ] f [x n−1 , x n ]
· · · · f[x 0 , · · · , x n ] with
f [x 0 , · · · , x n ] = f[x 1 , · · · , x n ] − f [x 0 , · · · , x n−1 ] x n − x 0
.
The divided differences
x 0 f [x 0 ]
x 1 f [x 1 ] f [x 0 , x 1 ]
x 2 f [x 2 ] f [x 1 , x 2 ] f [x 1 , x 2 ] − f [x 0 , x 1 ] x 2 − x 0
.. . .. . .. . .. .
. ..
x n−1 f [x n−1 ] f [x n−2 , x n−1 ] f [x n−1 , x n ] − f [x n−2 , x n−1 ] x n − x n−2
. ..
x n f [x n ] f [x n−1 , x n ] f [x n−1 , x n ] − f [x n−2 , x n−1 ] x n − x n−2
· · · · f [x 0 , · · · , x n ] with
f [x 0 , · · · , x n ] = f[x 1 , · · · , x n ] − f [x 0 , · · · , x n−1 ] x n − x 0
.
The divided differences
x 0 f [x 0 ]
x 1 f [x 1 ] f [x 0 , x 1 ]
x 2 f [x 2 ] f [x 1 , x 2 ] f [x 0 , x 1 , x 2 ]
.. . .. . .. . .. .
. ..
x n−1 f [x n−1 ] f [x n−2 , x n−1 ] f [x n−3 , x n−2 , x n−1 ]
. ..
x n f [x n ] f [x n−1 , x n ] f [x n−2 , x n−1 , x n ]
· · · · f [x 0 , · · · , x n ] with
f [x 0 , · · · , x n ] = f[x 1 , · · · , x n ] − f [x 0 , · · · , x n−1 ] x n − x 0
.
The divided differences
x 0 f [x 0 ]
x 1 f [x 1 ] f [x 0 , x 1 ]
x 2 f [x 2 ] f [x 1 , x 2 ] f [x 0 , x 1 , x 2 ]
.. . .. . .. . .. . . ..
x n−1 f [x n−1 ] f [x n−2 , x n−1 ] f [x n−3 , x n−2 , x n−1 ] . ..
x n f [x n ] f [x n−1 , x n ] f [x n−2 , x n−1 , x n ] · · · · f [x 0 , · · · , x n ] with
f[x 0 , · · · , x n ] = f[x 1 , · · · , x n ] − f [x 0 , · · · , x n−1 ] x n − x 0
.
The divided differences
x 0 f [x 0 ]
x 1 f [x 1 ] f [x 0 , x 1 ]
x 2 f [x 2 ] f [x 1 , x 2 ] f [x 0 , x 1 , x 2 ]
.. . .. . .. . .. . . ..
x n−1 f [x n−1 ] f [x n−2 , x n−1 ] f [x n−3 , x n−2 , x n−1 ] . ..
x n f [x n ] f [x n−1 , x n ] f [x n−2 , x n−1 , x n ] · · · · f[x 0 , · · · , x n ]
Þ P n = f[x 0 ] + f[x 0 , x 1 ](X − x 0 ) + f [x 0 , x 1 , x 2 ](X − x 0 )(X − x 1 ) + · · · + f [x 0 , · · · , x n ]
n−1
Y
j=0
(X − x j ).
The divided differences
x 0 f [x 0 ]
x 1 f [x 1 ] f [x 0 , x 1 ]
x 2 f [x 2 ] f [x 1 , x 2 ] f [x 0 , x 1 , x 2 ]
.. . .. . .. . .. . . ..
x n−1 f [x n−1 ] f [x n−2 , x n−1 ] f [x n−3 , x n−2 , x n−1 ] . ..
x n f [x n ] f [x n−1 , x n ] f [x n−2 , x n−1 , x n ] · · · · f[x 0 , · · · , x n ]
Cost of the computation ≈ n 2
2 div. and n 2 sub.
Result
Theorem
The Lagrange interpolating polynomial of f in the points (x i ) 0≤i≤n
reads
P n = f [x 0 ] +
n
X
j=1
f[x 0 , · · · , x j ]
j−1
Y
k=0
(X − x k ),
where f [ ] denotes the divided difference of f defined by induction f [x i ] = f (x i ) for 0 ≤ i ≤ n
f [x i , · · · , x i+k ] = f [x i+1 , · · · , x i+k ] − f [x i , · · · , x i+k−1 ] x i+k − x i
for 0 ≤ i ≤ n − k, 1 ≤ k ≤ n.
IV. A few words about Hermite interpolation
1
Presentation of the problem
One example
f (x) = sin( πx
2 )(x 2 + 3)
Consider two points : (x 0 , y 0 ) = (−1, −4) (x 1 , y 1 ) = (3, −12)
P = −4 − 2(X + 1) = −6 − 2X Q = P + (X + 1)(X − 3)(αX + β)
= P + (X + 1)(X − 3)(−1)
= −X 2 − 3
One example
f (x) = sin( πx
2 )(x 2 + 3)
Consider two points : (x 0 , y 0 ) = (−1, −4) (x 1 , y 1 ) = (3, −12) Search P such that
P (x 0 ) = f (x 0 ), P (x 1 ) = f (x 1 )
P = −4 − 2(X + 1) = −6 − 2X Q = P + (X + 1)(X − 3)(αX + β)
= P + (X + 1)(X − 3)(−1)
= −X 2 − 3
One example
f (x) = sin( πx
2 )(x 2 + 3)
Consider two points : (x 0 , y 0 ) = (−1, −4) (x 1 , y 1 ) = (3, −12) Search P such that
P (x 0 ) = f (x 0 ), P (x 1 ) = f (x 1 )
P = −4 − 2(X + 1) = −6 − 2X
Q = P + (X + 1)(X − 3)(αX + β)
= P + (X + 1)(X − 3)(−1)
= −X 2 − 3
One example
f (x) = sin( πx
2 )(x 2 + 3)
Consider two points : (x 0 , y 0 ) = (−1, −4) (x 1 , y 1 ) = (3, −12) Search Q such that
Q(x 0 ) = f (x 0 ), Q(x 1 ) = f (x 1 ) Q 0 (x 0 ) = f 0 (x 0 ), Q 0 (x 1 ) = f 0 (x 1 )
P = −4 − 2(X + 1) = −6 − 2X
Q = P + (X + 1)(X − 3)(αX + β)
= P + (X + 1)(X − 3)(−1)
= −X 2 − 3
One example
f (x) = sin( πx
2 )(x 2 + 3)
Consider two points : (x 0 , y 0 ) = (−1, −4) (x 1 , y 1 ) = (3, −12) Search Q such that
Q(x 0 ) = f (x 0 ), Q(x 1 ) = f (x 1 ) Q 0 (x 0 ) = f 0 (x 0 ), Q 0 (x 1 ) = f 0 (x 1 )
P = −4 − 2(X + 1) = −6 − 2X Q = P + (X + 1)(X − 3)(αX + β)
= P + (X + 1)(X − 3)(−1)
= −X 2 − 3
One example
f (x) = sin( πx
2 )(x 2 + 3)
Consider two points : (x 0 , y 0 ) = (−1, −4) (x 1 , y 1 ) = (3, −12) Search Q such that
Q(x 0 ) = f (x 0 ), Q(x 1 ) = f (x 1 ) Q 0 (x 0 ) = f 0 (x 0 ), Q 0 (x 1 ) = f 0 (x 1 )
P = −4 − 2(X + 1) = −6 − 2X Q = P + (X + 1)(X − 3)(αX + β)
= P + (X + 1)(X − 3)(−1)
= −X 2 − 3
With 2 other points
f (x) = sin( πx
2 )(x 2 + 3)
P = 0 Q = − π
2 X 3 + π
4 X 2 + 3π
2 X
The mathematical problem
Generalities
The Hermite interpolation takes into account
the values of the function in some points (x i ) 0≤i≤k ,
the values of the successive derivatives of the function until order α i in x i .
Formulation
f is a sufficiently smooth function defined on [a, b], x 0 , . . . , x k are (k + 1) given points of [a, b],
α 0 , . . . , α k are (k + 1) integers.
Is it possible to find P satisfying
∀0 ≤ i ≤ k, P (j) (x i ) = f (j) (x i ), ∀0 ≤ j ≤ α i ?
IV. A few words about Hermite interpolation
1
Presentation of the problem
2
Main results
Analysis of the problem
Degree of P
Number of equations :
k
X
i=0
(α i + 1) = k + 1 +
k
X
i=0
α i .
Degree : n = k +
k
X
i=0
α i .
Definition
P is the Hermite interpolating polynomial of f in the
points (x i ) 0≤i≤k with the orders (α i ) 0≤i≤k
Theorem
Theorem : existence and uniqueness + interpolation error Hypotheses :
(x i ) 0≤i≤k , (k + 1) points in [a, b],
(α i ) 0≤i≤k , (k + 1) integers, n = k +
k
X
i=0
α i f : [a, b] → R , f ∈ C n+1 ([a, b]),
Then, there exists a unique polynomial P n ∈ R n [X] such that
∀0 ≤ i ≤ k, P n (j) (x i ) = f (j) (x i ), ∀0 ≤ j ≤ α i . Furthermore, for all x ∈ [a, b], there exists ξ x ∈ [a, b] such that
f (x) − P n (x) = 1
(n + 1)! Ω n (x)f (n+1) (ξ x ), with Ω n =
k
Y
i=0
(X − x i ) α
i+1 .
V. Least squares method
1
The case of linear regression
Linear regression
We are looking for a 0 and b 0 such that the following distance is mini- mal :
d(a, b) =
n
X
i=1
(y i − (ax i + b)) 2 .
Necessary condition
∂d
∂a (a 0 , b 0 ) = 0 and ∂d
∂b (a 0 , b 0 ) = 0
⇐⇒
a 0
n
X
i=1
x 2 i + b 0
n
X
i=1
x i =
n
X
i=1
x i y i
a 0 n
X
i=1
x i + b 0 n =
n
X
i=1
y i
Existence of a unique candidate (a 0 , b 0 )
Matrix of the linear system
A =
n
X
i=1
x 2 i
n
X
i=1
x i
n
X
i=1
x i n
= n
1 n
n
X
i=1
x 2 i X ¯ X ¯ 1
Invertibility det A = n 2 ( 1
n
n
X
i=1
x 2 i − X ¯ 2 ) = n
n
X
i=1
(x i − X) ¯ 2 = n 2 V(X).
Conclusion
As soon as two x i are different, det A 6= 0 and there exists a unique (a 0 , b 0 ) susceptible to be a minimum of d :
a 0 = Cov(X, Y )
V(X) and b 0 = ¯ Y − a 0 X. ¯
(a 0 , b 0 ) is a minimizer of d
After some computations, we prove that d(a, b) − d(a 0 , b 0 ) =
n
X
i=1
((a 0 − a)x i + b 0 − b) 2 It yields
∀(a, b) ∈ R 2 d(a, b) ≥ d(a 0 , b 0 ).
Remark on the matrix A
A =
n
X
i=1
x 2 i
n
X
i=1
x i n
X
i=1
x i n
= B T B with B =
x 1 1 x 2 1 .. . .. . x n 1
V. Least squares method
1
The case of linear regression
2