Interpolation and Curve Fitting II: Divided Differences, Least-Squares Approximations
Interpolation and Curve Fitting II: Divided Differences, Least-Squares Approximations
Fitting II
Lecture 8
Interpolation and Curve Fitting II
Divided Differences,Least-Squares Approximations
Divided Differences
Spline Curves
Ceng375 Numerical Computations at December 9, 2010 The Equation for a Cubic
Spline
Least-Squares
Approximations
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
2 Spline Curves Approximations
3 Least-Squares Approximations
8.2
Interpolation and Curve
Interpolation and Curve Fitting II Fitting II
Least-Squares
Approximations
8.3
Interpolation and Curve
Interpolation and Curve Fitting II Fitting II
8.3
Interpolation and Curve
Interpolation and Curve Fitting II Fitting II
8.3
Interpolation and Curve
Divided Differences I Fitting II
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.4
Interpolation and Curve
Divided Differences I Fitting II
Least-Squares
Approximations
8.4
Interpolation and Curve
Divided Differences I Fitting II
Least-Squares
have to start over in the computations. Approximations
8.4
Interpolation and Curve
Divided Differences I Fitting II
Least-Squares
have to start over in the computations. Approximations
8.4
Interpolation and Curve
Divided Differences I Fitting II
Least-Squares
have to start over in the computations. Approximations
8.4
Interpolation and Curve
Divided Differences I Fitting II
Least-Squares
have to start over in the computations. Approximations
8.4
Interpolation and Curve
Divided Differences II Fitting II
th
• Every n -degree polynomial that passes through the
same n + 1 points is identical.
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.5
Interpolation and Curve
Divided Differences II Fitting II
th
• Every n -degree polynomial that passes through the
same n + 1 points is identical.
• Only the way that the polynomial is expressed is different.
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.5
Interpolation and Curve
Divided Differences II Fitting II
th
• Every n -degree polynomial that passes through the
same n + 1 points is identical.
• Only the way that the polynomial is expressed is different.
• The function, f (x ), is known at several values for x : Divided Differences
Spline Curves
x0 f0 The Equation for a Cubic
Spline
x1 f1 Least-Squares
x2 f2 Approximations
x3 f3
8.5
Interpolation and Curve
Divided Differences II Fitting II
th
• Every n -degree polynomial that passes through the
same n + 1 points is identical.
• Only the way that the polynomial is expressed is different.
• The function, f (x ), is known at several values for x : Divided Differences
Spline Curves
x0 f0 The Equation for a Cubic
Spline
x1 f1 Least-Squares
x2 f2 Approximations
x3 f3
8.5
Interpolation and Curve
Divided Differences II Fitting II
th
• Every n -degree polynomial that passes through the
same n + 1 points is identical.
• Only the way that the polynomial is expressed is different.
• The function, f (x ), is known at several values for x : Divided Differences
Spline Curves
x0 f0 The Equation for a Cubic
Spline
x1 f1 Least-Squares
x2 f2 Approximations
x3 f3
8.5
Interpolation and Curve
Divided Differences II Fitting II
th
• Every n -degree polynomial that passes through the
same n + 1 points is identical.
• Only the way that the polynomial is expressed is different.
• The function, f (x ), is known at several values for x : Divided Differences
Spline Curves
x0 f0 The Equation for a Cubic
Spline
x1 f1 Least-Squares
x2 f2 Approximations
x3 f3
8.5
Interpolation and Curve
Divided Differences III Fitting II
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.6
Interpolation and Curve
Divided Differences III Fitting II
f1 − f0
f [x0 , x1 ] =
x1 − x0 Divided Differences
Spline Curves
called the first divided difference between x0 and x1 . The Equation for a Cubic
Spline
Least-Squares
Approximations
8.6
Interpolation and Curve
Divided Differences III Fitting II
f1 − f0
f [x0 , x1 ] =
x1 − x0 Divided Differences
Spline Curves
called the first divided difference between x0 and x1 . The Equation for a Cubic
Spline
f [xs ] = fs
8.6
Interpolation and Curve
Divided Differences III Fitting II
f1 − f0
f [x0 , x1 ] =
x1 − x0 Divided Differences
Spline Curves
called the first divided difference between x0 and x1 . The Equation for a Cubic
Spline
f [xs ] = fs
• In general,
ft − fs
f [xs , xt ] =
xt − xs
8.6
Interpolation and Curve
Divided Differences III Fitting II
f1 − f0
f [x0 , x1 ] =
x1 − x0 Divided Differences
Spline Curves
called the first divided difference between x0 and x1 . The Equation for a Cubic
Spline
f [xs ] = fs
• In general,
ft − fs
f [xs , xt ] =
xt − xs
• Second- and higher-order differences are defined in terms
of lower-order differences.
f [x1 , x2 ] − f [x0 , x1 ]
f [x0 , x1 , x2 ] =
x2 − x0
8.6
Interpolation and Curve
Divided Differences IV Fitting II
• For n-terms,
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.7
Interpolation and Curve
Divided Differences IV Fitting II
• For n-terms,
Spline Curves
• Using the standard notation, a divided-difference table is The Equation for a Cubic
Spline
8.7
Interpolation and Curve
Divided Differences V Fitting II
Least-Squares
Approximations
f1 − f0 17.8 − 22.0
f [x0 , x1 ] = = = 8.4
x1 − x0 2.7 − 3.2
f2 − f1 14.2 − 17.8
f [x1 , x2 ] = = = 2.1176
x2 − x1 1.0 − 2.7
f [x1 , x2 ] − f [x0 , x1 ] 2.1176 − 8.4
f [x0 , x1 , x2 ] = = = 2.8556
x2 − x0 1.0 − 3.2
and the others..
8.8
Interpolation and Curve
Divided Differences VI Fitting II
x = x0 : P0 (x0 ) = a0
x = x1 : P1 (x1 ) = a0 + (x1 − x0 )a1
x = x2 : P2 (x2 ) = a0 + (x2 − x0 )a1 + (x2 − x0 )(x2 − x1 )a2
.. ..
. .
Divided Differences
x = xn : Pn (xn ) = a0 + (xn − x0 )a1 + (xn − x0 )(xn − x1 )a2 + . . .
Spline Curves
+(xn − x0 ) . . . (xn − xn−1 )an The Equation for a Cubic
Spline
Least-Squares
• If Pn (x ) is to be an interpolating polynomial, it must match Approximations
8.9
Interpolation and Curve
Divided Differences VI Fitting II
x = x0 : P0 (x0 ) = a0
x = x1 : P1 (x1 ) = a0 + (x1 − x0 )a1
x = x2 : P2 (x2 ) = a0 + (x2 − x0 )a1 + (x2 − x0 )(x2 − x1 )a2
.. ..
. .
Divided Differences
x = xn : Pn (xn ) = a0 + (xn − x0 )a1 + (xn − x0 )(xn − x1 )a2 + . . .
Spline Curves
+(xn − x0 ) . . . (xn − xn−1 )an The Equation for a Cubic
Spline
Least-Squares
• If Pn (x ) is to be an interpolating polynomial, it must match Approximations
Least-Squares
Approximations
8.10
Interpolation and Curve
Divided Differences VII Fitting II
Least-Squares
points? Approximations
8.10
Interpolation and Curve
Divided Differences VII Fitting II
Least-Squares
points? Approximations
8.10
Interpolation and Curve
Divided Differences VII Fitting II
Least-Squares
points? Approximations
8.10
Interpolation and Curve
Divided Differences VII Fitting II
Least-Squares
points? Approximations
8.10
Interpolation and Curve
Divided Differences VII Fitting II
Least-Squares
points? Approximations
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.11
Interpolation and Curve
Divided Differences IX Fitting II
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.12
Interpolation and Curve
Divided Differences IX Fitting II
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.12
Interpolation and Curve
Divided Differences IX Fitting II
f (x ) = 2x 3 − x 2 + x − 1. Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.12
Interpolation and Curve
Divided Differences IX Fitting II
f (x ) = 2x 3 − x 2 + x − 1. Spline Curves
The Equation for a Cubic
Spline
Least-Squares
• Here is its divided-difference table: Approximations
8.12
Interpolation and Curve
Divided Differences IX Fitting II
f (x ) = 2x 3 − x 2 + x − 1. Spline Curves
The Equation for a Cubic
Spline
Least-Squares
• Here is its divided-difference table: Approximations
8.12
Interpolation and Curve
Divided Differences IX Fitting II
f (x ) = 2x 3 − x 2 + x − 1. Spline Curves
The Equation for a Cubic
Spline
Least-Squares
• Here is its divided-difference table: Approximations
Spline Curves
Least-Squares
Approximations
8.13
Interpolation and Curve
Spline Curves I Fitting II
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.14
Interpolation and Curve
Spline Curves II Fitting II
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.15
Interpolation and Curve
Spline Curves II Fitting II
Least-Squares
Approximations
8.15
Interpolation and Curve
Spline Curves II Fitting II
8.15
Interpolation and Curve
Spline Curves II Fitting II
8.15
Interpolation and Curve
Spline Curves II Fitting II
8.15
Interpolation and Curve
Spline Curves III Fitting II
Divided Differences
Spline Curves
The Equation for a Cubic
Figure: Fitting with quadratic in subinterval. Spline
Least-Squares
Approximations
8.16
Interpolation and Curve
Spline Curves III Fitting II
Divided Differences
Spline Curves
The Equation for a Cubic
Figure: Fitting with quadratic in subinterval. Spline
Least-Squares
Approximations
8.16
Interpolation and Curve
Spline Curves III Fitting II
Divided Differences
Spline Curves
The Equation for a Cubic
Figure: Fitting with quadratic in subinterval. Spline
Least-Squares
Approximations
8.16
Interpolation and Curve
Spline Curves III Fitting II
Divided Differences
Spline Curves
The Equation for a Cubic
Figure: Fitting with quadratic in subinterval. Spline
Least-Squares
Approximations
8.16
Interpolation and Curve
Spline Curves III Fitting II
Divided Differences
Spline Curves
The Equation for a Cubic
Figure: Fitting with quadratic in subinterval. Spline
Least-Squares
Approximations
(xi , yi ), with i = 0, 1, 2, . . . , n.
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.17
Interpolation and Curve
Spline Curves IV Fitting II
(xi , yi ), with i = 0, 1, 2, . . . , n.
Least-Squares
Approximations
8.17
Interpolation and Curve
Spline Curves IV Fitting II
(xi , yi ), with i = 0, 1, 2, . . . , n.
8.17
Interpolation and Curve
Spline Curves IV Fitting II
(xi , yi ), with i = 0, 1, 2, . . . , n.
8.17
Interpolation and Curve
Spline Curves IV Fitting II
(xi , yi ), with i = 0, 1, 2, . . . , n.
Divided Differences
Figure: Cubic spline.
Spline Curves
The Equation for a Cubic
Spline
8.18
Interpolation and Curve
The Equation for a Cubic Spline I Fitting II
Divided Differences
Figure: Cubic spline.
Spline Curves
The Equation for a Cubic
Spline
8.18
Interpolation and Curve
The Equation for a Cubic Spline I Fitting II
Divided Differences
Figure: Cubic spline.
Spline Curves
The Equation for a Cubic
Spline
8.18
Interpolation and Curve
The Equation for a Cubic Spline I Fitting II
Divided Differences
Figure: Cubic spline.
Spline Curves
The Equation for a Cubic
Spline
8.18
Interpolation and Curve
The Equation for a Cubic Spline I Fitting II
Divided Differences
Figure: Cubic spline.
Spline Curves
The Equation for a Cubic
Spline
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.19
Interpolation and Curve
The Equation for a Cubic Spline II Fitting II
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.19
Interpolation and Curve
The Equation for a Cubic Spline II Fitting II
Least-Squares
Approximations
8.19
Interpolation and Curve
The Equation for a Cubic Spline II Fitting II
• Least-Squares
Approximations
gi (xi+1 ) = gi+1 (xi+1 ), i = 0, 1, . . . , n − 2 (2)
8.19
Interpolation and Curve
The Equation for a Cubic Spline II Fitting II
• Least-Squares
Approximations
gi (xi+1 ) = gi+1 (xi+1 ), i = 0, 1, . . . , n − 2 (2)
•
′ ′
gi (xi+1 ) = gi+1 (xi+1 ), i = 0, 1, . . . , n − 2 (3)
8.19
Interpolation and Curve
The Equation for a Cubic Spline II Fitting II
• Least-Squares
Approximations
gi (xi+1 ) = gi+1 (xi+1 ), i = 0, 1, . . . , n − 2 (2)
•
′ ′
gi (xi+1 ) = gi+1 (xi+1 ), i = 0, 1, . . . , n − 2 (3)
•
′′ ′′
gi (xi+1 ) = gi+1 (xi+1 ), i = 0, 1, . . . , n − 2 (4)
8.19
Interpolation and Curve
The Equation for a Cubic Spline II Fitting II
• Least-Squares
Approximations
gi (xi+1 ) = gi+1 (xi+1 ), i = 0, 1, . . . , n − 2 (2)
•
′ ′
gi (xi+1 ) = gi+1 (xi+1 ), i = 0, 1, . . . , n − 2 (3)
•
′′ ′′
gi (xi+1 ) = gi+1 (xi+1 ), i = 0, 1, . . . , n − 2 (4)
• Until now, we have assumed that the data are accurate, Dr. Cem Özdoğan
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.20
Interpolation and Curve
Least-Squares Approximations I Fitting II
• Until now, we have assumed that the data are accurate, Dr. Cem Özdoğan
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.20
Interpolation and Curve
Least-Squares Approximations I Fitting II
• Until now, we have assumed that the data are accurate, Dr. Cem Özdoğan
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.20
Interpolation and Curve
Least-Squares Approximations I Fitting II
• Until now, we have assumed that the data are accurate, Dr. Cem Özdoğan
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.20
Interpolation and Curve
Least-Squares Approximations I Fitting II
• Until now, we have assumed that the data are accurate, Dr. Cem Özdoğan
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.20
Interpolation and Curve
Least-Squares Approximations I Fitting II
• Until now, we have assumed that the data are accurate, Dr. Cem Özdoğan
Least-Squares
Approximations
8.20
Interpolation and Curve
Least-Squares Approximations I Fitting II
• Until now, we have assumed that the data are accurate, Dr. Cem Özdoğan
8.20
Interpolation and Curve
Least-Squares Approximations I Fitting II
• Until now, we have assumed that the data are accurate, Dr. Cem Özdoğan
8.20
Interpolation and Curve
Least-Squares Approximations I Fitting II
• Until now, we have assumed that the data are accurate, Dr. Cem Özdoğan
• If someone else were given the data and asked to draw Divided Differences
Least-Squares
Approximations
8.21
Interpolation and Curve
Least-Squares Approximations II Fitting II
• If someone else were given the data and asked to draw Divided Differences
Least-Squares
and they would get different values for a and b. Approximations
8.21
Interpolation and Curve
Least-Squares Approximations II Fitting II
• If someone else were given the data and asked to draw Divided Differences
Least-Squares
and they would get different values for a and b. Approximations
8.21
Interpolation and Curve
Least-Squares Approximations II Fitting II
• If someone else were given the data and asked to draw Divided Differences
Least-Squares
and they would get different values for a and b. Approximations
8.21
Interpolation and Curve
Least-Squares Approximations III Fitting II
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.22
Interpolation and Curve
Least-Squares Approximations III Fitting II
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.22
Interpolation and Curve
Least-Squares Approximations III Fitting II
Spline Curves
• The deviations are determined by the distances between The Equation for a Cubic
Spline
the points and the line. Least-Squares
Approximations
8.22
Interpolation and Curve
Least-Squares Approximations III Fitting II
Spline Curves
• The deviations are determined by the distances between The Equation for a Cubic
Spline
the points and the line. Least-Squares
Approximations
8.22
Interpolation and Curve
Least-Squares Approximations III Fitting II
Spline Curves
• The deviations are determined by the distances between The Equation for a Cubic
Spline
the points and the line. Least-Squares
Approximations
8.22
Interpolation and Curve
Least-Squares Approximations III Fitting II
Spline Curves
• The deviations are determined by the distances between The Equation for a Cubic
Spline
the points and the line. Least-Squares
Approximations
8.22
Interpolation and Curve
Least-Squares Approximations III Fitting II
Spline Curves
• The deviations are determined by the distances between The Equation for a Cubic
Spline
the points and the line. Least-Squares
Approximations
8.22
Interpolation and Curve
Least-Squares Approximations III Fitting II
Spline Curves
• The deviations are determined by the distances between The Equation for a Cubic
Spline
the points and the line. Least-Squares
Approximations
8.22
Interpolation and Curve
Least-Squares Approximations III Fitting II
Spline Curves
• The deviations are determined by the distances between The Equation for a Cubic
Spline
the points and the line. Least-Squares
Approximations
8.22
Interpolation and Curve
Least-Squares Approximations IV Fitting II
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.23
Interpolation and Curve
Least-Squares Approximations IV Fitting II
Spline Curves
criterion). The Equation for a Cubic
Spline
Least-Squares
Approximations
8.23
Interpolation and Curve
Least-Squares Approximations IV Fitting II
Spline Curves
criterion). The Equation for a Cubic
Spline
• The usual criterion is to minimize the sum of the squares Least-Squares
of the errors, the least-squares principle. Approximations
8.23
Interpolation and Curve
Least-Squares Approximations IV Fitting II
Spline Curves
criterion). The Equation for a Cubic
Spline
• The usual criterion is to minimize the sum of the squares Least-Squares
of the errors, the least-squares principle. Approximations
8.23
Interpolation and Curve
Least-Squares Approximations IV Fitting II
Spline Curves
criterion). The Equation for a Cubic
Spline
• The usual criterion is to minimize the sum of the squares Least-Squares
of the errors, the least-squares principle. Approximations
8.23
Interpolation and Curve
Least-Squares Approximations IV Fitting II
Spline Curves
criterion). The Equation for a Cubic
Spline
• The usual criterion is to minimize the sum of the squares Least-Squares
of the errors, the least-squares principle. Approximations
8.23
Interpolation and Curve
Least-Squares Approximations IV Fitting II
Spline Curves
criterion). The Equation for a Cubic
Spline
• The usual criterion is to minimize the sum of the squares Least-Squares
of the errors, the least-squares principle. Approximations
yi = axi + b
Divided Differences
where xi is a particular value of the variable assumed to
Spline Curves
be free of error. The Equation for a Cubic
Spline
Least-Squares
Approximations
8.24
Interpolation and Curve
Least-Squares Approximations V Fitting II
yi = axi + b
Divided Differences
where xi is a particular value of the variable assumed to
Spline Curves
be free of error. The Equation for a Cubic
Spline
• We wish to determine the best values for a and b so that Least-Squares
Approximations
the y ’s predict the function values that correspond to
x -values.
8.24
Interpolation and Curve
Least-Squares Approximations V Fitting II
yi = axi + b
Divided Differences
where xi is a particular value of the variable assumed to
Spline Curves
be free of error. The Equation for a Cubic
Spline
• We wish to determine the best values for a and b so that Least-Squares
Approximations
the y ’s predict the function values that correspond to
x -values.
• Let
ei = Yi − yi
8.24
Interpolation and Curve
Least-Squares Approximations V Fitting II
yi = axi + b
Divided Differences
where xi is a particular value of the variable assumed to
Spline Curves
be free of error. The Equation for a Cubic
Spline
• We wish to determine the best values for a and b so that Least-Squares
Approximations
the y ’s predict the function values that correspond to
x -values.
• Let
ei = Yi − yi
8.24
Interpolation and Curve
Least-Squares Approximations V Fitting II
yi = axi + b
Divided Differences
where xi is a particular value of the variable assumed to
Spline Curves
be free of error. The Equation for a Cubic
Spline
• We wish to determine the best values for a and b so that Least-Squares
Approximations
the y ’s predict the function values that correspond to
x -values.
• Let
ei = Yi − yi
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.25
Interpolation and Curve
Least-Squares Approximations VI Fitting II
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.25
Interpolation and Curve
Least-Squares Approximations VI Fitting II
Spline Curves
• Remembering that the xi and Yi are data points unaffected The Equation for a Cubic
Spline
∂S
PN
= 0 = i=1 2(Yi − axi − b)(−xi )
∂a
∂S PN
∂b = 0 = i=1 2(Yi − axi − b)(−1)
8.25
Interpolation and Curve
Least-Squares Approximations VI Fitting II
Spline Curves
• Remembering that the xi and Yi are data points unaffected The Equation for a Cubic
Spline
∂S
PN
= 0 = i=1 2(Yi − axi − b)(−xi )
∂a
∂S PN
∂b = 0 = i=1 2(Yi − axi − b)(−1)
8.25
Interpolation and Curve
Least-Squares Approximations VI Fitting II
Spline Curves
• Remembering that the xi and Yi are data points unaffected The Equation for a Cubic
Spline
∂S
PN
= 0 = i=1 2(Yi − axi − b)(−xi )
∂a
∂S PN
∂b = 0 = i=1 2(Yi − axi − b)(−1)
Divided Differences
Spline Curves
The Equation for a Cubic
Spline
Least-Squares
Approximations
8.26
Interpolation and Curve
Least-Squares Approximations VII Fitting II
X X
The Equation for a Cubic
Spline
8.26
Interpolation and Curve
Least-Squares Approximations VII Fitting II
X X
The Equation for a Cubic
Spline
8.26
Interpolation and Curve
Least-Squares Approximations VII Fitting II
X X
The Equation for a Cubic
Spline
R = 702.2 + 3.395T
8.26
Interpolation and Curve
Least-Squares Approximations VIII Fitting II
Least-Squares
Approximations
8.27
Interpolation and Curve
Least-Squares Approximations VIII Fitting II
8.27