Sei sulla pagina 1di 134

Linear Regression

Polinomial Regression
Multiple Linear Regression

Interpolasi Polinomial Newton


Interpolasi Polinomial Lagrange
Interpolasi Polinomial Spline (linear, quadratic, & cubic spline)

Aproksimasi Fungsi Polinomial


Aproksimasi Fungsi Fourier
Aproksimasi Fungsi Eksponensial

Diktat Kuliah

Pada bidang eksplorasi dengan menggunakan


metode gravity

Tidal Correction at Sago-Lirik Area


th

(Dec 8 , 2006)
0.12

Tide (mGal)

0.08

0.04
Tim e
0
6:00

8:24

10:48

13:12

15:36

-0.04

-0.08

Tidal correction at the Base


on the 8th Dec 2006

18:00

Specific Growth Rate, m

Need to determine parameters for


saturation-growth rate model to
characterize microbial kinetics

Food Available, S

m m max

S
Ks S

T ( o C)
0

10

20

30

z (m )

10

Epilimnion
Thermocline

15

20

25

30

Hypolimnion

Thermocline : Depth at which the rate of decrease of temperature with increase


of depth is the largest.
In general the sea water temperature decreases from the surface to the deepest levels, except in
high latitudes where the configuration can be more complex. There exists in most ocean areas
(apart from polar and sub-polar oceans) a zone where the rate of decrease of temperature is
much larger compared with that above and below, hence the definition. Depending on the
geographical location, the thermocline depth ranges from about 50m to 1000m.
A simplified view is to consider the thermocline as the separation zone between the mixed-layer
above, much influenced by atmospheric fluxes, and the deep ocean. In the tropics, the
thermocline can be quite shallow on average, as in the eastern Pacific (50m), or deeper as in the
western part (160-200m). In extra-tropical regions a permanent (or main) thermocline is found
between 200m and 1000m. However the thermocline depth varies seasonally, especially in the
mid-latitude regions where a secondary and much shallower thermocline (above 50m) occurs in
summer. In high latitudes, a thermocline may appear only seasonally.
Thermocline can also vary from one year to the next, as in the tropical Pacific where
thermocline vertical displacements play a fundamental role during ENSO. As the pycnocline, the
thermocline is a prominent feature of the ocean which conditions many physical, chemical and
biological processes occurring in the oceanic upper layers. In many situations, the thermocline
can be identified with the pycnocline when the vertical contrasts of salinity are small.

Who cares? physical oceanographers, marine biologists, climatologists, therefore any


specialist dealing with the upper ocean will need to consider the thermocline. In a practical way,
this oceanic feature is very familiar for instance to fishermen and submarine crews.

Interpolation of data
What is kinematic
viscosity at 7.5 C?

v, 10-2 cm 2/s

2
1.5
1
0.5
0
0

10

20
T(oC)

30

T (oC)
0
4
8
12
16
20
24

v, 10-2 (cm2/s)
1.7923
1.5615
1.3874
1.2396
1.1168
1.0105
0.9186

f(x)

Can you suggest another?

x
We want to find the best fit of a curve through the data.
Here we see :
a) Least squares fit
b) Linear interpolation

Material to be Covered in Curve Fitting


Linear Regression

Polynomial Regression

Multiple Regression

General linear least squares

Nonlinear regression

Interpolation

Newtons Divided Difference

Lagrange polynomial

Coefficients of polynomials (Collocation-Polynomial Fit)

Splines

Aproximation

Specific Study Objectives


Understand
regression

the

fundamental

and

interpolation

difference
and

between

realize

why

confusing the two could lead to serious problems

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


Realize that more accurate results are obtained if
data used for interpolation is centered around and
close to the unknown point

Recognize the liabilities and risks associated with


extrapolation

Understand why spline functions have utility for data


with local areas of abrupt change

Linear Regression

Polynomial Regression

???

Linear

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

Sum of the Residual Error, Sr


n

i 1

i 1

Sr e2i yi a o a1xi

f(x)

yi a o a1xi

