SlideShare a Scribd company logo
1 of 17
MAN 547
Reverse Engineering in Mechanical Design
Dr. Mohamed Badran
Department of Mechanical Engineering
Spline Interpolation
MAN 547 Dr. Mohamed Badran 1
References
• Chapra, Steven C., and Canale, Raymond P.
“Numerical Methods for Engineers”, 5th edition,
McGraw Hill. Inc., 2006.
MAN 547 Dr. Mohamed Badran 2
Interpolation
• Employed to estimate intermediate values between precise data
points. Most common method : Polynomial interpolation
General formula for an nth-order polynomial:
f (x) =a0+a1x+a2x2+a3x3+ …….+anxn
For n+1 data points, there is one and only one polynomial of
order n that passes through all the points.
MAN 547 Dr. Mohamed Badran 3
Spline Interpolation
• There are cases where polynomials can lead to erroneous results
because of round off error and overshoot.
• Alternative approach is to apply lower-order polynomials to
subsets of data points. Such connecting polynomials are called
spline functions. e.g. 3rd order curves employed to connect each
pair of data points are called “ cubic splines”
MAN 547 Dr. Mohamed Badran 4
Spline Interpolation Vs. High order
interpolation polynomial
• When a function includes an abrupt change in values, e.g. the step
function, higher order curve fitting introduces wiggles known as
“spatial oscillations”
MAN 547 Dr. Mohamed Badran 5
Linear Splines
• First order splines connect each 2 successive points with a
straight line, i.e.:
These equations can be used to evaluate the function at any point
between x0 and xn by first locating the interval within which the point
lies. Then the appropriate equation is used to determine the function
value within the interval. Identical to linear interpolation
f(x) = f(x0) + m0 (x-x0), x0  x x1
f(x) = f(x1) + m1 (x-x1), x1  x x2 mi =
f x f x
x x
i i
i i
( ) ( )
( )




