0% found this document useful (0 votes)
223 views

Approximation of Functions (: Numerical Interpolation & Regression)

The document provides an overview of approximation of functions through numerical interpolation and regression. It discusses two general approaches - least-squares regression which fits a curve to follow the general trend of data points when data has some error, and interpolation which fits curves passing through each data point for precise data. It then describes various regression based methods like linear and multiple linear regression to fit curves in the form of polynomials or other functions like exponential and power equations to a given data set. The coefficients of these functions are determined by minimizing the sum of squared errors using the least squares method.

Uploaded by

Rahul Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
223 views

Approximation of Functions (: Numerical Interpolation & Regression)

The document provides an overview of approximation of functions through numerical interpolation and regression. It discusses two general approaches - least-squares regression which fits a curve to follow the general trend of data points when data has some error, and interpolation which fits curves passing through each data point for precise data. It then describes various regression based methods like linear and multiple linear regression to fit curves in the form of polynomials or other functions like exponential and power equations to a given data set. The coefficients of these functions are determined by minimizing the sum of squared errors using the least squares method.

Uploaded by

Rahul Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

Approximation of Functions
(Numerical Interpolation & Regression)
Dheeraj K Khatod, EED
Basics about Approximation of
Functions
• Data are often tabulated in discrete values in a given range.
Many times, we require estimates at points between two
discrete values. Techniques are available to fit curves/functions
to such data to obtain intermediate estimates. In addition,
these techniques can be used to simplify a complicated
function. Both of these applications are known as curve fitting.
• Two general approaches for curve fitting (based on amount of
error associated with available data)
– Least-squares regression
• Used when available data exhibit a significant degree of error or noise
• A single curve is derived to represent the general trend of the available data
• Since any individual data point may be incorrect, no effort is made to
intersect every point. Rather, the curve is designed to follow the pattern of
the data points taken as a group
– Interpolation
• Used when very precise data are known
• Basic approach is to fit a curve or a series of curves that pass directly through
each of the data points

2
Graphical Depiction of Regression and
Interpolation

Least-squares Regression

(a) Linear Interpolation (b) Curvilinear Interpolation/Spline

Interpolation

3
Regression based Methods

4
Least-Squares Regression

• Given known data points:


𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 𝑖𝑖 = 0, 1, 2, … , 𝑛𝑛
• Using above 𝑛𝑛 + 1 data points, a polynomial of degree
𝑚𝑚 (𝑚𝑚 ≤ 𝑛𝑛) can be fitted as:
𝑦𝑦 = 𝑓𝑓𝑚𝑚 𝑥𝑥 = 𝑎𝑎0 + 𝑎𝑎1𝑥𝑥 + 𝑎𝑎2𝑥𝑥2 + . . . + 𝑎𝑎𝑚𝑚−1 𝑥𝑥 𝑚𝑚−1 + 𝑎𝑎𝑚𝑚 𝑥𝑥 𝑚𝑚
where, a’s are unknown constants/coefficients.
• The coefficients of 𝑓𝑓𝑚𝑚 𝑥𝑥 can be determined using least square
criterion, which minimizes the sum of the squares of the
residuals between measured y and calculated y as
𝑆𝑆𝑟𝑟 = ∑𝑖𝑖=𝑛𝑛
𝑖𝑖=0 𝑦𝑦𝑖𝑖 − 𝑓𝑓𝑚𝑚 𝑥𝑥𝑖𝑖
2

2
= ∑𝑖𝑖=𝑛𝑛
𝑖𝑖=0 𝑦𝑦𝑖𝑖 − 𝑎𝑎0 + 𝑎𝑎1𝑥𝑥𝑖𝑖 + . . . + 𝑎𝑎𝑚𝑚−1 𝑥𝑥𝑖𝑖𝑚𝑚−1 + 𝑎𝑎𝑚𝑚 𝑥𝑥𝑖𝑖𝑚𝑚

5
Least-Squares Regression (contd…)

• For the sum of squared error, 𝑆𝑆𝑟𝑟 to be minimum, the


partial derivatives of 𝑆𝑆𝑟𝑟 wrt 𝑚𝑚 + 1 coefficients should be
zero as
𝜕𝜕𝑆𝑆𝑟𝑟 𝜕𝜕𝑆𝑆𝑟𝑟 𝜕𝜕𝑆𝑆𝑟𝑟 𝜕𝜕𝑆𝑆𝑟𝑟 𝜕𝜕𝑆𝑆𝑟𝑟
= =⋯= =⋯= = =0
𝜕𝜕𝑎𝑎0 𝜕𝜕𝑎𝑎1 𝜕𝜕𝑎𝑎𝑘𝑘 𝜕𝜕𝑎𝑎𝑚𝑚−1 𝜕𝜕𝑎𝑎𝑚𝑚
where,
𝑖𝑖=𝑛𝑛
𝜕𝜕𝑆𝑆𝑟𝑟
= 2 � 𝑦𝑦𝑖𝑖 − 𝑎𝑎0 + 𝑎𝑎1𝑥𝑥𝑖𝑖 + . . . + 𝑎𝑎𝑚𝑚−1 𝑥𝑥𝑖𝑖𝑚𝑚−1 + 𝑎𝑎𝑚𝑚 𝑥𝑥𝑖𝑖𝑚𝑚 −𝑥𝑥𝑖𝑖𝑘𝑘
𝜕𝜕𝑎𝑎𝑘𝑘
𝑖𝑖=0
𝑘𝑘 = 0, 1, 2, … , 𝑚𝑚
• To determine 𝑚𝑚 + 1 coefficients of 𝑓𝑓𝑚𝑚 𝑥𝑥 , 𝑚𝑚 + 1
equations are required. Above relations give 𝑚𝑚 + 1
linear equations which can be solved simultaneously to
determine 𝑚𝑚 + 1 coefficients of 𝑓𝑓𝑚𝑚 𝑥𝑥 .

6
Least-Squares Regression (contd…)

• Above 𝑚𝑚 + 1 linear equations can be arranged in


matrix form also as
 =i n=i n 2 =i n m   i =n 
 n + 1 ∑ xi ∑ xi  ∑ xi   ∑ yi 
 =i 0=i 0 =i 0
  i =0 
 m +1   0   i =n 
=i n=i n =i n =i n a
 ∑ xi ∑ ∑  ∑ xi     ∑ xi yi
2 3
xi xi
a 

=i 0=i 0 =i 0 =i 0
  1   i =0 

=i n=i n =i n =i n
  a  =  i =n

∑ i ∑ ∑ ∑     ∑ i yi
m+2
x 2
x 3
x 4
 x 2
x 2

     i =0
i i i
= i 0=i 0 =i 0 =i 0 
        am    
= i n=i n =i n =i n   i =n 
 xm 2m   xm y 
=
 ∑ i ∑ x m +1
i
 i 0=i 0 =i 0
∑ x m+2
i  ∑
=i 0
x i

  ∑
 i =0
i i


