Numerical Methods Module 5
Numerical Methods Module 5
Regression:
Ob
Obtain a straight
h line
l
that best fits the data
Interpolation Example
Given the following data:
x 0.8 1.4 2.7 3.8 4.8 4.9
y 0.69 1.00 2.02 2.39 2.34 2.83
Interpolation:
“J
“Join the
h dots”
d ” and
d
find a curve passing
through the data.
Regression vs. Interpolation
x 0.8 1.4 2.7 3.8 4.8 4.9
y 0.69 1.00 2.02 2.39 2.34 2.83
In regression,
regression we are interested in fitting a
chosen function to data
y = 0.45
0 45 + 0.47x
0 47x
In interpolation,
p , ggiven finite amount of data,, we
are interested in obtaining new data-points
within this range.
At x = 2.0, y = 1.87
Example: Kinetic Rate Constants
(Regression)
R i )
Experiments with conversion measured at
various temperatures
6
E
r k0e ( RT )
ca 4
log(rr)
0 Slope = E/R
E 1
ln(r ) ln(k0 ) ln(ca )
-2
R T -4
Intercept = ln(k0)
-3.5 -3 -2.5 -2 -1.5
-1/T -3
x 10
Example: Viscosity of Oil
(Interpolation)
I l i )
Viscosity of lubricant oil was measured between
-20 to 200 degrees Celcius in steps of 20 oC.
Interpolation is used if viscosity is desired at an
intermediate temperature
General Setup
Let x be an independent variable
and y be a dependent variable
Polynomial Regression
A l i and
Analysis d EExtension
i
Non-Linear Regression
g
Linear Regression: One Variable
Model: y f x;
Errors: ei yi yˆi
yi f xi ; ei
yˆ i
Mean / Variance:
i
2
x xi sx
x x
( N 1) sx
N
Extension to Multi
Multi--Variables
Let x1, x2, …, xn be n variables.
Let there be N data points for each:
x11, x21,, xn1; y1 ,
x12 , x22 ,, xn 2 ; y2 ,
x1N , x2 N ,, xnN ; y N
Obtain θ for
y f x; θ
Linear Regression (multi
(multi--variable)
Data xi , ui , wi ; yi
Model y a0 a1x a2u a3w
Least Squares
X X T
1 T
X Y
Polynomial / Functional Regression
Example:
p Specific
p heat as a function of T
◦ Methane: cp = 85.8 + 1.126e-2 T – 2.1141e-6 T2
1 ln x1 1
x1 x1
1 ln x2 1 x2
M d l
Model: X x2
a2
y a0 a1 ln( x) a3 x
x 1 ln x N 1
xN xN
Outline: Interpolation
Polynomial fitting and limitations
Newton’s methods
S li interpolation
Spline i l i
Lagrange Polynomials
Pi
x x1 x x2 ... x xi 1 x xi 1 ... x x N
xi x1 xi x2 ...xi xi 1 xi xi 1 ...xi xN
x xj
j i xi x j
The interpolating
polynomial becomes
f ( x) y1P1 y2 P2 ... y N PN
Newton’s
Newton s Divided Differences
yi 11 yi
yi 1, i
xi 1 xi
y[i 2, i 1] y[i 1, i ]
yi 2, i 1, i
xi 2 xi
y[i 3, i 2, i 1] y[i 2, i 1, i ]
yi 3, i 2, i 1, i
xi 3 xi
f ( x) c0 c1 ( x x1 ) c2 ( x x1 )( x x2 ) ...