1
1
.... = ........................ is the slope of the
f(x) = f(xi) + mi (x-xi), xi  x xi+1 connecting line
….. = ………………
f(x) = f(xn-1) + mn-1 (x-xn-1), xn-1  x xn
MAN 547 Dr. Mohamed Badran 6
Example 1(18.8)*
Fit the data in the table below with first-order splines. Evaluate
the function at x=5.
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
x F(x)
3.0 2.5
4.5 1.0
7.0 2.5
9.0 0.5
MAN 547 Dr. Mohamed Badran 7
Example 1(18.8)*
continued
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
MAN 547 Dr. Mohamed Badran 8
Quadratic Splines
continued
• For each interval we derive a 2nd order polynomial:
fi(x) = ai x2 +bi x+ ci
• for (n+1) data points
( i = 0,1,2,..n) there are
n intervals, i.e. 3n unknown
coefficients (ai , bi ,ci )
MAN 547 Dr. Mohamed Badran 9
Quadratic Splines
The ( 3n) equations are:
1. function values equal at interior knots[i=1n-1] :
ai xi
2 + bi xi + ci = f(xi)
ai+1xi
2+bi+1xi + ci+1= f(xi) (2n-2) eqs (1)
2. first and last function pass through end pts:
a1x0
2 + b1x0 + c1 = f(x0)
anxn
2 + bn xn+ cn = f(xn) 2 eqns (2)
3. first derivative( fi(x) = 2 aix+bi) at interior knots[i=1n-1] are
equal:
2 aixi + bi = 2 ai+1 xi + bi+1 ( n-1) eqns (3)
4. an arbitrary choice, e.g. assume fi(xi) = 0 at first pt., hence:
f1(x0) = 2 a1 = 0  a1 = 0 (1 eqn.) (4)
which implies that first 2 pts are connected by straight line , which
is the natural spline condition.
MAN 547 Dr. Mohamed Badran 10
Example 2(18.9)*
Fit the data in the table below with quadratic splines. Evaluate the
function at x=5.
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
x F(x)
3.0 2.5
4.5 1.0
7.0 2.5
9.0 0.5
MAN 547 Dr. Mohamed Badran 11
Example 2(18.9)*
continued
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
MAN 547 Dr. Mohamed Badran 12
Cubic Splines
•For each interval we derive a 3rd order polynomial:
fi(x) = ai x3 +bi x2+ ci x + di
• for (n+1) data points ( i = 0,1,2,..n) there are n intervals,
4n unknown coefficients (ai , bi ,ci ,di)
The 4n equations are:
1. Function values are equal at interior knots = 2(n-1) equations
2. First and last functions pass through end points = 2 equations
3. First derivatives at interior knots must be equal = n-1 equations
4. Second derivatives at interior knots must be equal = n-1 equations
5. Second derivatives at the end knots are zero = 2 equations
(arbitrary)
4n equations
MAN 547 Dr. Mohamed Badran 13
Another method to derive Cubic Splines
Since 2nd derivative (f(x)= 6ai x+2bi) within each interval is a straight
line, it can be expressed by:
, for xi-1  x  xi
(1)
Integrating equation(1) twice to yield fi(x) and evaluating the 2 constants
of integration from the conditions:
fi(x) = f(xi-1) at x=xi-1 and fi(x)= f(xi) at x= xi
yields:
(2)
To determine the unknowns f(xi-1), f(xi) we invoke the condition that :
(3)
𝑓𝑖
′
𝑥𝑖 = 𝑓𝑖+1
′
𝑥𝑖
𝑓𝑖 𝑥 =
𝑓𝑖
′′
𝑥𝑖−1
6 𝑥𝑖 − 𝑥𝑖−1
𝑥𝑖 − 𝑥 3
+
𝑓𝑖
′′
𝑥𝑖
6 𝑥𝑖 − 𝑥𝑖−1
𝑥 − 𝑥𝑖−1
3
+
𝑓 𝑥𝑖−1
𝑥𝑖 − 𝑥𝑖−1
−
𝑓′′
𝑥𝑖−1 𝑥𝑖 − 𝑥𝑖−1
6
𝑥𝑖 − 𝑥
+
𝑓 𝑥𝑖
𝑥𝑖 − 𝑥𝑖−1
−
𝑓′′
𝑥𝑖 𝑥𝑖 − 𝑥𝑖−1
6
𝑥−𝑥𝑖−1
𝑓𝑖
′′
𝑥 = 𝑓𝑖
′′
𝑥𝑖−1
𝑥 − 𝑥𝑖−1
𝑥𝑖−1 − 𝑥𝑖
+ 𝑓𝑖
′′
𝑥𝑖
𝑥 − 𝑥𝑖−1
𝑥𝑖 − 𝑥𝑖−1
MAN 547 Dr. Mohamed Badran 14
Another method to derive Cubic Splines
continued
Thus differentiating (2) w.r.t. x, for both fi and fi-1 and equating both
sides (i.e. eqn(3)), yields:
(4)
Equation (4) is expressed for all interior knots , giving (n-1)
simultaneous equations for :
f(xi), for i= 1 to (n-1), given f(x0) and f(xn).
The resulting set is TDM and hence is solved employing TDMA
Equation (2) can then be employed as the cubic spline interpolation
polynomial, to interpolate f(x) in any interval between x0 and xn.
𝑥𝑖 − 𝑥𝑖−1 𝑓′′
𝑥𝑖−1 + 2 𝑥𝑖+1 − 𝑥𝑖−1 𝑓′′
𝑥𝑖 + 𝑥𝑖+1 − 𝑥𝑖 𝑓′′
𝑥𝑖+1
=
6
𝑥𝑖+1 − 𝑥𝑖
𝑓 𝑥𝑖+1 − 𝑓 𝑥𝑖 +
6
𝑥𝑖 − 𝑥𝑖−1
𝑓 𝑥𝑖−1 − 𝑓 𝑥𝑖
MAN 547 Dr. Mohamed Badran 15
Example 3(18.10)*
Fit the data in the table below with cubic splines. Evaluate the
function at x=5.
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
x F(x)
3.0 2.5
4.5 1.0
7.0 2.5
9.0 0.5
MAN 547 Dr. Mohamed Badran 16
Example 3(18.10)*
continued
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
MAN 547 Dr. Mohamed Badran 17