7
Multiple Regression
• The method of least-squares regression can be extended to a linear function
of two or more independent variables as
𝑦𝑦 = 𝑎𝑎0 + 𝑎𝑎1𝑥𝑥1 + 𝑎𝑎2𝑥𝑥2 + . . . + 𝑎𝑎𝑚𝑚−1 𝑥𝑥𝑚𝑚−1 + 𝑎𝑎𝑚𝑚 𝑥𝑥𝑚𝑚
where, a’s are unknown constants/coefficients.
• Unknown coefficients of above model can be determined by solving
following 𝑚𝑚 + 1 linear equations simultaneously as
 =i n=i n =i n
  i=n 
 n +1 ∑ x1,i ∑ x2,i  ∑ xm ,i   ∑ yi 
 =i 0=i 0 =i 0
  i =0 

=i n=i n=i n =i n
  a0   i = n 
 ∑ x1,i ∑ ∑ x1,i x2,i  ∑ x1,i xm ,i     ∑ x1,i yi
2
x1,i
a 

=i 0=i 0=i 0 =i 0
  1   i =0 
=i n =i n =i n =i n=i n
  a2  =  i = n 
 ∑ x2,i ∑ x1,i x2,i ∑  ∑∑ x2,i xm,i     ∑ x2,i yi
2
x2,i 
=i 0 =i 0 =i 0 =i 0=i 0      i =0 
        am    
= i n=i n =i n=i n=  i n 
 x xm ,i   x y 
=
∑ ∑ x1,i xm,i ∑ x2,i xm,i 
 i 0=i 0 =i 0=i 0=
m ,i ∑ 2
  ∑
i 0
m ,i i

where, 𝑥𝑥1,𝑖𝑖 , 𝑥𝑥2,𝑖𝑖 , … , 𝑥𝑥𝑚𝑚,𝑖𝑖 , 𝑦𝑦𝑖𝑖 represents ith data point.

8
Non-Algebraic Relations

• Least-squares regression discussed for


polynomials can also be extended to non-
algebraic relations
– Exponential model
𝑦𝑦 = 𝛼𝛼1 𝑒𝑒 𝛽𝛽1 𝑥𝑥
– Power equation
𝑦𝑦 = 𝛼𝛼2 𝑥𝑥 𝛽𝛽2
– Saturation-growth-rate model can be expressed as
𝑥𝑥
𝑦𝑦 = 𝛼𝛼3
𝑥𝑥 + 𝛽𝛽3
where, 𝛼𝛼’s and 𝛽𝛽′ 𝑠𝑠 are unknown constants.
9
Exponential Model

• Exponential model can be expressed as


𝑦𝑦 = 𝛼𝛼1 𝑒𝑒 𝛽𝛽1 𝑥𝑥
where, 𝛼𝛼1 and 𝛽𝛽1 are unknown constants.
• The above model can be linearized by taking its
natural logarithm as
ln 𝑦𝑦 = ln 𝛼𝛼1 + 𝛽𝛽1 𝑥𝑥1
• Substituting 𝑌𝑌 = ln 𝑦𝑦 and 𝐴𝐴 = ln 𝛼𝛼1 , above model can
be expressed as
𝑌𝑌 = 𝐴𝐴 + 𝛽𝛽1 𝑥𝑥1
• The coefficients of above model can be computed by
least-squares regression.

10
Linearization of Exponential Model

Linearization

11
Power Equation

• Power equation can be expressed as


𝑦𝑦 = 𝛼𝛼2 𝑥𝑥 𝛽𝛽2
where, 𝛼𝛼2 and 𝛽𝛽2 are unknown constants.
• The above model can be linearized by taking its
logarithm as
log 𝑦𝑦 = log 𝛼𝛼2 + 𝛽𝛽2 log 𝑥𝑥
• Substituting 𝑌𝑌 = log 𝑦𝑦, 𝐴𝐴 = log 𝛼𝛼2 and 𝑋𝑋 = log 𝑥𝑥,
above model can be expressed as
𝑌𝑌 = 𝐴𝐴 + 𝛽𝛽2 𝑋𝑋
• The coefficients of above model can be computed
by least-squares regression.
12
Linearization of Power Equation

Linearization

13
Saturation-Growth-Rate model

• Saturation-growth-rate model can be expressed as


𝑥𝑥
𝑦𝑦 = 𝛼𝛼3
𝑥𝑥 + 𝛽𝛽3
where, 𝛼𝛼3 and 𝛽𝛽3 are unknown constants.
• The above model can be linearized by inverting it as
1 1 𝛽𝛽3
= +
𝑦𝑦 𝛼𝛼3 𝛼𝛼3 𝑥𝑥
1 1 𝛽𝛽3 1
• Substituting 𝑌𝑌 = , 𝐴𝐴 = , 𝐵𝐵 = and 𝑋𝑋 = , above
𝑦𝑦 𝛼𝛼3 𝛼𝛼3 𝑥𝑥
model can be expressed as
𝑌𝑌 = 𝐴𝐴 + 𝐵𝐵𝐵𝐵
• The coefficients of above model can be computed by least-
squares regression.

14
Linearization of Saturation-Growth-
Rate Model

Linearization

15
Periodic Functions using Fourier Series

• Fourier Series can be expressed as


𝑦𝑦 = 𝐴𝐴0 + 𝐴𝐴1 cos 𝜔𝜔𝜔𝜔 + 𝐴𝐴2 sin 𝜔𝜔𝜔𝜔
where, A’s are unknown constants.
• Unknown coefficients of above model can be determined by
solving following linear equations simultaneously as
𝑖𝑖=𝑛𝑛 𝑖𝑖=𝑛𝑛 𝑖𝑖=𝑛𝑛

𝑛𝑛 + 1 � cos 𝜔𝜔𝑡𝑡𝑖𝑖 � sin 𝜔𝜔𝑡𝑡𝑖𝑖 � 𝑦𝑦𝑖𝑖


𝑖𝑖=0 𝑖𝑖=0 𝑖𝑖=0
𝑖𝑖=𝑛𝑛 𝑖𝑖=𝑛𝑛 𝑖𝑖=𝑛𝑛 𝐴𝐴0 𝑖𝑖=𝑛𝑛

� cos 𝜔𝜔𝑡𝑡𝑖𝑖 � cos 𝜔𝜔𝑡𝑡𝑖𝑖 2


� sin 𝜔𝜔𝑡𝑡𝑖𝑖 cos 𝜔𝜔𝑡𝑡𝑖𝑖 𝐴𝐴1 = � cos 𝜔𝜔𝑡𝑡𝑖𝑖 𝑦𝑦𝑖𝑖
𝑖𝑖=0 𝑖𝑖=0 𝑖𝑖=0 𝐴𝐴2 𝑖𝑖=0
𝑖𝑖=𝑛𝑛 𝑖𝑖=𝑛𝑛 𝑖𝑖=𝑛𝑛 𝑖𝑖=𝑛𝑛
2
� sin 𝜔𝜔𝑡𝑡𝑖𝑖 � sin 𝜔𝜔𝑡𝑡𝑖𝑖 cos 𝜔𝜔𝑡𝑡𝑖𝑖 � sin 𝜔𝜔𝑡𝑡𝑖𝑖 � sin 𝜔𝜔𝑡𝑡𝑖𝑖 𝑦𝑦𝑖𝑖
𝑖𝑖=0 𝑖𝑖=0 𝑖𝑖=0 𝑖𝑖=0

