Curve Fitting: ME 537 Numerical Methods For Engineers University of Gaziantep Faculty of Engineering Dr. Mustafa Özakça
Curve Fitting: ME 537 Numerical Methods For Engineers University of Gaziantep Faculty of Engineering Dr. Mustafa Özakça
x
We want to find the best “fit” of a curve through the data.
f(x)
x
We want to find the best “fit” of a curve through the data.
Here we see :
a) Least squares fit
f(x)
A histogram used
to depict the distributions
of an exam grade.
x
x 2
95%
x
68%
Material to be Covered in Curve
Fitting
• Linear Regression
Polynomial Regression
Multiple Regression
General linear lease squares
Nonlinear regression
• Interpolation
Newton’s Polynomial
Lagrange polynomial
Coefficients of polynomials
Specific Study Objectives
• Understand the fundamental difference between
regression and interpolation
• Understand the derivation of linear least squares
regression and be able to assess the reliability of
the fit using graphical and quantitative
assessments.
Specific Study Objectives
• Know how to linearize data by transformation
• Understand situations where polynomial, multiple
and nonlinear regression are appropriate
• Understand the general matrix formulation of
linear least squares
• Understand that there is one and only one
polynomial of degree n or less that passes exactly
through n+1 points
Specific Study Objectives
• Become familiar with the use of Newton’s and
Lagrange formulas for interpolating polynomials
• Recognize that the Newton and Lagrange
equations are merely different formulations of the
same interpolating polynomial
• Realize that more accurate results are obtained if
data used for interpolation is centered around and
close to the unknown point
Specific Study Objectives
• Recognize the liabilities and risks associated with
extrapolation
• Understand why spline functions have utility for
data with local areas of abrupt change
Least Squares Regression
• Simplest is fitting a straight line to a set of
paired observations
(x1,y1), (x2, y2).....(xn, yn)
• The resulting mathematical expression is
y = ao + a1x + e
• We will consider the error introduced at
each data point to develop a strategy for
determining the “best fit” equations
n n 2
Sr e2i yi a o a1xi
i 1 i 1
f(x)
x
n n 2
Sr e2i yi a o a1xi
i 1 i 1
f(x)
x
n n 2
Sr e2i yi a o a1xi
i 1 i 1
f(x)
yi a o a1xi
x
n n 2
Sr e2i yi a o a1xi
i 1 i 1
Sr
2 yi ao a1xi
ao
Sr
2 yi ao a1xi xi
a1
Note: we have simplified the summation symbols.
What mathematics technique will minimize Sr?
Sr
2 yi ao a1xi
a o
Sr
2 yi ao a1xi xi
a1
n xi yi xi y i
a1
n x xi
2 2
i
ao y a1x
Error
Recall:
n n 2
f(x)
Sr e i yi a o a1xi
2
i 1 i 1
St
sy
n 1
Introduce a term to measure the standard error of the estimate:
Sr
sy
x n2
St Sr
2
r
St
Sr = 0
r = r2 = 1
12.00 10.00
10.00 8.00
8.00
6.00
f(x)
f(x)
6.00
4.00
4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15
x x
14.00 14.00
12.00 12.00
10.00 10.00
8.00 8.00
f(x)
f(x)
6.00 6.00
4.00 4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15 20
x x
f(x)
f(x)
6.00
4.00
4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15
x x
slope = 0.5
Results from Excel linest function
Data Set 3 Data Set 4
14.00 14.00
12.00 12.00
10.00 10.00
8.00 8.00
f(x)
f(x)
6.00 6.00
4.00 4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15 20
x x
f(x)
f(x)
6.00
4.00
4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15
x x
y - intercept = 3.00
Results from Excel linest function
Data Set 3 Data Set 4
14.00 14.00
12.00 12.00
10.00 10.00
8.00 8.00
f(x)
f(x)
6.00 6.00
4.00 4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15 20
x x
f(x)
f(x)
6.00
4.00
4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15
x x
14.00 14.00
12.00 12.00
10.00 10.00
8.00 8.00
f(x)
f(x)
6.00 6.00
4.00 4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15 20
x x
f(x)
f(x)
6.00
4.00
4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15
x x
f(x)
6.00 6.00
4.00 4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15 20
x x
f(x)
f(x)
6.00
4.00
4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15
x x
f(x)
6.00 6.00
4.00 4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15 20
x x
f(x)
f(x)
6.00
4.00
4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15
x x
f(x)
6.00 6.00
4.00 4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15 20
x x
f(x)
f(x)
6.00
4.00
4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15
x x
f(x)
6.00 6.00
4.00 4.00
2.00 2.00
0.00 0.00
0 5 10 15 0 5 10 15 20
x x
or so it appears.
x
P EXPONENTIAL
EQUATIONS
P Po e rt
Linearize
t
ln P
intercept = ln P0
slope = r
why?
t
rt
Can you see the similarity
P P0e with the equation for a line:
ln P ln P0e rt
y = b + mx
ln P0 lne rt
ln P0 rt where b is the y-intercept
and m is the slope?
lnP
intercept = ln Po slope = r
t
P P0e rt After taking the natural log
ln P ln P0e rt of the y-data, perform linear
regression.
ln P0 lne rt From this regression:
The value of b will give us
ln P0 rt ln (P0). Hence, P0 = eb
intercept = ln P0 slope = r
t
Q POWER EQUATIONS
Q cH a
(Flow over a weir)
log Q H
Here we linearize
the equation by
taking the log of
H and Q data.
log H
What is the resulting
intercept and slope?
Q cH a
log Q logcH a
log c log H a
log c a log H
log Q
slope = a
log H
intercept = log c
Q cH a So how do we get
log Q logcH a c and a from
performing regression
log c log H a on the log H vs log Q
log c a log H data?
From : y = mx + b
slope = m = a
slope = a
log H
intercept = log c
SATURATION-GROWTH
m
RATE EQUATION
S
max
Ks S
1/m S
Here, m is the growth rate
of a microbial population,
mmax is the maximum
growth rate, S is the
slope = Ks/mmax substrate or food
concentration, Ks is the
intercept = 1/mmax substrate concentration at a
value of m = mmax/2
1/ S
General Comments of Linear
Regression
• You should be cognizant of the fact that
there are theoretical aspects of regression
that are of practical importance but are
beyond the scope of this book
• Statistical assumptions are inherent in the
linear least squares procedure
General Comments of Linear
Regression
• x has a fixed value; it is not random and is
measured without error
• The y values are independent random
variable and all have the same variance
• The y values for a given x must be normally
distributed
General Comments of Linear
Regression
• The regression of y versus x is not the same
as x versus y
• The error of y versus x is not the same as x
versus y
General Comments of Linear
Regression
• The regression of y versus x is not the same
as x versus y
• The error of y versus x is not the same as x
versus y f(x)
x
General Comments of Linear
Regression
• The regression of y versus x is not the same
as x versus y
• The error of y versus x is not the same as x
versus y f(x)
x
General Comments of Linear
Regression
• The regression of y versus x is not the same
as x versus y
• The error of y versus x is not the same as x
versus y f(x)
x-direction
x
General Comments of Linear
Regression
• The regression of y versus x is not the same
as x versus y
• The error of y versus x is not the same as x
versus y f(x)
y-direction
x-direction
x
Polynomial Regression
• One of the reasons you were presented with
the theory behind linear regression was to
allow you the insight behind similar
procedures for higher order polynomials
• y = a 0 + a 1x
• mth - degree polynomial
y = a0 + a1x + a2x2 +....amxm + e
Based on the sum of the squares
of the residuals
Sr yi a o a1xi a x ...... a x
2 i
2
m i
m 2
Based on the sum of the squares
of the residuals
Sr yi a o a1xi a x ...... a x
2 i
2
m i
m 2
Sr
2 xi yi ao a1xi a2 xi2 ..... amxim
2
a 2
2. These equations are set to zero to minimize Sr., i.e.
minimize the error.
2. These equations are set to zero to minimize Sr., i.e.
minimize the error.
x2 i x y
x x
1i 2 i x 2
2 i a 2
2 i i
[A] and {c}are clearly based on data given for x1, x2 and y
to solve for the unknowns in {x}.
Interpolation
• General formula for an n-th order
polynomial
y = a0 + a1x + a2x2 +....amxm
• For m+1 data points, there is one, and only
one polynomial of order m or less that
passes through all points
• Example: y = a0 + a1x
– fits between 2 points
– 1st order
Interpolation
• We will explore two mathematical methods
well suited for computer implementation
• Newton’s Divided Difference Interpolating
Polynomials
• Lagrange Interpolating Polynomial
Newton’s Divided Difference
Interpolating Polynomials
• Linear Interpolation
• Quadratic Interpolation
• General Form
• Errors
Linear Interpolation
3
Temperature, C Density, kg/m
0 999.9
5 1000.0
10 999.7
15 999.1
20 998.2
T
15 20
r
999.1
998.2
T
15 20
999.1
998.2
17 T
15 20
999.1
998.2
17 T
15 20
f x1 f x0
f1 x f xo x x0
x1 x0
998.2 999 .1 998.2
20 15 20 17
f x1 f x0
f1 x f xo x x0
x1 x0
f(x)
x
true solution 1
2
f(x)
smaller intervals
provide a better estimate
x
true solution 1
2
f(x)
x
true solution
f(x)
x
Quadratic Interpolation
f 2 x b0 b1 x x0 b2 x x0 x x1
f 2 x b0 b1 x x0 b2 x x0 x x1
First, multiply the terms
f 2 x b0 b1 x x0 b2 x x0 x x1
f 2 x b0 b1 x x0 b2 x x0 x x1
a0 b0 b1 x0 b2 x0 x1
f x a0 a1x a2 x 2
a1 b1 b2 x0 b2 x1
a2 b2
x, f(x) x2, f(x2)
f(x)
Procedure for
x1, f(x1)
Quadratic
x0, f(x0)
Interpolation
x
b0 f x0
f x1 f x0
b1
x1 x0
f x2 f x1 f x1 f x0
x2 x1 x1 x0
b2
x2 x0
Procedure for Quadratic
Interpolation
b0 f x0
f x1 f x0
b1
x1 x0
f x2 f x1 f x1 f x0
x2 x1 x1 x0
b2
x2 x0
Procedure for Quadratic
Interpolation
b0 f x0
f x1 f x0
b1
x1 x0
f x2 f x1 f x1 f x0
x2 x1 x1 x0
b2
x2 x0
f 2 x b0 b1 x x0 b2 x x0 x x1
Example
1000 Include 10 degrees in
999.5 your calculation of the
density at 17 degrees.
Density
999
998.5
3
998
Temperature, C Density, kg/m
0 5 10 15 20 0 999.9
Tem p
5 1000.0
10 999.7
15 999.1
20 998.2
Example
b0 f x0
b1
f x1 f x0 Include 10 degrees in
x1 x0
f x2 f x1 f x1 f x0
your calculation of the
b2
x2 x1
x1 x0 density at 17 degrees.
x 2 x0
f 2 x b0 b1 x x0 b2 x x0 x x1
3
Temperature, C Density, kg/m
0 999.9
5 1000.0
10 999.7
15 999.1
20 998.2
b0 f x0 999.7
f x1 f x0 999.1 999.7
b1 012
.
x1 x0 15 10
f x2 f x1 f x1 f x0
x2 x1 x1 x0
b2
x2 x0
998.2 999.1
012
.
20 15 0.006
20 10
f 1 17 998.74
General Form of Newton’s
Interpolating Polynomials
for the nth-order polynomial
f n x b0 b1 x x0 ....bn x x0 x x1 x x n 1
f x1 f x0
b1
x1 x0
f x2 f x1 f x1 f x0
x2 x1 x1 x0
b2
x2 x0
f xi , x j , xk
f xi , x j f x j , xk
xi xk
i xi f(xi) first
0 x0 f(x0) f[x1,x0]
1 x1 f(x1)
2 x2 f(x2)
3 x3 f(x3)
This leads to a scheme that can easily lead to the
use of spreadsheets
i xi f(xi) first
0 x0 f(x0) f[x1,x0]
1 x1 f(x1) f[x2,x1]
2 x2 f(x2)
3 x3 f(x3)
This leads to a scheme that can easily lead to the
use of spreadsheets
i xi f(xi) first
0 x0 f(x0) f[x1,x0]
1 x1 f(x1) f[x2,x1]
2 x2 f(x2) f[x2,x3]
3 x3 f(x3)
This leads to a scheme that can easily lead to the
use of spreadsheets
1 x1 f(x1) f[x2,x1]
2 x2 f(x2) f[x2,x3]
3 x3 f(x3)
This leads to a scheme that can easily lead to the
use of spreadsheets
2 x2 f(x2) f[x2,x3]
3 x3 f(x3)
This leads to a scheme that can easily lead to the
use of spreadsheets
2 x2 f(x2) f[x2,x3]
3 x3 f(x3)
f n x b0 b1 x x0 ....bn x x0 x x1 x x n 1
f n x f x0 f x1 , x0 x x0 ....
f xn , x n 1 , , x0 x x0 x x1 x xn 1
n x xj
Li x
j0 xi x j
ji
n
x xj
Li x
j 0 xi x j
j i
x x1 x x0
f1 f x0 f x1
x0 x1 x1 x0
x x1 x x2 x x3
f3 f x0
x0 x1 x0 x2 x0 x3
.......
n
f n x Li x f xi
i0
n x xj
Li x
j 0 xi x j
j i
Note:
x x1 x x2 x x3 x0 is
f3 f x0
x0 x1 x0 x2 x0 x3 not being subtracted
....... from the constant
term x
n
f n x Li x f xi
i0
n x xj
Li x
j 0 xi x j
j i
Note:
x x1 x x2 x x3 x0 is
f3 f x0
x0 x1 x0 x2 x0 x3 not being subtracted
....... from the constant
term x
n
f n x Li x f xi
i0
n x xj
Li x
j 0 xi x j
j i
Note:
x x1 x x2 x x3 x0 is
f3 f x0
x0 x1 x0 x2 x0 x3 not being subtracted
....... from the constant
term x
n
f n x Li x f xi
i0
n x xj
Li x
j 0 xi x j
j i
Note:
x x1 x x2 x x3 x0 is
f3 f x0
x0 x1 x0 x2 x0 x3 not being subtracted
....... from the constant
term x
or xi = x0 in
the numerator
or the denominator
j= 0
n
f n x Li x f xi
i0
n x xj
Li x
j 0 xi x j
j i
Note:
x x1 x x2 x x3 x0 is
f3 f x0
x0 x1 x0 x2 x0 x3 not being subtracted
....... from the constant
term x
or xi = x0 in
the numerator
or the denominator
j= 0
n
f n x Li x f xi
i0
n x xj
Li x
j 0 xi x j
j i
Note:
x x1 x x2 x x3 x0 is
f3 f x0
x0 x1 x0 x2 x0 x3 not being subtracted
....... from the constant
term x
or xi = x0 in
the numerator
or the denominator
j= 0
n
f n x Li x f xi
i 0
n x xj
Li x
j 0 xi x j
j i
x x1 x x2 x x3
f3 f x0
x0 x1 x0 x2 x0 x3
x x0 x x2 x x3
f x1
x1 x0 x1 x2 x1 x3
.......
n
f n x Li x f xi
i 0
n x xj
Li x
j 0 xi x j
j i
x x1 x x2 x x3
f3 f x0
x0 x1 x0 x2 x0 x3 Note:
x x0 x x2 x x3 x1 is
f x1 not being subtracted
x1 x0 x1 x2 x1 x3
from the constant
....... term x
or xi = x1 in
the numerator
or the denominator
j= 1
n
f n x Li x f xi
i 0
n x xj
Li x
j 0 xi x j
j i
x x1 x x2 x x3
f3 f x0
x0 x1 x0 x2 x0 x3
x x0 x x2 x x3 Note:
f x1
x1 x0 x1 x2 x1 x3 x2 is
x x0 x x1 x x3 not being subtracted
f x2 from the constant
x2 x0 x2 x1 x2 x3
term x or xi = x2 in
......
the numerator
or the denominator
j= 2
n
f n x Li x f xi
i 0
n
x xj
Li x
j 0 xi x j
j i
f3
x x1 x x2 x x3
f x0
x0 x1 x0 x2 x0 x3
x x0 x x2 x x3
f x1 Note:
x1 x0 x1 x2 x1 x3 x3 is
x x0 x x1 x x3
f x2
not being subtracted
x2 x0 x2 x1 x2 x3 from the constant
term x or xi = x3 in
x x0 x x1 x x2
f x3 the numerator
x3 x0 x3 x1 x3 x2 or the denominator
j= 3
Example
1000 Determine the density
999.5 at 17 degrees.
Density
999
998.5
3
998
Temperature, C Density, kg/m
0 5 10 15 20 0 999.9
Tem p
5 1000.0
10 999.7
15 999.1
20 998.2
n
Temperature, C Density, kg/m
3
f n x Li x f xi
0 999.9 i0
5 1000.0
10 999.7
15 999.1
n x xj
Li x
20 998.2
j0 xi x j
ji
999.5
Density
999
998.5
998
0 5 10 15 20
Tem p
....end of problem
f 2 17 119.964 839.244 279.496 998.776
f 2 17 998.776
Using Newton’s
f 1 17 998.74 Interpolating Polynomial
999
998.5
3
998
Temperature, C Density, kg/m
0 5 10 15 20 0 999.9
Tem p
5 1000.0
10 999.7
15 999.1
20 998.2
3
Temperature, C Density, kg/m
0 999.9
5 1000.0
10 999.7
15 999.1
20 998.2
1 10 10 2 a0 999.7
2
1 15 15 a
1 999.1
1 20 20 2 a2 998.2
a0 1000
a
1 0.03
a 0.006
2
17 1000 0.0317 0.00617
2
998.78
Spline Interpolation
• Our previous approach was to derive an nth
order polynomial for n+1 data points.
• An alternative approach is to apply lower-
order polynomials to subset of data points
• Such connecting polynomials are called
spline functions
• Adaptation of drafting techniques
Spline interpolation is an adaptation of the
drafting technique of using a spline to draw smooth curves
through a series of points
Spline interpolation is an adaptation of the
drafting technique of using a spline to draw smooth curves
through a series of points
Spline interpolation is an adaptation of the
drafting technique of using a spline to draw smooth curves
through a series of points
Spline interpolation is an adaptation of the
drafting technique of using a spline to draw smooth curves
through a series of points
Linear Splines
f x f x0 m0 x x0 x0 x x1
f x f x1 m1 x x1 x1 x x2
f x f xn 1 mn 1 x xn 1 xn 1 x x n
where
f xi 1 f xi
mi
xi 1 xi
Quadratic Spline
Example
A well pumping at 250 gallons per minute has observation
wells located at 15, 42, 128, 317 and 433 ft away
along a straight line from the well.
After three hours of pumping, the following drawdowns
in the five wells were observed: 14.6, 10.7, 4.8
1.7 and 0.3 ft respectively. 16
Derive equations of 14
Drawdown
8
6
4
2
0
0 100 200 300 400 500
Distance from we ll
15 14.6
42 10.7
128 4.8
317 1.7
433 0.3
16
14
12
10
Drawdown
8
6
4
2
0
0 100 200 300 400 500
Distance from we ll
15 14.6
42 10.7
128 4.8
317 1.7 a1 x 2 b1 x c1 f x
433 0.3
16
14
12
10
Drawdown
8
6
4
2
0
0 100 200 300 400 500
Distance from we ll
15 14.6
For all values of x between 15 and 42 we
42 10.7 want this equation
128 4.8
317 1.7 a1 x 2 b1 x c1 f x
433 0.3
16
14
12
10
Drawdown
8
6
4
2
0
0 100 200 300 400 500
Distance from we ll
15 14.6
For all values of x between 42 and 128 we
42 10.7 want this equation
128 4.8
317 1.7
433 0.3
16
14
12
10
Drawdown
8
6
4
2
0
0 100 200 300 400 500
Distance from we ll
15 14.6
For all values of x between 42 and 128 we
42 10.7 want this equation
128 4.8
317 1.7 a2 x 2 b2 x c2 f x
433 0.3
16
14
12
10
Drawdown
8
6
4
2
0
0 100 200 300 400 500
Distance from we ll
15 14.6
For all values of x between 128 and 317 we
42 10.7 want this equation
128 4.8
317 1.7
433 0.3
16
14
12
10
Drawdown
8
6
4
2
0
0 100 200 300 400 500
Distance from we ll
15 14.6
For all values of x between 128 and 317 we
42 10.7 want this equation
128 4.8
317 1.7 a3 x 2 b3 x c3 f x
433 0.3
16
14
12
10
Drawdown
8
6
4
2
0
0 100 200 300 400 500
Distance from we ll
15 14.6
For all values of x between 317 and 433 we
42 10.7 want this equation
128 4.8
317 1.7 a4 x 2 b4 x c4 f x
433 0.3
16
14
12
10
Drawdown
8
6
4
2
0
0 100 200 300 400 500
Distance from we ll
12 unknowns…….we need 12 equations
16
14
a1 x 2 b1 x c1 f x
12
Drawdown
10
a2 x 2 b2 x c2 f x
8
6
4
a3 x 2 b3 x c3 f x
2 a4 x 2 b4 x c4 f x
0
0 100 200 300 400 500
Distance from we ll
15 14.6
42 10.7
128 4.8
317 1.7
433 0.3
(42)2 a2 + 42 b2 + c2 = 10.7
16
14
12
10
Drawdown
8
6
4
2
0
0 100 200 300 400 500
Distance from we ll
15 14.6
42 10.7
128 4.8
317 1.7
433 0.3
(42)2 a2 + 42 b2 + c2 = 10.7
16
14
12
16,384 a3 + 128 b3 + c3 = 4.8
10
Drawdown
8
6
4
2
0
0 100 200 300 400 500
Distance from we ll
15 14.6
42 10.7
128 4.8
317 1.7
433 0.3
(42)2 a2 + 42 b2 + c2 = 10.7
16
14
12
16,384 a3 + 128 b3 + c3 = 4.8
10
Drawdown
8
6 100,489a4 + 317b4 + c4 = 1.7
4
2
0
0 100 200 300 400 500
Distance from we ll
15 14.6
42 10.7
128 4.8
317 1.7
433 0.3
(42)2 a2 + 42 b2 + c2 = 10.7
16
14
12
16,384 a3 + 128 b3 + c3 = 4.8
10
Drawdown
8
6 100,489a4 + 317b4 + c4 = 1.7
4
2
0
0 100 200 300 400 500
Distance from we ll
ai 1 x 2 bi 1 x ci 1 f x
Consider this
ai x 2 bi x ci f x
15 14.6 ai 1 x 2 bi 1 x ci 1 f x
42 10.7
128 4.8 ai x 2 bi x ci f x
317 1.7
433 0.3
(42)2 a2 + 42 b2 + c2 = 10.7
16
14
12
16,384 a3 + 128 b3 + c3 = 4.8
10
Drawdown
8
6 100,489a4 + 317b4 + c4 = 1.7
4
2
0
0 100 200 300
Distance from we ll
400 500
(42)2 a1 + 42b1 + c1 = 10.7
(42)2 a2 + 42 b2 + c2 = 10.7
16
14
12
16,384 a3 + 128 b3 + c3 = 4.8
10
Drawdown
8
6 100,489a4 + 317b4 + c4 = 1.7
4
2
0
0 100 200 300
Distance from we ll
400 500
(42)2 a1 + 42b1 + c1 = 10.7
(42)2 a2 + 42 b2 + c2 = 10.7
16
14
12
16,384 a3 + 128 b3 + c3 = 4.8
10
Drawdown
8
6 100,489a4 + 317b4 + c4 = 1.7
4
2
0
0 100 200 300
Distance from we ll
400 500
(42)2 a1 + 42b1 + c1 = 10.7
16
14
12
10
Drawdown
8
6
4
2
0
0 100 200 300 400 500
Distance from we ll
Similarly, the equations 15 14.6
42 10.7
include the end points 128 4.8
317 1.7
433 0.3
a1 x02 b1 x0 c1 f x0
an xn2 bn xn cn f xn
Drawdown
8
6
4
2
0
0 100 200 300 400 500
Distance from we ll
The first derivative at the 15 14.6
42 10.7
interior knots must be equal. 128 4.8
317 1.7
433 0.3
2ai 1 xi 1 bi 1 2ai xi 1 b
16
14
12
10
Drawdown
8
6
4
2
0
0 100 200 300 400 500
Distance from we ll
The first derivative at the 15 14.6
42 10.7
interior knots must be equal. 128 4.8
317 1.7
433 0.3
2ai 1 xi 1 bi 1 2ai xi 1 b
12
Drawdown
8
6
4
....end of problem
Splines
• To ensure that the mth derivatives are continuous
at the “knots”, a spline of at least m+1 order must
be used
• 3rd order polynomials or cubic splines that ensure
continuous first and second derivatives are most
frequently used in practice
• Although third and higher derivatives may be
discontinuous when using cubic splines, they
usually cannot be detected visually and
consequently are ignored.
Splines
• The derivation of cubic splines is somewhat
involved
• First illustrate the concepts of spline interpolation
using second order polynomials.
• These “quadratic splines” have continuous first
derivatives at the “knots”
• Note: This does not ensure equal second
derivatives at the “knots”
Quadratic Spline
1.The function must be equal at the interior
knots. This condition can be represented as:
ai 1xi21 bi 1xi 1 ci 1 f xi 1
ai xi21 bi xi 1 ci f xi 1
ai 1xi2 1 bi 1xi 1 ci 1 f xi 1
ai xi2 1 bi xi 1 ci f xi 1
a1x02 b1x0 c1 f x0
an xn2 bn xn cn f xn
We need 3n
2 ai 1 xi 1 bi 1 2 ai xi 1 b
4. Unless we have some additional information
regarding the functions or their derivatives,
we must make an arbitrary choice in order
to successfully compute the constants.
Note: 6 points
Here we see even more oscillation by fitting
an even higher order polynomial.
Note: 6 points
The oscillation are continue to
amplify as we increase the order
of the polynomial
Note: 8 points
The oscillation are continue to
amplify as we increase the order
of the polynomial
Note: 8 points
Fitting a cubic spline provides
a much more acceptable
approximation
Fitting a cubic spline provides
a much more acceptable
approximation
Fitting a cubic spline provides
a much more acceptable
approximation
Specific Study Objectives
• Understand the fundamental difference between
regression and interpolation
• Understand the derivation of linear least squares
regression and be able to assess the reliability of
the fit using graphical and quantitative
assessments.
Specific Study Objectives
• Know how to linearize data by transformation
• Understand situations where polynomial, multiple
and nonlinear regression are appropriate
• Understand the general matrix formulation of
linear least squares
• Understand that there is one and only one
polynomial of degree n or less that passes exactly
through n+1 points
Specific Study Objectives
• Become familiar with the use of Newton’s and
Lagrange formulas for interpolating polynomials
• Recognize that the Newton and Lagrange
equations are merely different formulations of the
same interpolating polynomial
• Realize that more accurate results are obtained if
data used for interpolation is centered around and
close to the unknown point
Specific Study Objectives
• Recognize the liabilities and risks associated with
extrapolation
• Understand why spline functions have utility for
data with local areas of abrupt change
Example
(Previous Exam Question)
x f(x) 7.00
6.00
1 0.50 5.00
4.00
f(x)
4 4.60
3.00
2.00
1.00
6 1.50 0.00
0 2 4 6 8
7 3.00 x
(4, 4.6)
7.00
Interior knots:
6.00
5.00 16a1 + 4b1 + c1 = 4.6
4.00
16a2 + 4b2 + c2 = 4.6
f(x)
3.00
2.00
1.00
0.00 36a2 + 6b2 + c2 = 1.5
0 2 4 6 8
x 36a3 + 6b3 + c3 = 1.5
End conditions
x f(x) a1 + b1 + c1 = 0.5
1 0.50 49a3 + 7b3 + c3 = 3.0
Extra equation
a1 =0
Interior knots: End conditions
16a1 + 4b1 + c1 = 4.6 16a2 + 4b2 + c2 = 4.6 a1 + b1 + c1 = 0.5 49a3 + 7b3 + c3 = 3.0
36a2 + 6b2 + c2 = 1.5 36a3 + 6b3 + c3 = 1.5 First derivative cont. at interior knots
8a1 + b1 = 8a2 + b2 12a2 + b2 = 12a3 + b3
Extra equation
a1 =0
b1 c1 a2 b2 c2 a3 b3 c3
4 1 0 0 0 0 0 b1 4.6
0
0 0 16 4 1 0 0 0 c1 4.6
0 0 36 6 1 0 0 0 a2 15 .
0 0 0 0 0 36 6 1 b2 15.
1 1 0 0 0 0 0 0 c2 0.5
0 0 0 0 0 49 7 1 a3 3.0
1 0 8 1 0 0 0 0 b3 0
0 0 12 1 0 12 1 0 c3 0
…end of lecture