More Related Content

Similar to MAN 547-Interpolation.pptx

Modul bimbingan add maths
Modul bimbingan add mathsModul bimbingan add maths
Modul bimbingan add maths
Sasi Villa
 
DirectionsUse what you have learned in this course to answer th.docx
DirectionsUse what you have learned in this course to answer th.docxDirectionsUse what you have learned in this course to answer th.docx
DirectionsUse what you have learned in this course to answer th.docx
kimberly691
 
MA3355-RANDOM PROCESSES AND LINEAR ALGEBRA-739353433-ECE-MA3355(RPLA) QUESTIO...
MA3355-RANDOM PROCESSES AND LINEAR ALGEBRA-739353433-ECE-MA3355(RPLA) QUESTIO...MA3355-RANDOM PROCESSES AND LINEAR ALGEBRA-739353433-ECE-MA3355(RPLA) QUESTIO...
MA3355-RANDOM PROCESSES AND LINEAR ALGEBRA-739353433-ECE-MA3355(RPLA) QUESTIO...
JayaPrakash167124
 

Similar to MAN 547-Interpolation.pptx (20)

Spline interpolation numerical methods presentation
Spline interpolation numerical methods presentationSpline interpolation numerical methods presentation
Spline interpolation numerical methods presentation
 
05_AJMS_16_18_RA.pdf
05_AJMS_16_18_RA.pdf05_AJMS_16_18_RA.pdf
05_AJMS_16_18_RA.pdf
 
05_AJMS_16_18_RA.pdf
05_AJMS_16_18_RA.pdf05_AJMS_16_18_RA.pdf
05_AJMS_16_18_RA.pdf
 
Comparison Results of Trapezoidal, Simpson’s 13 rule, Simpson’s 38 rule, and ...
Comparison Results of Trapezoidal, Simpson’s 13 rule, Simpson’s 38 rule, and ...Comparison Results of Trapezoidal, Simpson’s 13 rule, Simpson’s 38 rule, and ...
Comparison Results of Trapezoidal, Simpson’s 13 rule, Simpson’s 38 rule, and ...
 
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
 
Bisection method
Bisection methodBisection method
Bisection method
 
AppsDiff3c.pdf
AppsDiff3c.pdfAppsDiff3c.pdf
AppsDiff3c.pdf
 
Numerical Methods and Applied Statistics Paper (RTU VI Semester)
Numerical Methods and Applied Statistics Paper (RTU VI Semester)Numerical Methods and Applied Statistics Paper (RTU VI Semester)
Numerical Methods and Applied Statistics Paper (RTU VI Semester)
 
Mathematics 9 Quadratic Functions (Module 1)
Mathematics 9 Quadratic Functions (Module 1)Mathematics 9 Quadratic Functions (Module 1)
Mathematics 9 Quadratic Functions (Module 1)
 
Modul bimbingan add maths
Modul bimbingan add mathsModul bimbingan add maths
Modul bimbingan add maths
 
b
bb
b
 
DirectionsUse what you have learned in this course to answer th.docx
DirectionsUse what you have learned in this course to answer th.docxDirectionsUse what you have learned in this course to answer th.docx
DirectionsUse what you have learned in this course to answer th.docx
 
Optimization tutorial
Optimization tutorialOptimization tutorial
Optimization tutorial
 
Mathematics Assignment Help
Mathematics Assignment Help Mathematics Assignment Help
Mathematics Assignment Help
 