16
Interpolation

17
Interpolation
• Given known data points:
𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 𝑖𝑖 = 0, 1, 2, … , 𝑛𝑛
• Using above 𝑛𝑛 + 1 data points, a polynomial of
degree 𝑚𝑚 (𝑚𝑚 ≤ 𝑛𝑛) can be fitted as:
𝑦𝑦 = 𝑓𝑓𝑚𝑚 𝑥𝑥 = 𝑎𝑎0 + 𝑎𝑎1𝑥𝑥 + 𝑎𝑎2𝑥𝑥2 + . . . + 𝑎𝑎𝑚𝑚−1 𝑥𝑥 𝑚𝑚−1 + 𝑎𝑎𝑚𝑚 𝑥𝑥 𝑚𝑚
where, a’s are unknown constants/coefficients.
• The process of finding the curve passing through
above points is called interpolation and the obtained
curve is called interpolating curve.
• If 𝑥𝑥𝑚𝑚 is not in the range between 𝑥𝑥0 to 𝑥𝑥𝑛𝑛 , then the
method to find 𝑦𝑦𝑚𝑚 corresponding to 𝑥𝑥𝑚𝑚 is called as
extrapolation.
18
Finite Difference Operators
• When the arguments are equally spaced i.e. ℎ = 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1 , for 𝑖𝑖 = 1, 2, … , 𝑛𝑛
and 𝑦𝑦𝑖𝑖 = 𝑓𝑓 𝑥𝑥𝑖𝑖 = 𝑓𝑓 𝑥𝑥0 + 𝑖𝑖𝑖 for 𝑖𝑖 = 0, 1, 2, … , 𝑛𝑛, then following finite
differences operators can be used:
– Forward Difference
• Operator: 𝛥𝛥
• ∆𝑦𝑦𝑖𝑖 = 𝑦𝑦𝑖𝑖+1 − 𝑦𝑦𝑖𝑖 or ∆𝑓𝑓 𝑥𝑥𝑖𝑖 = 𝑓𝑓 𝑥𝑥𝑖𝑖+1 − 𝑓𝑓 𝑥𝑥𝑖𝑖
• ∆𝑛𝑛 𝑦𝑦𝑖𝑖 = ∆𝑛𝑛−1 ∆𝑦𝑦𝑖𝑖 or ∆𝑛𝑛 𝑓𝑓 𝑥𝑥𝑖𝑖 = ∆𝑛𝑛−1 ∆𝑓𝑓 𝑥𝑥𝑖𝑖
– Backward Difference
• Operator: 𝛻𝛻
• ∇𝑦𝑦𝑖𝑖 = 𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖−1 or ∇𝑓𝑓 𝑥𝑥𝑖𝑖 = 𝑓𝑓 𝑥𝑥𝑖𝑖 − 𝑓𝑓 𝑥𝑥𝑖𝑖−1
• ∇𝑛𝑛 𝑦𝑦𝑖𝑖 = ∇𝑛𝑛−1 ∇𝑦𝑦𝑖𝑖 or ∇𝑛𝑛 𝑓𝑓 𝑥𝑥𝑖𝑖 = ∇𝑛𝑛−1 ∇𝑓𝑓 𝑥𝑥𝑖𝑖
– Central Difference
• Operator: 𝛿𝛿
ℎ ℎ
• 𝛿𝛿𝑦𝑦𝑖𝑖 = 𝑦𝑦𝑖𝑖+ℎ�2 − 𝑦𝑦𝑖𝑖−ℎ�2 or 𝛿𝛿𝑓𝑓 𝑥𝑥𝑖𝑖 = 𝑓𝑓 𝑥𝑥𝑖𝑖 + − 𝑓𝑓 𝑥𝑥𝑖𝑖 −
2 2
• 𝛿𝛿 𝑛𝑛 𝑦𝑦𝑖𝑖 = 𝛿𝛿 𝑛𝑛−1 𝛿𝛿𝑦𝑦𝑖𝑖 or 𝛿𝛿 𝑛𝑛 𝑓𝑓 𝑥𝑥𝑖𝑖 = 𝛿𝛿 𝑛𝑛−1 𝛿𝛿𝑓𝑓 𝑥𝑥𝑖𝑖

19
Finite Divided Difference

• First finite divided difference at point 𝑖𝑖


𝑓𝑓 𝑥𝑥𝑖𝑖+1 − 𝑓𝑓 𝑥𝑥𝑖𝑖
𝑓𝑓 𝑥𝑥𝑖𝑖 , 𝑥𝑥𝑖𝑖+1 = = 𝑓𝑓 𝑥𝑥𝑖𝑖+1 , 𝑥𝑥𝑖𝑖
𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖
• Second finite divided difference at point 𝑖𝑖
𝑓𝑓 𝑥𝑥𝑖𝑖+1 , 𝑥𝑥𝑖𝑖+2 − 𝑓𝑓 𝑥𝑥𝑖𝑖 , 𝑥𝑥𝑖𝑖+1
𝑓𝑓 𝑥𝑥𝑖𝑖 , 𝑥𝑥𝑖𝑖+1 , 𝑥𝑥𝑖𝑖+2 =
𝑥𝑥𝑖𝑖+2 − 𝑥𝑥𝑖𝑖
= 𝑓𝑓 𝑥𝑥𝑖𝑖+2 , 𝑥𝑥𝑖𝑖+1 , 𝑥𝑥𝑖𝑖
• Similarly, nth finite divided difference at point 𝑖𝑖
𝑓𝑓 𝑥𝑥𝑖𝑖 , 𝑥𝑥𝑖𝑖+1 , … , 𝑥𝑥𝑖𝑖+𝑛𝑛
𝑓𝑓 𝑥𝑥𝑖𝑖+1 , 𝑥𝑥𝑖𝑖+2 , … , 𝑥𝑥𝑖𝑖+𝑛𝑛 − 𝑓𝑓 𝑥𝑥𝑖𝑖 , 𝑥𝑥𝑖𝑖+1 , … , 𝑥𝑥𝑖𝑖+𝑛𝑛−1
=
𝑥𝑥𝑖𝑖+𝑛𝑛 − 𝑥𝑥𝑖𝑖
for 𝑛𝑛 = 1, 2, 3, …
20
Piecewise Linear Interpolation

• In piecewise linear interpolation, each pair of


consecutive points is approximated by a linear
function.
• Given known data points:
𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 𝑖𝑖 = 0, 1, 2, … , 𝑛𝑛
• A line segment, interpolating two given points,
𝑥𝑥𝑘𝑘 , 𝑦𝑦𝑘𝑘 and 𝑥𝑥𝑘𝑘+1 , 𝑦𝑦𝑘𝑘+1 , can be expressed as
𝑦𝑦−𝑦𝑦𝑘𝑘 𝑦𝑦𝑘𝑘+1 −𝑦𝑦𝑘𝑘 𝑦𝑦𝑘𝑘+1 −𝑦𝑦𝑘𝑘
= or 𝑦𝑦 = 𝑓𝑓1 𝑥𝑥 = 𝑦𝑦𝑘𝑘 + 𝑥𝑥 − 𝑥𝑥𝑘𝑘
𝑥𝑥−𝑥𝑥𝑘𝑘 𝑥𝑥𝑘𝑘+1 −𝑥𝑥𝑘𝑘 𝑥𝑥𝑘𝑘+1 −𝑥𝑥𝑘𝑘