x
Data Observasi : (x1,y1), (x2, y2).....(xn, yn)
Persamaan Regresi Linear : y = ao + a1x + e

Determining the Coefficients


To determine the values for ao and a1, differentiate
with respect to each coefficient

Sr
2 yi ao a1xi
a o
Sr
2 yi ao a1xi xi
a1

i 1

i 1

Sr e2i yi a o a1xi

Note: we have simplified the summation symbols.

What mathematics technique will minimize Sr?

Determining the Coefficients


Sr
2 yi ao a1xi
a o
Sr
2 yi ao a1xi xi
a1
Setting the derivative equal to zero will minimizing Sr.
If this is done, the equations can be expressed as:

0 yi ao a1xi

0 yi xi ao xi a1xi2

Determining the Coefficients


0 yi ao a1xi

0 yi xi ao xi a1xi2
Note:

nao

We have two simultaneous equations, with two unknowns,


ao and a1.
What are these equations? (hint: only place terms with ao
and a1 on the LHS of the equations)

What are the final equations for ao and a1?

Determining the Coefficients


y a a x
0 y x a x a x
0

i i

1 i

o i

2
1 i

nao xi a1 yi

These first two


equations are called

xa x a x y
i

a1

2
i 1

i i

n xi yi xi y i
n x xi

ao y a1x

2
i

the normal equations

nao xi a1 yi
xi ao

xi2 a1 xi yi

xi n ao xi xi a1
xi

xi yi

n ao n xi2 a1

a1


xi

n xi yi

n xi2

xi yi n xi yi

a1
a1

a0

yi

xi yi n xi yi
2
xi
n xi2

n xi yi xi yi
n xi2

x
i

xi a1
y a1 x
n

a1

n xi yi xi y i
2

n xi

ao y a1 x

x
i

Persamaan Regresi Linear :

y = ao + a1x

Error
Recall:

f(x)

i 1

i 1

Sr e2i yi a o a1xi

The most common measure of the spread of a sample is

the standard deviation about the mean:

S t yi y

St
sy
n 1

Error
Introduce a term to measure the standard error of the

estimate:

Sr
sy
n2
x
Coefficient of determination r2 :

St Sr
r
St
2

r is the correlation coefficient

Error

St Sr
r
St
2

The following signifies that the line explains 100 percent


of the variability of the data:
Sr = 0
r = r2 = 1
If r = r2 = 0, then Sr = St and the fit is invalid.

Error

S t yi y

St
sy
n 1

standard deviation
about the mean

i 1

i 1

Sr e2i yi a o a1xi

Sr
sy
n2
x

St Sr
r
St

standard error of the


estimate

Coefficient of
determination

Example
Determine the linear equation and R2 value for
the following data

y
9
7
5
4
3
1
0

8
7
f(x)

x
0
1
2
3
4
5
6

10
9

6
5
4
3
2
1
0
0

4
x

Consider the following four sets of data

Data 1
10
8.04
8
6.95
13
7.58
9
8.81
11
8.33
14
9.96
6
7.24
4
4.26
12
10.84
7
4.82
5
5.68

Data 2
10
9.14
8
8.14
13
8.74
9
8.77
11
9.26
14
8.10
6
6.13
4
3.10
12
9.13
7
7.26
5
4.74

Data 3
10
7.46
8
6.77
13
12.74
9
7.11
11
7.81
14
8.84
6
6.08
4
5.39
12
8.15
7
6.42
5
5.73

Data 4
8
6.58
8
5.76
8
7.71
8
8.84
8
8.47
8
7.04
8
5.25
19
12.50
8
5.56
8
7.91
8
6.89

12

12

10

10

8
y

14

14

y = 0.5001x + 3.0001
R2 = 0.6665

y = 0.5x + 3.0009

R2 = 0.6662

0
0

10

15

10

15

14

14

12

12

10

10

8
y

y = 0.4997x + 3.0025
2

y = 0.4999x + 3.0017
R2 = 0.6667

R = 0.6663

0
0

10
x

15

10
x

15

20

Linearization of non-linear relationships

Some data is simply ill-