MA3355-RANDOM PROCESSES AND LINEAR ALGEBRA-739353433-ECE-MA3355(RPLA) QUESTIO...
MA3355-RANDOM PROCESSES AND LINEAR ALGEBRA-739353433-ECE-MA3355(RPLA) QUESTIO...MA3355-RANDOM PROCESSES AND LINEAR ALGEBRA-739353433-ECE-MA3355(RPLA) QUESTIO...
MA3355-RANDOM PROCESSES AND LINEAR ALGEBRA-739353433-ECE-MA3355(RPLA) QUESTIO...
 
Modeling quadratic fxns
Modeling quadratic fxnsModeling quadratic fxns
Modeling quadratic fxns
 
Numerical differentation with c
Numerical differentation with cNumerical differentation with c
Numerical differentation with c
 
False Point Method / Regula falsi method
False Point Method / Regula falsi methodFalse Point Method / Regula falsi method
False Point Method / Regula falsi method
 
Intro. to computational Physics ch2.pdf
Intro. to computational Physics ch2.pdfIntro. to computational Physics ch2.pdf
Intro. to computational Physics ch2.pdf
 
Fortran chapter 2.pdf
Fortran chapter 2.pdfFortran chapter 2.pdf
Fortran chapter 2.pdf
 

More from Ahmed Sobhi (17)

MAN 547_Reverse Engineering-Hardware and Software.pptx
MAN 547_Reverse Engineering-Hardware and Software.pptxMAN 547_Reverse Engineering-Hardware and Software.pptx
MAN 547_Reverse Engineering-Hardware and Software.pptx
 
4288904.pptx
4288904.pptx4288904.pptx
4288904.pptx
 
CMM
CMMCMM
CMM
 
Design
DesignDesign
Design
 
L01_IENG 202 - ORI - Intro.pptx
L01_IENG 202 - ORI - Intro.pptxL01_IENG 202 - ORI - Intro.pptx
L01_IENG 202 - ORI - Intro.pptx
 
Network flow
Network flowNetwork flow
Network flow
 
LOGISTIKE.pdf
LOGISTIKE.pdfLOGISTIKE.pdf
LOGISTIKE.pdf
 
4handling-part4-171025101141.pdf
4handling-part4-171025101141.pdf4handling-part4-171025101141.pdf
4handling-part4-171025101141.pdf
 
camsfollowers-190301142036.pdf
camsfollowers-190301142036.pdfcamsfollowers-190301142036.pdf
camsfollowers-190301142036.pdf
 
OR II.ppt
OR II.pptOR II.ppt
OR II.ppt
 
2nd lect CADCAM.pptx
2nd lect CADCAM.pptx2nd lect CADCAM.pptx
2nd lect CADCAM.pptx
 
7807139.ppt
7807139.ppt7807139.ppt
7807139.ppt
 
13675443.ppt
13675443.ppt13675443.ppt
13675443.ppt
 
Lect_03 Mechanisms Sp23.pdf
Lect_03 Mechanisms Sp23.pdfLect_03 Mechanisms Sp23.pdf
Lect_03 Mechanisms Sp23.pdf
 
6177233.ppt
6177233.ppt6177233.ppt
6177233.ppt
 
02_Ch(2)_Work Systems and How They Work.pptx
02_Ch(2)_Work Systems and How They Work.pptx02_Ch(2)_Work Systems and How They Work.pptx
02_Ch(2)_Work Systems and How They Work.pptx
 
03.ppt
03.ppt03.ppt
03.ppt
 

Recently uploaded

Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
AldoGarca30
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 

Recently uploaded (20)

Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 