for 𝑥𝑥𝑘𝑘 ≤ 𝑥𝑥 ≤ 𝑥𝑥𝑘𝑘+1 , 𝑘𝑘 = 0, 1, 2, ⋯ , 𝑛𝑛 − 1


where, 𝑓𝑓1 𝑥𝑥 represents first order polynomial.

21
Lagrange Interpolating Polynomial

• Given known data points:


𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 𝑖𝑖 = 0, 1, 2, … , 𝑛𝑛
• Using above data points, Lagrange interpolating
polynomial of order 𝑛𝑛 can be expressed as
𝑓𝑓𝑛𝑛 𝑥𝑥 = ∑𝑛𝑛𝑖𝑖=0 𝐿𝐿𝑖𝑖 𝑥𝑥 𝑦𝑦𝑖𝑖 or 𝑓𝑓𝑛𝑛 𝑥𝑥 = ∑𝑛𝑛𝑖𝑖=0 𝐿𝐿𝑖𝑖 𝑥𝑥 𝑓𝑓 𝑥𝑥𝑖𝑖
𝑗𝑗=𝑛𝑛 𝑥𝑥−𝑥𝑥𝑗𝑗
where, 𝐿𝐿𝑖𝑖 𝑥𝑥 = ∏𝑗𝑗=0
𝑥𝑥𝑖𝑖 −𝑥𝑥𝑗𝑗
𝑗𝑗≠𝑖𝑖

1 𝑥𝑥 = 𝑥𝑥𝑗𝑗
Also, 𝐿𝐿𝑖𝑖 𝑥𝑥 = �
0 𝑥𝑥 ≠ 𝑥𝑥𝑗𝑗

22
Newton Interpolating Polynomial

• Given known data points:


𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 𝑖𝑖 = 0, 1, 2, … , 𝑛𝑛
• Using above data points, Newton interpolating polynomial
of order 𝑛𝑛 can be expressed as
𝑦𝑦 = 𝑓𝑓𝑛𝑛 𝑥𝑥 = 𝑏𝑏0 + 𝑏𝑏1 𝑥𝑥 − 𝑥𝑥0 + 𝑏𝑏2 𝑥𝑥 − 𝑥𝑥0 𝑥𝑥 − 𝑥𝑥1
+ . . . + 𝑏𝑏𝑛𝑛 𝑥𝑥 − 𝑥𝑥0 𝑥𝑥 − 𝑥𝑥1 . . . 𝑥𝑥 − 𝑥𝑥𝑛𝑛−1
• The coefficients, 𝑏𝑏𝑖𝑖 , 𝑖𝑖 = 0, 1, 2, … , 𝑛𝑛 of above equation can
be computed by substituting 𝑥𝑥 = 𝑥𝑥0 , 𝑥𝑥1 , … , 𝑥𝑥𝑛𝑛 , one at a
time in 𝑓𝑓𝑛𝑛 𝑥𝑥 as
𝑏𝑏0 = 𝑦𝑦0
𝑏𝑏0 + 𝑏𝑏1 𝑥𝑥1 − 𝑥𝑥0 = 𝑦𝑦1
𝑏𝑏0 + 𝑏𝑏1 𝑥𝑥2 − 𝑥𝑥0 + 𝑏𝑏2 𝑥𝑥2 − 𝑥𝑥0 𝑥𝑥2 − 𝑥𝑥1 = 𝑦𝑦2

𝑏𝑏0 + 𝑏𝑏1 𝑥𝑥𝑛𝑛 − 𝑥𝑥0 + . . . +𝑏𝑏𝑛𝑛 𝑥𝑥𝑛𝑛 − 𝑥𝑥0 𝑥𝑥𝑛𝑛 − 𝑥𝑥1 . . . 𝑥𝑥𝑛𝑛 − 𝑥𝑥𝑛𝑛−1 = 𝑦𝑦𝑛𝑛

23
Newton Interpolating Polynomial
(contd…)
• Those 𝑛𝑛 + 1 linear equations can be solved by forward substitution
as
𝑏𝑏0 = 𝑦𝑦0
𝑦𝑦1 − 𝑏𝑏0
𝑏𝑏1 = = 𝑓𝑓 𝑥𝑥0 , 𝑥𝑥1
𝑥𝑥1 − 𝑥𝑥0
𝑦𝑦2 − 𝑏𝑏0 − 𝑏𝑏1 𝑥𝑥2 − 𝑥𝑥0
𝑏𝑏2 = = 𝑓𝑓 𝑥𝑥0 , 𝑥𝑥1 , 𝑥𝑥2
𝑥𝑥2 − 𝑥𝑥0 𝑥𝑥2 − 𝑥𝑥1

𝑦𝑦𝑛𝑛 − 𝑏𝑏0 − 𝑏𝑏1 𝑥𝑥𝑛𝑛 − 𝑥𝑥0 − ⋯ − 𝑏𝑏𝑛𝑛−1 𝑥𝑥𝑛𝑛 − 𝑥𝑥0 𝑥𝑥𝑛𝑛 − 𝑥𝑥1 . . . 𝑥𝑥𝑛𝑛 − 𝑥𝑥𝑛𝑛−2
𝑏𝑏𝑛𝑛 =
𝑥𝑥𝑛𝑛 − 𝑥𝑥0 𝑥𝑥𝑛𝑛 − 𝑥𝑥1 . . . 𝑥𝑥𝑛𝑛 − 𝑥𝑥𝑛𝑛−1
= 𝑓𝑓 𝑥𝑥0 , 𝑥𝑥1 , … , 𝑥𝑥𝑛𝑛−1 , 𝑥𝑥𝑛𝑛
• General expression
𝑚𝑚−1 𝑘𝑘−1
1
𝑏𝑏𝑚𝑚 = 𝑦𝑦𝑚𝑚 − 𝑏𝑏0 − � 𝑏𝑏𝑘𝑘 � 𝑥𝑥𝑚𝑚 − 𝑥𝑥𝑗𝑗 = 𝑓𝑓 𝑥𝑥0 , 𝑥𝑥1 , … , 𝑥𝑥𝑚𝑚−1 , 𝑥𝑥𝑚𝑚
∏𝑚𝑚−1
𝑖𝑖=0 𝑥𝑥𝑚𝑚 − 𝑥𝑥𝑖𝑖
𝑘𝑘=1 𝑗𝑗=0

for 𝑚𝑚 = 1,2, 3, … , 𝑛𝑛

