Professional Documents
Culture Documents
CURVE FITTING
Application
2
Interpolation of data
1.5 What is kinematic
v, 10-2 cm 2/s
1 viscosity at 7.5º C?
o -2 2
0.5 T ( C) v, 10 (cm /s)
0 1.7923
0 4 1.5615
0 10 20 30
8 1.3874
T(oC)
12 1.2396
16 1.1168
20 1.0105
24 0.9186
f(x)
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
ao
Sr
2 yi ao a1xi xi
a1
Note: a o nao
the normal
equations
n xi yi xi y i
a1
n x xi
2 2
i
ao y a1x
Example
Fit a straight line to the x and y values in the
following Table.
Example
Error
Recall:
n n 2
f(x)
Sr e i yi a o a1xi
2
i 1 i 1
St
St
The following signifies that the line explains 100
percent of the variability of the data:
Sr = 0
r = r2 = 1
12 12
10 10
8 8
y
y
6 6
4 4
y = 0.5001x + 3.0001 y = 0.5x + 3.0009
2 2 2 2
R = 0.6665 R = 0.6662
0 0
0 5 10 15 0 5 10 15
x x
14
14
12
12
10
10
8 8
y
6 6
4 4
y = 0.4997x + 3.0025 y = 0.4999x + 3.0017
2 2 2 2
R = 0.6663 R = 0.6667
0 0
0 5 10 15 0 5 10 15 20
x x
Linearization of non-linear
relationships
or so it appears. x
P
EXPONENTIAL
EQUATIONS
P Po e rt
Linearize
t
ln P
intercept = ln P0
slope = r
why?
t
P P0e rt Can you see the similarity
ln P ln P0e rt with the equation for a line:
ln P0 ln e rt
y = b + mx
ln P0 rt
intercept = ln Po slope = r
t
After taking the natural log
P P0e rt of the y-data, perform linear
ln P ln P0e rt regression.
ln P0 ln e rt
From this regression:
The value of b will give us
ln P0 rt
ln (P0). Hence, P0 = eb
ln P0
The value of m will give us r
directly.
intercept = ln P0 slope = r
t
Q
POWER EQUATIONS
Q cH a
H
log Q Here we linearize
the equation by
taking the log of
H and Q data.
What is the resulting
log H intercept and slope?
Q cH a
log Q log cH 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 log cH a
c and a from
log c log H a performing regression
on the log H vs log Q
log c a log H
data?
From : y = mx + b
log Q
b = log c
slope = a c = 10b
log H m=a
intercept = log c
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 = a0 + a1x
• 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
a2
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
• Linear Interpolation
• Quadratic Interpolation
Linear Interpolation
3
Temperature, C Density, kg/m
0 999.9
5 1000.0
10 999.7
15 999.1
20 998.2
15 20
999.1
998.2
15 20
999.1
998.2
17
15 20
999.1
998.2
17
15 20
f x1 f x0
f1 x f xo x x0
x1 x0
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
Lagrange Interpolating
Polynomial
n
f n x Li x f xi
i0
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
i 0
n x xj Note:
Li x x1 is
j0 xi x j
j i
not being
x x1 x x2 x x3 subtracted
f3 f x0
x0 x1 x0 x2 x0 x3 from the
x x0 x x2 x x3 constant
f x1
x1 x0 x1 x2 x1 x3 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 Note:
Li x
j0 xi x j x2 is
j i
x x1 x x2 x x3 not being
f3 f x0 subtracted
x0 x1 x0 x2 x0 x3
from the
x x0 x x2 x x3
f x1 constant
x1 x0 x1 x2 x1 x3 term x or
x x0 x x1 x x3 xi = x2 in
f x2
x2 x0 x2 x1 x2 x3 the numerator
...... or the
denominator
j= 2
n
f n x Li x f xi
i 0
n
x xj Note:
Li x
j 0 xi x j x3 is
j i
not being
f3
x x1 x x2 x x3
f x0 subtracted
x0 x1 x0 x2 x0 x3
from the
x x0 x x2 x x3
f x1 constant
x1 x0 x1 x2 x1 x3 term x or
x x0 x x1 x x3
f x2 xi = x3 in
x2 x0 x2 x1 x2 x3 the numerator
x x0 x x1 x x2
f x3 or the
x3 x0 x3 x1 x3 x2 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
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
Coefficients of an Interpolating
Polynomial
f n x b0 b1 x x0 ....bn x x0 x x1 x x n 1