MAN 547-Interpolation.pptx

  • 1. MAN 547 Reverse Engineering in Mechanical Design Dr. Mohamed Badran Department of Mechanical Engineering Spline Interpolation MAN 547 Dr. Mohamed Badran 1
  • 2. References • Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006. MAN 547 Dr. Mohamed Badran 2
  • 3. Interpolation • Employed to estimate intermediate values between precise data points. Most common method : Polynomial interpolation General formula for an nth-order polynomial: f (x) =a0+a1x+a2x2+a3x3+ …….+anxn For n+1 data points, there is one and only one polynomial of order n that passes through all the points. MAN 547 Dr. Mohamed Badran 3
  • 4. Spline Interpolation • There are cases where polynomials can lead to erroneous results because of round off error and overshoot. • Alternative approach is to apply lower-order polynomials to subsets of data points. Such connecting polynomials are called spline functions. e.g. 3rd order curves employed to connect each pair of data points are called “ cubic splines” MAN 547 Dr. Mohamed Badran 4
  • 5. Spline Interpolation Vs. High order interpolation polynomial • When a function includes an abrupt change in values, e.g. the step function, higher order curve fitting introduces wiggles known as “spatial oscillations” MAN 547 Dr. Mohamed Badran 5
  • 6. Linear Splines • First order splines connect each 2 successive points with a straight line, i.e.: These equations can be used to evaluate the function at any point between x0 and xn by first locating the interval within which the point lies. Then the appropriate equation is used to determine the function value within the interval. Identical to linear interpolation f(x) = f(x0) + m0 (x-x0), x0  x x1 f(x) = f(x1) + m1 (x-x1), x1  x x2 mi = f x f x x x i i i i ( ) ( ) ( )     1 1 .... = ........................ is the slope of the f(x) = f(xi) + mi (x-xi), xi  x xi+1 connecting line ….. = ……………… f(x) = f(xn-1) + mn-1 (x-xn-1), xn-1  x xn MAN 547 Dr. Mohamed Badran 6
  • 7. Example 1(18.8)* Fit the data in the table below with first-order splines. Evaluate the function at x=5. *Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006. x F(x) 3.0 2.5 4.5 1.0 7.0 2.5 9.0 0.5 MAN 547 Dr. Mohamed Badran 7
  • 8. Example 1(18.8)* continued *Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006. MAN 547 Dr. Mohamed Badran 8
  • 9. Quadratic Splines continued • For each interval we derive a 2nd order polynomial: fi(x) = ai x2 +bi x+ ci • for (n+1) data points ( i = 0,1,2,..n) there are n intervals, i.e. 3n unknown coefficients (ai , bi ,ci ) MAN 547 Dr. Mohamed Badran 9
  • 10. Quadratic Splines The ( 3n) equations are: 1. function values equal at interior knots[i=1n-1] : ai xi 2 + bi xi + ci = f(xi) ai+1xi 2+bi+1xi + ci+1= f(xi) (2n-2) eqs (1) 2. first and last function pass through end pts: a1x0 2 + b1x0 + c1 = f(x0) anxn 2 + bn xn+ cn = f(xn) 2 eqns (2) 3. first derivative( fi(x) = 2 aix+bi) at interior knots[i=1n-1] are equal: 2 aixi + bi = 2 ai+1 xi + bi+1 ( n-1) eqns (3) 4. an arbitrary choice, e.g. assume fi(xi) = 0 at first pt., hence: f1(x0) = 2 a1 = 0  a1 = 0 (1 eqn.) (4) which implies that first 2 pts are connected by straight line , which is the natural spline condition. MAN 547 Dr. Mohamed Badran 10
  • 11. Example 2(18.9)* Fit the data in the table below with quadratic splines. Evaluate the function at x=5. *Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006. x F(x) 3.0 2.5 4.5 1.0 7.0 2.5 9.0 0.5 MAN 547 Dr. Mohamed Badran 11
  • 12. Example 2(18.9)* continued *Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006. MAN 547 Dr. Mohamed Badran 12
  • 13. Cubic Splines •For each interval we derive a 3rd order polynomial: fi(x) = ai x3 +bi x2+ ci x + di • for (n+1) data points ( i = 0,1,2,..n) there are n intervals, 4n unknown coefficients (ai , bi ,ci ,di) The 4n equations are: 1. Function values are equal at interior knots = 2(n-1) equations 2. First and last functions pass through end points = 2 equations 3. First derivatives at interior knots must be equal = n-1 equations 4. Second derivatives at interior knots must be equal = n-1 equations 5. Second derivatives at the end knots are zero = 2 equations (arbitrary) 4n equations MAN 547 Dr. Mohamed Badran 13
  • 14. Another method to derive Cubic Splines Since 2nd derivative (f(x)= 6ai x+2bi) within each interval is a straight line, it can be expressed by: , for xi-1  x  xi (1) Integrating equation(1) twice to yield fi(x) and evaluating the 2 constants of integration from the conditions: fi(x) = f(xi-1) at x=xi-1 and fi(x)= f(xi) at x= xi yields: (2) To determine the unknowns f(xi-1), f(xi) we invoke the condition that : (3) 𝑓𝑖 ′ 𝑥𝑖 = 𝑓𝑖+1 ′ 𝑥𝑖 𝑓𝑖 𝑥 = 𝑓𝑖 ′′ 𝑥𝑖−1 6 𝑥𝑖 − 𝑥𝑖−1 𝑥𝑖 − 𝑥 3 + 𝑓𝑖 ′′ 𝑥𝑖 6 𝑥𝑖 − 𝑥𝑖−1 𝑥 − 𝑥𝑖−1 3 + 𝑓 𝑥𝑖−1 𝑥𝑖 − 𝑥𝑖−1 − 𝑓′′ 𝑥𝑖−1 𝑥𝑖 − 𝑥𝑖−1 6 𝑥𝑖 − 𝑥 + 𝑓 𝑥𝑖 𝑥𝑖 − 𝑥𝑖−1 − 𝑓′′ 𝑥𝑖 𝑥𝑖 − 𝑥𝑖−1 6 𝑥−𝑥𝑖−1 𝑓𝑖 ′′ 𝑥 = 𝑓𝑖 ′′ 𝑥𝑖−1 𝑥 − 𝑥𝑖−1 𝑥𝑖−1 − 𝑥𝑖 + 𝑓𝑖 ′′ 𝑥𝑖 𝑥 − 𝑥𝑖−1 𝑥𝑖 − 𝑥𝑖−1 MAN 547 Dr. Mohamed Badran 14
  • 15. Another method to derive Cubic Splines continued Thus differentiating (2) w.r.t. x, for both fi and fi-1 and equating both sides (i.e. eqn(3)), yields: (4) Equation (4) is expressed for all interior knots , giving (n-1) simultaneous equations for : f(xi), for i= 1 to (n-1), given f(x0) and f(xn). The resulting set is TDM and hence is solved employing TDMA Equation (2) can then be employed as the cubic spline interpolation polynomial, to interpolate f(x) in any interval between x0 and xn. 𝑥𝑖 − 𝑥𝑖−1 𝑓′′ 𝑥𝑖−1 + 2 𝑥𝑖+1 − 𝑥𝑖−1 𝑓′′ 𝑥𝑖 + 𝑥𝑖+1 − 𝑥𝑖 𝑓′′ 𝑥𝑖+1 = 6 𝑥𝑖+1 − 𝑥𝑖 𝑓 𝑥𝑖+1 − 𝑓 𝑥𝑖 + 6 𝑥𝑖 − 𝑥𝑖−1 𝑓 𝑥𝑖−1 − 𝑓 𝑥𝑖 MAN 547 Dr. Mohamed Badran 15
  • 16. Example 3(18.10)* Fit the data in the table below with cubic splines. Evaluate the function at x=5. *Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006. x F(x) 3.0 2.5 4.5 1.0 7.0 2.5 9.0 0.5 MAN 547 Dr. Mohamed Badran 16
  • 17. Example 3(18.10)* continued *Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006. MAN 547 Dr. Mohamed Badran 17