24
Special Case of Newton Interpolating
Polynomial
• Using finite divided difference relations, Newton
interpolating polynomial can also be expressed as
𝑓𝑓𝑛𝑛 𝑥𝑥 = 𝑦𝑦0 + 𝑥𝑥 − 𝑥𝑥0 𝑓𝑓 𝑥𝑥0 , 𝑥𝑥1 + 𝑥𝑥 − 𝑥𝑥0 𝑥𝑥 − 𝑥𝑥1 𝑓𝑓 𝑥𝑥0 , 𝑥𝑥1 , 𝑥𝑥2 +. . .
+ 𝑥𝑥 − 𝑥𝑥0 𝑥𝑥 − 𝑥𝑥1 . . . 𝑥𝑥 − 𝑥𝑥𝑛𝑛−1 𝑓𝑓 𝑥𝑥0 , 𝑥𝑥1 , … , 𝑥𝑥𝑛𝑛−1 , 𝑥𝑥𝑛𝑛
• If interpolating points 𝑥𝑥𝑖𝑖 , 𝑖𝑖 = 0, 1, 2, … , 𝑛𝑛 are equally
spaced, i.e. ℎ = 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1 , for 𝑖𝑖 = 1, 2, … , 𝑛𝑛, then
𝑏𝑏0 = 𝑦𝑦0
∆𝑦𝑦0
𝑏𝑏1 = 𝑓𝑓 𝑥𝑥0 , 𝑥𝑥1 =

∆2 𝑦𝑦0
𝑏𝑏2 = 𝑓𝑓 𝑥𝑥0 , 𝑥𝑥1 , 𝑥𝑥2 =
2! ℎ2

∆𝑛𝑛 𝑦𝑦0
𝑏𝑏𝑛𝑛 = 𝑓𝑓 𝑥𝑥0 , 𝑥𝑥1 , … , 𝑥𝑥𝑛𝑛−1 , 𝑥𝑥𝑛𝑛 =
𝑛𝑛! ℎ𝑛𝑛
25
Special Case of Newton Interpolating
Polynomial (contd…)
• General expression
∆𝑚𝑚 𝑦𝑦0
𝑏𝑏𝑚𝑚 = 𝑓𝑓 𝑥𝑥0 , 𝑥𝑥1 , … , 𝑥𝑥𝑚𝑚−1 , 𝑥𝑥𝑚𝑚 =
𝑚𝑚! ℎ𝑚𝑚
for 𝑚𝑚 = 1,2, 3, … , 𝑛𝑛
• Finally, for equally spaced interpolating points,
Newton interpolating polynomial can be expressed as
∆𝑦𝑦0 ∆2 𝑦𝑦0
𝑓𝑓𝑛𝑛 𝑥𝑥 = 𝑦𝑦0 + 𝑥𝑥 − 𝑥𝑥0 + 𝑥𝑥 − 𝑥𝑥0 𝑥𝑥 − 𝑥𝑥1 2
+. . .
ℎ 2! ℎ
𝑛𝑛
∆ 𝑦𝑦0
+ 𝑥𝑥 − 𝑥𝑥0 𝑥𝑥 − 𝑥𝑥1 . . . 𝑥𝑥 − 𝑥𝑥𝑛𝑛−1
𝑛𝑛! ℎ𝑛𝑛

26
Aitken Interpolation Method

• Given known data points:


𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 𝑖𝑖 = 0, 1, 2, … , 𝑛𝑛
• According to Aitken interpolation method,
interpolating polynomial 𝑊𝑊𝑛𝑛 (𝑥𝑥) is evaluated by using
a series of linear interpolation through 𝑛𝑛 iterations as
– First iteration
• 𝑛𝑛 polynomials, 𝑊𝑊0,𝑘𝑘 (between 𝑖𝑖 = 0 and 𝑖𝑖 = 𝑘𝑘) of degree 1 are
created as
𝑥𝑥 − 𝑥𝑥𝑘𝑘 𝑥𝑥 − 𝑥𝑥0 𝑥𝑥 − 𝑥𝑥𝑘𝑘 𝑥𝑥 − 𝑥𝑥0
𝑊𝑊0,𝑘𝑘 = 𝑦𝑦0 + 𝑦𝑦𝑘𝑘 = 𝑦𝑦0 − 𝑦𝑦𝑘𝑘
𝑥𝑥0 − 𝑥𝑥𝑘𝑘 𝑥𝑥𝑘𝑘 − 𝑥𝑥0 𝑥𝑥0 − 𝑥𝑥𝑘𝑘 𝑥𝑥0 − 𝑥𝑥𝑘𝑘
1 𝑦𝑦0 𝑥𝑥 − 𝑥𝑥0
=
𝑥𝑥0 − 𝑥𝑥𝑘𝑘 𝑦𝑦𝑘𝑘 𝑥𝑥 − 𝑥𝑥𝑘𝑘
for 𝑘𝑘 = 1,2, 3, … , 𝑛𝑛

27
Aitken Interpolation Method (contd…)

– Second iteration
• (𝑛𝑛 − 1) polynomials, 𝑊𝑊0,1,𝑘𝑘 (between 𝑖𝑖 = 1 and 𝑖𝑖 = 𝑘𝑘) of degree 2 are
created as
𝑥𝑥 − 𝑥𝑥𝑘𝑘 𝑥𝑥 − 𝑥𝑥1 𝑥𝑥 − 𝑥𝑥𝑘𝑘 𝑥𝑥 − 𝑥𝑥1
𝑊𝑊0, 1, 𝑘𝑘 = 𝑊𝑊0,1 + 𝑊𝑊0,𝑘𝑘 = 𝑊𝑊0,1 − 𝑊𝑊0,𝑘𝑘
𝑥𝑥1 − 𝑥𝑥𝑘𝑘 𝑥𝑥𝑘𝑘 − 𝑥𝑥1 𝑥𝑥1 − 𝑥𝑥𝑘𝑘 𝑥𝑥1 − 𝑥𝑥𝑘𝑘
1 𝑊𝑊0,1 𝑥𝑥 − 𝑥𝑥1
=
𝑥𝑥1 − 𝑥𝑥𝑘𝑘 𝑊𝑊0,𝑘𝑘 𝑥𝑥 − 𝑥𝑥𝑘𝑘
for 𝑘𝑘 = 2, 3, … , 𝑛𝑛
– Third iteration
• (𝑛𝑛 − 2) polynomials, 𝑊𝑊0,1,2,𝑘𝑘 (between 𝑖𝑖 = 2 and 𝑖𝑖 = 𝑘𝑘) of degree 3 are
created as
𝑥𝑥 − 𝑥𝑥𝑘𝑘 𝑥𝑥 − 𝑥𝑥2 𝑥𝑥 − 𝑥𝑥𝑘𝑘 𝑥𝑥 − 𝑥𝑥2
𝑊𝑊0, 1, 2, 𝑘𝑘 = 𝑊𝑊0,1,2 + 𝑊𝑊0,1,𝑘𝑘 = 𝑊𝑊0,1,2 − 𝑊𝑊0, 1,𝑘𝑘
𝑥𝑥2 − 𝑥𝑥𝑘𝑘 𝑥𝑥𝑘𝑘 − 𝑥𝑥2 𝑥𝑥2 − 𝑥𝑥𝑘𝑘 𝑥𝑥2 − 𝑥𝑥𝑘𝑘
1 𝑊𝑊0,1,2 𝑥𝑥 − 𝑥𝑥2
=
𝑥𝑥2 − 𝑥𝑥𝑘𝑘 𝑊𝑊0,1,𝑘𝑘 𝑥𝑥 − 𝑥𝑥𝑘𝑘
for 𝑘𝑘 = 3, 4, … , 𝑛𝑛