f(x)

suited for linear least


squares regression....
or so it appears.

EXPONENTIAL
EQUATIONS

Linearize

P Po e
t
ln P

intercept = ln P0
slope = r
t

why?

rt

P P0e rt

ln P ln P0e rt

ln P0 lne rt

Can you see the similarity


with the equation for a line :

y = ao + a1x

ln P0 rt
lnP

intercept = ln Po

slope = r

After taking the natural log

P P0e rt

of the y-data, perform linear

ln P ln P0e rt

ln P0 lne
ln P0 rt
ln P

regression.
rt

From this regression:


The value of ao will give us
ln (P0). Hence, P0 = eao

The value of a1 will give us r


directly.

intercept = ln P0

slope = r
t

POWER EQUATIONS

Q cH

(Flow over a weir)


H
log Q

Here we linearize
the equation by
taking the log of

H and Q data.
What is the resulting
intercept and slope?
log H

Q cH a

So how do we get
c and a from
performing regression
on the log H vs log Q
data?
From : y = ao + a1x

log Q logcH a
log c log H

log c a log H

ao = log c
c = 10ao

log Q

a1 = a

slope = a

log H

intercept = log c

SATURATION-GROWTH
RATE EQUATION

m m max
S

1/m

slope = Ks/mmax
intercept = 1/mmax
1/ S

S
Ks S

Here, m is the growth


rate of a microbial
population,
mmax is the maximum
growth rate, S is the
substrate or food
concentration, Ks is the
substrate concentration
at a value of m = mmax/2

Residual Error
Linear :

y = ao + a1x

2
2

Sr e yi ymodel yi ao a1 xi
2

Power :

y = axb

2
b 2

Sr e yi ymodel yi ax
2

Exponential :

y=aexb

Sr e yi ymodel yi ae
2

xi b 2

Example
X

Ymodel

0.7

0.8

1.7

1.6

3.3

3.1

7.3

6.2

10.9

12.1

22.7

23.9

y = 0.407e

0.679x

Given the following results, determine Sr.

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


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

y-direction

f(x)

x-direction

Latihan

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

Polynomial Regression

Sr yi a o a1xi a x ...... a x
2
2 i

m 2
m i

1. Take the derivative of the above equation with


respect to each of the unknown coefficients: i.e.
the partial with respect to a2

Sr
2
2 xi yi ao a1xi a2 xi2 ..... amxim
a2

Polynomial Regression
2. These equations are set to zero to minimize Sr, i.e.
minimize the error.

3. Set all unknowns values on the LHS of the equation.

ao xi a1 xi3 a2 xi4 ..... am xi


2

m 2

xi yi
2

Polynomial Regression

4. This set of normal equations result in m+1


simultaneous equations which can be solved using

matrix methods to determine a0, a1, a2......am

Polynomial Regression (orde-2) :


y = a0 + a1 x + a2 x2

n a o x i a1 x i2 a 2 yi

x a x a x a x y
x a x a x a x y
i

2
i

xi

xi2

2
i

3
i

xi

2
xi

2
xi

3
xi

3
xi

4
xi

3
i

4
i

ao

a1
a
2

2
i

yi

xi yi
2
xi yi

Multiple Linear Regression


A useful extension of linear regression is the case
where y is a linear function of two or more variables

y = ao + a1x1 + a2x2

We follow the same procedure

y = ao + a1x1 + a2x2 + e

Multiple Linear Regression


For two variables, we would solve a 3 x 3 matrix
in the following form:

x1i
x2i

x
x
x x

1i
2
1i

1i 2 i

x
x x
x

a0 yi


1i 2 i a1 x1i yi
2
x y
2 i a 2

2i i
2i