28
Aitken Interpolation Method (contd…)

– Last (𝑛𝑛𝑡𝑡𝑡) iteration


• One polynomial, 𝑊𝑊0,1,2, … , 𝑛𝑛 (between 𝑖𝑖 = 𝑛𝑛 − 1 and 𝑖𝑖 = 𝑛𝑛) of degree
𝑛𝑛 is created as
𝑥𝑥 − 𝑥𝑥𝑛𝑛 𝑥𝑥 − 𝑥𝑥𝑛𝑛−1
𝑊𝑊0,1,2, … , 𝑛𝑛 = 𝑊𝑊0,1,2, … ,𝑛𝑛−2, 𝑛𝑛−1 + 𝑊𝑊0,1,2, … ,𝑛𝑛−2, 𝑛𝑛
𝑥𝑥𝑛𝑛−1 − 𝑥𝑥𝑛𝑛 𝑥𝑥𝑛𝑛 − 𝑥𝑥𝑛𝑛−1
𝑥𝑥 − 𝑥𝑥𝑛𝑛 𝑥𝑥 − 𝑥𝑥𝑛𝑛−1
= 𝑊𝑊0,1,2, … ,𝑛𝑛−2, 𝑛𝑛−1 − 𝑊𝑊0,1,2, … ,𝑛𝑛−2, 𝑛𝑛
𝑥𝑥𝑛𝑛−1 − 𝑥𝑥𝑛𝑛 𝑥𝑥𝑛𝑛−1 − 𝑥𝑥𝑛𝑛
1 𝑊𝑊0,1,2, … ,𝑛𝑛−2, 𝑛𝑛−1 𝑥𝑥 − 𝑥𝑥𝑛𝑛
=
𝑥𝑥𝑛𝑛−1 − 𝑥𝑥𝑛𝑛 𝑊𝑊0,1,2, … ,𝑛𝑛−2, 𝑛𝑛 𝑥𝑥 − 𝑥𝑥𝑛𝑛−1

29
Table of Calculation for Aitken
Interpolation Method

30
Spline Interpolation
• In the previous slides, 𝑛𝑛th-order polynomials were used to
interpolate between 𝑛𝑛 + 1 data points. This curve would
capture all the meanderings (at least up to and including 𝑛𝑛th
derivatives) suggested by the points. However, there are cases
where these functions can lead to erroneous results because of
round-off error and overshoot.
• An alternative approach is to apply lower-order polynomials to
subsets of data points. Such connecting polynomials are called
spline functions.
• The concept of the spline originated from the drafting
technique of using a thin, flexible strip (called a spline) to draw
smooth curves through a set of points. In this technique, the
drafter places paper over a wooden board and hammers nails
or pins into the paper (and board) at the location of the data
points. A smooth cubic curve results from interweaving the
strip between the pins.

31
Spline Interpolation (contd…)
• Given known data points:
𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 𝑖𝑖 = 0, 1, 2, … , 𝑛𝑛
• For 𝑛𝑛 + 1 data points, there 𝑛𝑛 intervals (segments
joining two consecutive points). For each interval, a
spline (of linear or quadratic or cubic order) can be
fitted. The order of spline through out the data range
remains same.
• Data point, where two splines/segments meet, is
called a knot.

32
Depiction of Spline Interpolation

33
Linear Spline
• In first-order (or linear) spline, a pair of two consecutive points
is joined by a straight line. For any 𝑖𝑖𝑡𝑡𝑡 interval,
𝑓𝑓𝑖𝑖 𝑥𝑥 = 𝑎𝑎𝑖𝑖 𝑥𝑥 + 𝑏𝑏𝑖𝑖 , 𝑖𝑖 = 1, 2, … , 𝑛𝑛
where, 𝑎𝑎𝑖𝑖 and 𝑏𝑏𝑖𝑖 are unknowns and can be
determined as:
𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖−1
𝑎𝑎𝑖𝑖 =
𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1
𝑥𝑥𝑖𝑖 𝑦𝑦𝑖𝑖−1 − 𝑥𝑥𝑖𝑖−1 𝑦𝑦𝑖𝑖
𝑏𝑏𝑖𝑖 =
𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1
• The primary disadvantage of first-order splines is that they are
not smooth (at knots, the slope changes abruptly).
• This deficiency is overcome by using higher-order polynomial
splines that ensure smoothness at the knots by equating
derivatives at these points.

34
Depiction of Linear Spline

35
Quadratic Spline
• In second-order (or quadratic) spline, a pair of two
consecutive points is joined by a second-order curve. For
any 𝑖𝑖𝑡𝑡𝑡 interval,
𝑓𝑓𝑖𝑖 𝑥𝑥 = 𝑎𝑎𝑖𝑖 𝑥𝑥 2 + 𝑏𝑏𝑖𝑖 𝑥𝑥 + 𝑐𝑐𝑖𝑖 , 𝑖𝑖 = 1, 2, … , 𝑛𝑛
where, 𝑎𝑎𝑖𝑖 , 𝑏𝑏𝑖𝑖 and 𝑐𝑐𝑖𝑖 are unknowns.
• Having 3 unknowns for each spline, there are total 3𝑛𝑛
unknowns. This requires 3𝑛𝑛 equations which can be
formulated by considering following points:
– The function values of adjacent polynomials must be equal at the
interior knots as:
2
𝑎𝑎𝑖𝑖−1 𝑥𝑥𝑖𝑖−1 + 𝑏𝑏𝑖𝑖−1 𝑥𝑥𝑖𝑖−1 + 𝑐𝑐𝑖𝑖−1 = 𝑦𝑦𝑖𝑖−1 or 𝑓𝑓 𝑥𝑥𝑖𝑖−1
2
𝑎𝑎𝑖𝑖 𝑥𝑥𝑖𝑖−1 + 𝑏𝑏𝑖𝑖 𝑥𝑥𝑖𝑖−1 + 𝑐𝑐𝑖𝑖 = 𝑦𝑦𝑖𝑖−1 or 𝑓𝑓 𝑥𝑥𝑖𝑖−1
for 𝑖𝑖 = 2, 3, … , 𝑛𝑛
This condition gives 2 𝑛𝑛 − 1 equations.

36
Quadratic Spline (contd…)
– The first and last functions must pass through the end
points as
𝑎𝑎1 𝑥𝑥02 + 𝑏𝑏1 𝑥𝑥0 + 𝑐𝑐1 = 𝑦𝑦0 or 𝑓𝑓 𝑥𝑥0
𝑎𝑎𝑛𝑛 𝑥𝑥𝑛𝑛2 + 𝑏𝑏𝑛𝑛 𝑥𝑥𝑛𝑛 + 𝑐𝑐𝑛𝑛 = 𝑦𝑦𝑛𝑛 or 𝑓𝑓 𝑥𝑥𝑛𝑛
This condition gives 2 equations.
– The first derivatives (i.e. 𝑓𝑓𝑖𝑖′ 𝑥𝑥 = 2𝑎𝑎𝑖𝑖 𝑥𝑥 + 𝑏𝑏𝑖𝑖 ) of adjacent
polynomials at the interior knots must be equal as
2𝑎𝑎𝑖𝑖−1 𝑥𝑥𝑖𝑖−1 + 𝑏𝑏𝑖𝑖−1 = 2𝑎𝑎𝑖𝑖 𝑥𝑥𝑖𝑖−1 + 𝑏𝑏𝑖𝑖 , for 𝑖𝑖 = 2, 3, … , 𝑛𝑛
This condition gives 𝑛𝑛 − 1 equations.
– The second derivative (i.e. 𝑓𝑓𝑖𝑖′′ 𝑥𝑥 = 2𝑎𝑎𝑖𝑖 ) is zero at the first
point as
𝑎𝑎1 = 0
This condition gives 1 equation.

37
Depiction of Quadratic Spline

38
Cubic Spline
• In third-order (or cubic) spline, a pair of two consecutive
points is joined by a third-order curve. For any 𝑖𝑖𝑡𝑡𝑡 interval,
𝑓𝑓𝑖𝑖 𝑥𝑥 = 𝑎𝑎𝑖𝑖 𝑥𝑥 3 + 𝑏𝑏𝑖𝑖 𝑥𝑥 2 + 𝑐𝑐𝑖𝑖 𝑥𝑥 + 𝑑𝑑𝑖𝑖 , 𝑖𝑖 = 1, 2, … , 𝑛𝑛
where, 𝑎𝑎𝑖𝑖 , 𝑏𝑏𝑖𝑖 , 𝑐𝑐𝑖𝑖 and 𝑑𝑑𝑖𝑖 are unknowns.
• Having 4 unknowns for each spline, there are total 4𝑛𝑛
unknowns. This requires 4𝑛𝑛 equations which can be
formulated by considering following points:
– The function values of adjacent polynomials must be equal at the
interior knots as:
3 2
𝑎𝑎𝑖𝑖−1 𝑥𝑥𝑖𝑖−1 + 𝑏𝑏𝑖𝑖−1 𝑥𝑥𝑖𝑖−1 + 𝑐𝑐𝑖𝑖−1 𝑥𝑥𝑖𝑖−1 + 𝑑𝑑𝑖𝑖−1 = 𝑦𝑦𝑖𝑖−1 or 𝑓𝑓 𝑥𝑥𝑖𝑖−1
3 2
𝑎𝑎𝑖𝑖 𝑥𝑥𝑖𝑖−1 + 𝑏𝑏𝑖𝑖 𝑥𝑥𝑖𝑖−1 + 𝑐𝑐𝑖𝑖 𝑥𝑥𝑖𝑖−1 + 𝑑𝑑𝑖𝑖 = 𝑦𝑦𝑖𝑖−1 or 𝑓𝑓 𝑥𝑥𝑖𝑖−1
for 𝑖𝑖 = 2, 3, … , 𝑛𝑛
This condition gives 2 𝑛𝑛 − 1 equations.

39
Cubic Spline (contd…)
– The first and last functions must pass through the end
points as
𝑎𝑎1 𝑥𝑥03 + 𝑏𝑏1 𝑥𝑥02 + 𝑐𝑐1 𝑥𝑥0 + 𝑑𝑑1 = 𝑦𝑦0 or 𝑓𝑓 𝑥𝑥0
𝑎𝑎𝑛𝑛 𝑥𝑥𝑛𝑛3 + 𝑏𝑏𝑛𝑛 𝑥𝑥𝑛𝑛2 + 𝑐𝑐𝑛𝑛 𝑥𝑥𝑛𝑛 + 𝑑𝑑𝑛𝑛 = 𝑦𝑦𝑛𝑛 or 𝑓𝑓 𝑥𝑥𝑛𝑛
This condition gives 2 equations.
– The first derivatives (i.e. 𝑓𝑓𝑖𝑖′ 𝑥𝑥 = 3𝑎𝑎𝑖𝑖 𝑥𝑥𝑖𝑖2 + 2𝑏𝑏𝑖𝑖 𝑥𝑥𝑖𝑖 + 𝑐𝑐𝑖𝑖 ) of
adjacent polynomials at the interior knots must be
equal as
2 2
3𝑎𝑎𝑖𝑖−1 𝑥𝑥𝑖𝑖−1 + 2𝑏𝑏𝑖𝑖−1 𝑥𝑥𝑖𝑖−1 + 𝑐𝑐𝑖𝑖−1 = 3𝑎𝑎𝑖𝑖 𝑥𝑥𝑖𝑖−1 + 2𝑏𝑏𝑖𝑖 𝑥𝑥𝑖𝑖−1 + 𝑐𝑐𝑖𝑖 ,
for 𝑖𝑖 = 2, 3, … , 𝑛𝑛
This condition gives 𝑛𝑛 − 1 equations.

40
Cubic Spline (contd…)
– The second derivatives (i.e. 𝑓𝑓𝑖𝑖′′ 𝑥𝑥 = 6𝑎𝑎𝑖𝑖 𝑥𝑥𝑖𝑖 + 2𝑏𝑏𝑖𝑖 ) of
adjacent polynomials at the interior knots must be
equal as
6𝑎𝑎𝑖𝑖−1 𝑥𝑥𝑖𝑖−1 + 2𝑏𝑏𝑖𝑖−1 = 6𝑎𝑎𝑖𝑖 𝑥𝑥𝑖𝑖−1 + 2𝑏𝑏𝑖𝑖 ,
for 𝑖𝑖 = 2, 3, … , 𝑛𝑛
This condition gives 𝑛𝑛 − 1 equations.
– The second derivatives at end points are zero as
6𝑎𝑎1 𝑥𝑥0 + 2𝑏𝑏1 = 0
6𝑎𝑎𝑛𝑛 𝑥𝑥𝑛𝑛 + 2𝑏𝑏𝑛𝑛 = 0
This condition gives 2 equations.

41
Alternative Approach for Cubic Spline

• To reduce the computational efforts, there is an


alternative technique that requires the solution of
only 𝑛𝑛 − 1 equations.
• As each pair of knots is connected by a cubic function,
the second derivative within each interval is a straight
line and can be represented by a first-order Lagrange
interpolating polynomial. For any 𝑖𝑖𝑡𝑡𝑡 interval,
′′ ′′ 𝑥𝑥 − 𝑥𝑥𝑖𝑖 ′′ 𝑥𝑥 − 𝑥𝑥𝑖𝑖−1
𝑓𝑓𝑖𝑖 𝑥𝑥 = 𝑓𝑓𝑖𝑖 𝑥𝑥𝑖𝑖−1 + 𝑓𝑓𝑖𝑖 𝑥𝑥𝑖𝑖
𝑥𝑥𝑖𝑖−1 − 𝑥𝑥𝑖𝑖 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1
where, 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖−1 and 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖 are the values of second
derivative of 𝑓𝑓𝑖𝑖 𝑥𝑥 at 𝑖𝑖 − 1 𝑡𝑡𝑡 and 𝑖𝑖𝑡𝑡𝑡 points, respectively.