[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

Newtons Divided Difference Interpolating


Polynomials

Lagrange Interpolating Polynomial

Newtons Divided Difference


Interpolating Polynomials
Linear Interpolation
Quadratic Interpolation
General Form
Errors

Newtons Linear Interpolation

Temperature, C

Density, kg/m3

999.9

1000.0

10

999.7

15

999.1

20

998.2

How would you approach estimating the density at 17 C?

998.2

999.1

15

17

998.2 999.1 999.1

20 15
17 15 T

20

Solve for

Therefore, the slope of one interval will equal the

slope of the other interval.

998.2 999 .1 998.2

20 15
20 17
f x1 f x0
f1 x f xo
x x0
x1 x0

Alternate interpretation

f1 x a0 a1 x x0
the intercept is f(x0)

Newtons
Linear
Interpolation

the slope is a finite difference


approx. of dy/dx

true solution
f(x)

Alternative approach would be to


include a third point and estimate f(x)
from a 2nd order polynomial.
x

Newtons Linear Interpolation

f1 x a0 a1 x x0

We use Eq. (18.2) and a


linear interpolation for
ln(2) from x0 = 1 to x1 = 6
to give

We use Eq. (18.2) and a


linear interpolation for
ln(2) from x0 = 1 to x1 = 4
to give

Newtons Quadratic Interpolation

f 2 x b0 b1 x x0 b2 x x0 x x1
Prove that this a 2nd order polynomial of
the form:

f x a0 a1x a2 x

First, multiply the terms

f 2 x b0 b1 x x0 b2 x x0 x x1
f 2 x b0 b1x b1x0 b2 x 2 b2 x0 x1 b2 xx0 b2 xx1
Collect terms and recognize that:

a0 b0 b1 x0 b2 x0 x1
a1 b1 b2 x0 b2 x1
a2 b2

f x a0 a1x a2 x 2

x2, f(x2)

x, f(x)

Procedure for

f(x)

Quadratic

x1, f(x1)

Interpolation

x0, f(x0)

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

Include 10 degrees in
your calculation of the
density at 17 degrees.

1000.5

Temperature, C

Density, kg/m3

999.5

999.9

999

1000.0

998.5

10

999.7

998

15

999.1

20

998.2

Density

1000

10

15
Temp

20

25

Example
Include 10 degrees in
your calculation of the
density at 17 degrees

f 2 x b0 b1 x x0 b2 x x0 x x1

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

Temperature, C

Density, kg/m

999.9

1000.0

10

999.7

15

999.1

20

998.2

Solution
b0 f x0 999.7

f x1 f x0 999.1 999.7
b1

0.12
x1 x0
15 10
f x2 f x1 f x1 f x0

x2 x1
x1 x0
b2
x2 x0

998.2 999.1
0.12
20 15

0.006
20 10

Solution

f 2 17 b0 b1 x x0 b2 x x0 x x1

b0 b1 17 10 b2 17 1017 15

f 2 17 998.776
f1 17 998.74

f3 x b0 b1 x x0 b2 x x0 x x1

b3 x x0 x x1 x x2

b0 f x0
b1

f x1 f x0
x1 x0

f x2 f x1
b2

b1

x2 x1

f x1 f x0

x2 x0

x1 x0

b2

f x3 f x2 f x2 f x1
f x2 f x1 f x1 f x0

x
x

x
x

x
x

x
3
2
2
1
2
1
1
0

x3 x1
x2 x0

b3
x3 x0

f 4 x b0 b1 x x0 b2 x x0 x x1

b3 x x0 x x1 x x2

b4 x x0 x x1 x x2 x x3
b0 f x0 f x0
f x1 f x0
b1 f x1 , x0
x1 x0

b1

f x2 f x1 f x1 f x0

x
x1 x0
f x2 , x1 f x1 , x0
2
1

b2 f x2 , x1 , x0

x2 x0
x2 x0
b3 f x3 , x2 , x1 , x0

f x3 , x2 , x1 f x2 , x1 , x0
x3 x0

f x3 , x2 f x2 , x1 f x2 , x1 f x1 , x0

x3 x1
x2 x0

x3 x0

b2

f x3 f x2 f x2 f x1 f x2 f x1 f x1 f x0

x
x

x
x

x
x1 x0
3
2
2
1
2
1

x3 x1
x2 x0

x3 x0

b4 f x4 , x3 , x2 , x1 , x0

f x4 , x3 , x2 , x1 f x3 , x2 , x1 , x0
x4 x0

f x4 , x3 , x2 f x3 , x2 , x1 f x3 , x2 , x1 f x2 , x1 , x0

x4 x1
x3 x0

x4 x0
f x4 , x3 f x3 , x2 f x3 , x2 f x2 , x1 f x3 , x2 f x2 , x1 f x2 , x1 f x1 , x0

x4 x2
x3 x1
x3 x1
x2 x0

x4 x1
x3 x0

x4 x0

b3

f x4 f x3 f x3 f x2 f x x , x
f x f x2 f x2 f x1 f x2 f x1 f x1 f x0
3
3 2 f x , x 3

2 1

x
x

x
x3 x2
x2 x1
x2 x1
x1 x0
4
3
3
2

x4 x2
x3 x1
x3 x1
x2 x0

x4 x1
x3 x0

x4 x0

Lagrange Interpolating Polynomial

f n x Li x f xi
i0

Li x
j0
ji

x xj
xi x j

where P designates the product of


The linear version of this expression is at n=1

Linear version: n=1


n

f n x Li x f xi
i 0

Li x
j 0
j i

x xj
xi x j

x x1
x x0
f1
f x0
f x1
x0 x1
x1 x0

Linear
Lagrange
Interpolating
Polynomial

Your text shows you how to do n=2 (second order).

What would third order be?

2nd-order Lagrange Interpolating Polynomial

fn x

n
Li
i 0

x f xi

Li x

n x xj

j 0 xi x j
j i

f1

x x0
x x1
f x0
f x1
x0 x1
x1 x0

x x0 x x2
x x0 x x1
x x1 x x2
f2
f x0
f x1
f x2
x0 x1 x0 x2
x1 x0 x1 x2
x2 x0 x2 x1

x x0
x x1
f1
f x0
f x1
x0 x1
x1 x0
x x0 x x2
x x0 x x1
x x1 x x2
f2
f x0
f x1
f x2
x0 x1 x0 x2
x1 x0 x1 x2
x2 x0 x2 x1

f n x Li x f xi
i 0
n

Li x
j 0
j i

x xj
xi x j

x x1 x x2 x x3
f3
f x0
x0 x1 x0 x2 x0 x3
.......

f n x Li x f xi
i 0
n

Li x
j 0
j i

x xj
xi x j

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
.......

f n x Li x f xi
i 0
n

Li x
j 0
j i

x xj
xi x j

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
.......

Note:
x1 is not being
subtracted from the
constant term x or
xi = x1 in the
numerator or the
denominator j= 1

f n x Li x f xi
i 0
n

Li x
j 0
j i

x xj
xi x j

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
x x0 x x1 x x3

f x2
x2 x0 x2 x1 x2 x3
......

Note:
x2 is not being
subtracted from
the constant term
x or xi = x2 in the
numerator or the
denominator j= 2

f n x Li x f xi
i 0
n

Li x
j 0
j i

x xj
xi x j

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
x x0 x x1 x x3

f x2
x2 x0 x2 x1 x2 x3
x x0 x x1 x x2

f x3
x3 x0 x3 x1 x3 x2

Note:
x3 is not being
subtracted from
the constant term
x or xi = x3 in the

numerator or the
denominator j= 3

Example

Determine the density


at 17 degrees.

1000.5

Density

1000

Temperature, C

Density, kg/m3

999

999.9

998.5

1000.0

10

999.7

15

999.1

20

998.2

999.5

998
0

10

15
Temp

20

25

Coefficients of an Interpolating
Polynomial

f n x b0 b1 x x0 ....bn x x0 x x1 x xn 1

y = a0 + a1x + a2x2 +....amxm


HOW CAN WE BE MORE STRAIGHT
FORWARD IN GETTING VALUES ?

f x0 a 0 a1x0 a 2 x02
f x1 a 0 a1x1 a 2 x12
f x2 a 0 a1x2 a 2 x32
This is a 2nd order polynomial.
We need three data points.
Plug the value of xi and f(xi)
directly into equations.
This gives three simultaneous equations

to solve for a0 , a1 , and a2

Example

Determine the density


at 17 degrees.

1000.5

Density

1000

Temperature, C

Density, kg/m3

999

999.9

998.5

1000.0

10

999.7

15

999.1

20

998.2

999.5

998
0

10

20
Temp

30

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
technique of using a spline to draw smooth curves
through a series of points

drafting

Spline interpolation is an adaptation


of the
technique of using a spline to draw smooth curves
through a series of points

drafting

Spline interpolation is an adaptation


of the
technique of using a spline to draw smooth curves
through a series of points

drafting

Spline interpolation is an adaptation


of the
technique of using a spline to draw smooth curves
through a series of points

drafting

Linear Splines

f x f x0 m0 x x0
f x f x1 m1 x x1

x0 x x1
x1 x x2

f x f xn 1 mn 1 x xn 1
where
f xi 1 f xi
mi
xi 1 xi

xn 1 x x n

Quadratic Spline

a1 x 2 b1 x c1

Quadratic Spline

a2 x 2 b2 x c2

Quadratic Spline

a3 x 2 b3 x c3

Quadratic Spline

a4 x 2 b4 x c4

Quadratic Spline

a1 x 2 b1 x c1
a2 x 2 b2 x c2
a4 x 2 b4 x c4

a3 x 2 b3 x c3

16

Draw dow n (ft)

14
12
10
8
6
4
2
0
0

100

200

300

Distanc e from w ell (ft)

400

500

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.

Turunkan persamaan quadratic spline utk problem tersebut !

15
42
128
317
433

ai 1xi2 1 bi 1xi 1 ci 1 f xi 1

14.6
10.7
4.8
1.7
0.3

ai xi2 1 bi xi 1 ci f xi 1

16

Draw dow n (ft)

14
12
10
8
6
4
2
0
0

100

200

300

Distanc e from w ell (ft)

400

500

ai 1xi2 1 bi 1xi 1 ci 1 f xi 1

Solution

ai xi2 1 bi xi 1 ci f xi 1

(42)2 a2 + 42 b2 + c2 = 10.7
16

Draw dow n (ft)

14
12
10
8
6
4
2
0
0

100

200

300

Distanc e from w ell (ft)

400

500

15
42
128
317
433

14.6
10.7
4.8
1.7
0.3

ai 1xi2 1 bi 1xi 1 ci 1 f xi 1

Solution

ai xi2 1 bi xi 1 ci f xi 1

(42)2 a2 + 42 b2 + c2 = 10.7

16,384 a3 + 128 b3 + c3 = 4.8

16

Draw dow n (ft)

14
12
10
8
6
4
2
0
0

100

200

300

Distanc e from w ell (ft)

400

500

15
42
128
317
433

14.6
10.7
4.8
1.7
0.3

ai 1xi2 1 bi 1xi 1 ci 1 f xi 1

Solution

ai xi2 1 bi xi 1 ci f xi 1
(42)2 a2 + 42 b2 + c2 = 10.7
16,384 a3 + 128 b3 + c3 = 4.8

16

Draw dow n (ft)

14
12
10

100,489a4 + 317b4 + c4 = 1.7

8
6
4
2
0
0

100

200

300

Distanc e from w ell (ft)

400

500

15
42
128
317
433

14.6
10.7
4.8
1.7
0.3

ai 1xi2 1 bi 1xi 1 ci 1 f xi 1

Solution

ai xi2 1 bi xi 1 ci f xi 1

(42)2 a2 + 42 b2 + c2 = 10.7
16,384 a3 + 128 b3 + c3 = 4.8

16

Draw dow n (ft)

14
12

100,489a4 + 317b4 + c4 = 1.7

10
8
6

(42)2 a1 + 42b1 + c1 = 10.7

4
2
0
0

100

200

300

400

500

Distanc e from w ell (ft)

Note: This point is in the first and second


polynomial

15
42
128
317
433

14.6
10.7
4.8
1.7
0.3

15
42
128
317
433

Solution

(42)2 a2 + 42 b2 + c2 = 10.7
16

16,384 a3 + 128 b3 + c3 = 4.8

Draw dow n (ft)

14
12

100,489a4 + 317b4 + c4 = 1.7

10
8
6

(42)2 a1 + 42b1 + c1 = 10.7

4
2
0
0

100

200

300

Distanc e from w ell (ft)

400

500

16,384a2 + 128b2 + c2 = 4.8

14.6
10.7
4.8
1.7
0.3

15
42
128
317
433

Solution

(42)2 a2 + 42 b2 + c2 = 10.7

16
14

Draw dow n (ft)

14.6
10.7
4.8
1.7
0.3

16,384 a3 + 128 b3 + c3 = 4.8

12
10

100,489a4 + 317b4 + c4 = 1.7

8
6
4

(42)2 a1 + 42b1 + c1 = 10.7

2
0
0

100

200

300

400

500

16,384a2 + 128b2 + c2 = 4.8

Distanc e from w ell (ft)

100,489a3 + 317b3 + c3 = 1.7

Solution

15
42
128
317
433

(15)2a1 + 15 b1 + c1 = 14.6

14.6
10.7
4.8
1.7
0.3

187,489a4 + 433b4 + c4 = 0.3

16

Similarly, the equations


include the end points

Draw dow n (ft)

14
12
10
8
6
4
2
0
0

100

200

300

Distanc e from w ell (ft)

400

500

15
42
128
317
433

Solution
2ai 1xi 1 bi 1 2ai xi 1 b

14.6
10.7
4.8
1.7
0.3

The first derivative at the interior


16

knots must be equal.

2a2 (128) + b2 = 2a3 (128) + b3


2a3 (317) + b3 = 2a4 (317) + b4

Draw dow n (ft)

2a1 (42) + b1 = 2a2 (42) + b2

14
12
10
8
6
4
2
0
0

100

200

300

Distanc e from w ell (ft)

400

500

15
42
128
317
433

Solution

Addition the last condition a1 = 0

You should be able to set these equations into a


matrix to solve for ai , bi, and ci for i = 1,3

....end of problem

14.6
10.7
4.8
1.7
0.3

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.

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

note: we are referencing the same x and f(x)

ai xi21 bi xi 1 ci f xi 1

Quadratic Spline
ai 1xi2 1 bi 1xi 1 ci 1 f xi 1
ai xi2 1 bi xi 1 ci f xi 1
This occurs between i = 2, n
Using the interior knots (n-1) this will provide 2n -2 equations.

Quadratic Spline
2. The first and last functions must pass

through

the end points.


This will add two more equations.

a1x02 b1x0 c1 f x0
an xn2 bn xn cn f xn
We now have 2n - 2 +2 = 2n equations.

How many do we need?

Quadratic Spline
3. The first derivative at the interior knots must
be equal.

This provides another n-1 equations for


2n + n-1 =3n -1.
We need 3n

2ai 1xi 1 bi 1 2ai xi 1 b

Quadratic Spline
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.
5. Assume the second derivative is zero at the
first point. The visual interpretation of this
condition is that the first two points will be
connected by a straight line.

a1 = 0

Cubic Splines
Third order polynomial
Need n+1 = 3+1 = 4 intervals

Consequently there are 4n unknown


constants to evaluate

What are these equations?

f i x ai x 3 bi x 2 ci x di

Cubic Splines
The function values must be equal at the
interior knots (2n -2)

The first and last functions must pass


through the end points (2)

The first derivatives at the interior knots


must be equal (n-1)

The second derivatives at the interior


knots must be equal (n-1)

The second derivative at the end knots are


zero (2)

SPECIAL NOTE

On the surface it may appear that a third order


approximation using splines would be inferior to higher
order polynomials.
Consider a situation where a spline may perform better:
A generally smooth function undergoes an abrupt change
in a region of interest.

The abrupt change


induces oscillations
in interpolating
polynomials.

In contrast, the cubic


spline provides a much
more acceptable
approximation

Quadratic Spline

Potrebbero piacerti anche