42
Alternative Approach for Cubic Spline
(contd…)
• Integrating above equation results
2 2
𝑥𝑥 − 𝑥𝑥𝑖𝑖 𝑥𝑥 − 𝑥𝑥𝑖𝑖−1
𝑓𝑓𝑖𝑖′ 𝑥𝑥 = 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖−1 + 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖 + 𝐶𝐶1
2 𝑥𝑥𝑖𝑖−1 − 𝑥𝑥𝑖𝑖 2 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1
where, 𝐶𝐶1 is a constant of integration.
• Again integrating above equation results
3 3
𝑥𝑥 − 𝑥𝑥𝑖𝑖 𝑥𝑥 − 𝑥𝑥𝑖𝑖−1
𝑓𝑓𝑖𝑖 𝑥𝑥 = 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖−1 + 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖 + 𝐶𝐶1 𝑥𝑥 + 𝐶𝐶2
6 𝑥𝑥𝑖𝑖−1 − 𝑥𝑥𝑖𝑖 6 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1
where, 𝐶𝐶2 is a constant of integration.
• The integration constants can be evaluated by
invoking the function-equality conditions as
𝑦𝑦𝑖𝑖−1 = 𝑓𝑓 𝑥𝑥𝑖𝑖−1 = 𝑓𝑓𝑖𝑖 𝑥𝑥𝑖𝑖−1
𝑦𝑦𝑖𝑖 = 𝑓𝑓 𝑥𝑥𝑖𝑖 = 𝑓𝑓𝑖𝑖 𝑥𝑥𝑖𝑖

43
Alternative Approach for Cubic Spline
(contd…)
• By substituting above conditions in expression of 𝑓𝑓𝑖𝑖 𝑥𝑥 , two equations are obtained
which can be solved to evaluate the integration constants as
𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1 2 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖−1 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖 𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖−1
𝐶𝐶1 = − + +
6 𝑥𝑥𝑖𝑖−1 − 𝑥𝑥𝑖𝑖 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1
𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1 2 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖−1 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖
𝐶𝐶2 = 𝑦𝑦𝑖𝑖 + + − 𝑥𝑥𝑖𝑖
6 𝑥𝑥𝑖𝑖−1 − 𝑥𝑥𝑖𝑖 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1 𝑥𝑥𝑖𝑖
𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖−1
− 𝑥𝑥
𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1 𝑖𝑖
• Using the values of integration constants as computed above, the final expression of
𝑓𝑓𝑖𝑖 𝑥𝑥 can be given as
𝑥𝑥 − 𝑥𝑥 3 𝑥𝑥 − 𝑥𝑥 3
𝑖𝑖 𝑖𝑖−1
𝑓𝑓𝑖𝑖 𝑥𝑥 = 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖−1 + 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖
6 𝑥𝑥𝑖𝑖−1 − 𝑥𝑥𝑖𝑖 6 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1
𝑦𝑦𝑖𝑖−1 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖−1
+ + 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1 𝑥𝑥 − 𝑥𝑥𝑖𝑖
𝑥𝑥𝑖𝑖−1 − 𝑥𝑥𝑖𝑖 6
𝑦𝑦𝑖𝑖 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖
+ − 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1 𝑥𝑥 − 𝑥𝑥𝑖𝑖−1
𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1 6

44
Alternative Approach for Cubic Spline
(contd…)
• In above equation, there are two unknowns, the second derivatives
at the beginning and the end of the interval. For computing second
derivative, following relations can be used
2 2
𝑥𝑥 − 𝑥𝑥𝑖𝑖 𝑥𝑥 − 𝑥𝑥𝑖𝑖−1
𝑓𝑓𝑖𝑖′ 𝑥𝑥 = 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖−1 + 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖
2 𝑥𝑥𝑖𝑖−1 − 𝑥𝑥𝑖𝑖 2 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1
𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1 2 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖−1 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖 𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖−1
− + +
6 𝑥𝑥𝑖𝑖−1 − 𝑥𝑥𝑖𝑖 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1
2 2
′ ′′ 𝑥𝑥 − 𝑥𝑥𝑖𝑖+1 ′′ 𝑥𝑥 − 𝑥𝑥𝑖𝑖
𝑓𝑓𝑖𝑖+1 𝑥𝑥 = 𝑓𝑓𝑖𝑖+1 𝑥𝑥𝑖𝑖 + 𝑓𝑓𝑖𝑖+1 𝑥𝑥𝑖𝑖+1
2 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖+1 2 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖
′′ ′′
𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 2 𝑓𝑓𝑖𝑖+1 𝑥𝑥𝑖𝑖 𝑓𝑓𝑖𝑖+1 𝑥𝑥𝑖𝑖+1 𝑦𝑦𝑖𝑖+1 − 𝑦𝑦𝑖𝑖
− + +
6 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖+1 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖
• Above two equations evaluated at interior knots will result same
value as the first derivatives at the knots must be continuous,
𝑓𝑓𝑖𝑖′ 𝑥𝑥𝑖𝑖 = 𝑓𝑓𝑖𝑖+1′
𝑥𝑥𝑖𝑖

45
Alternative Approach for Cubic Spline
(contd…)
• Using above condition and simplifying the resultant yields
𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖−1 + 2 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖−1 𝑓𝑓𝑖𝑖′′ 𝑥𝑥𝑖𝑖
′′ 𝑦𝑦𝑖𝑖+1 − 𝑦𝑦𝑖𝑖 𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑖𝑖−1
+ 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 𝑓𝑓𝑖𝑖+1 𝑥𝑥𝑖𝑖+1 = 6 −6
𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1
for 𝑖𝑖 = 2, 3, … , 𝑛𝑛
• When above equation is to be written for all interior
knots, 𝑛𝑛 − 1 simultaneous equations result with
𝑛𝑛 + 1 unknown second derivatives. However, because
this is a natural cubic spline, the second derivatives at the
end knots are zero and the problem reduces to (𝑛𝑛 −
1) equations with 𝑛𝑛 − 1 unknowns.
• In addition, the system of equations will be tridiagonal.

46
Depiction of Cubic Spline

47
Suggested Readings
• S C Chapra & R P Canale, “Numerical Methods for
Engineers”, McGraw-Hill.
(https://drive.google.com/file/d/1C9w_yvfzXLlwNXi
QrGA1A_roN1H862wk/view?usp=sharing)
• Jaan Kiusalaas, “Numerical Methods in Engineering
With MATLAB”, Cambridge University Press.
(https://drive.google.com/file/d/1UtCk36Z18j5Kmsfj
Aeb_jDMCsqwqm3mf/view?usp=sharing)
• R L Burden, J D Faires & A M Burden, “Numerical
Analysis”, Cengage Learning.
(https://drive.google.com/file/d/1XfwSj1HhhZXWdO
TT_0ZA_ng_SNraIuJb/view?usp=sharing)

48
Thanks

49

You might also like