Splines and Piecewise Interpolation

Slides:



Advertisements
Similar presentations
Mark Trew CT Halfway Down Halfway down the stairs Is a stair Where I sit. There isn't any Other stair Quite like It. I'm not at the bottom, I'm.
Advertisements

Part 2 Chapter 6 Roots: Open Methods
Part 2 Chapter 6 Roots: Open Methods
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Curve Fitting ~ Least Squares Regression Chapter.
Roots: Bracketing Methods
Numerical Methods.  Polynomial interpolation involves finding a polynomial of order n that passes through the n+1 points.  Several methods to obtain.
Part 5 Chapter 19 Numerical Differentiation PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill.
MATH 685/ CSI 700/ OR 682 Lecture Notes
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Chapter 18 Interpolation The Islamic University of Gaza
1 Curve-Fitting Spline Interpolation. 2 Curve Fitting Regression Linear Regression Polynomial Regression Multiple Linear Regression Non-linear Regression.
CITS2401 Computer Analysis & Visualisation
Curve Fitting: Splines
Computational Methods in Physics PHYS 3437
ES 240: Scientific and Engineering Computation. InterpolationPolynomial  Definition –a function f(x) that can be written as a finite series of power functions.
Curve-Fitting Interpolation
Part 6 Chapter 22 Boundary-Value Problems PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill.
General Linear Least-Squares and Nonlinear Regression
Part 4 Chapter 13 Linear Regression
Polynomial Interpolation
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 181 Interpolation Chapter 18 Estimation of intermediate.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 23 CURVE FITTING Chapter 18 Function Interpolation and Approximation.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 181 Interpolation.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Interpolation Chapter 18.
Chapter 6 Numerical Interpolation
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 171 Least.
Numerical Integration Formulas
CMPS1371 Introduction to Computing for Engineers NUMERICAL METHODS.
Part 2 Chapter 7 Optimization
Curve Fitting and Interpolation: Lecture (I)
Part 3 Chapter 11 Matrix Inverse and Condition PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Applied Numerical Methods With MATLAB ® for Engineers.
Part 4 Chapter 17 Polynomial Interpolation PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill.
Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1.
Polynomial Interpolation You will frequently have occasions to estimate intermediate values between precise data points. The function you use to interpolate.
Part 2 Chapter 5 Roots: Bracketing Methods PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill.
Computers in Civil Engineering 53:081 Spring 2003 Lecture #15 Spline Interpolation.
Mohiuddin Ahmad SUNG-BONG JANG Interpolation II (8.4 SPLINE INTERPOLATION) (8.5 MATLAB’s INTERPOLATION Functions)
L5 – Curves in GIS NGEN06 & TEK230: Algorithms in Geographical Information Systems by: Sadegh Jamali (source: Lecture notes in GIS, Lars Harrie) 1 L5-
Spline Interpolation A Primer on the Basics by Don Allen.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Chapter 15 General Least Squares and Non- Linear.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Chapter 17 and 18 Interpolation.
Interpolation - Introduction
Lecture 29: Modeling Data. Data Modeling Interpolate between data points, using either linear or cubic spline models Model a set of data points as a polynomial.
Part 3 Chapter 9 Gauss Elimination
Linear Algebraic Equations and Matrices
Polynomial Interpolation
Curve-Fitting Spline Interpolation
Matrix Inverse and Condition
Numerical Analysis Lecture 25.
Interpolation Estimation of intermediate values between precise data points. The most common method is: Although there is one and only one nth-order.
Chapter 18.
Interpolation Methods
Boundary-Value Problems
Chapter 15 Curve Fitting : Splines
Numerical Integration Formulas
Numerical Differentiation
Part 2 Chapter 6 Roots: Open Methods
Chapter 18.
Spline Interpolation Class XVII.
General Linear Least-Squares and Nonlinear Regression
Splines and Piecewise Interpolation
Interpolation Methods
Roots: Bracketing Methods
Splines There are cases where polynomial interpolation is bad
SKTN 2393 Numerical Methods for Nuclear Engineers
Roots: Bracketing Methods
Part 2 Chapter 7 Optimization
Part 2 Chapter 6 Roots: Open Methods
Presentation transcript:

Splines and Piecewise Interpolation Part 4 Chapter 16 Splines and Piecewise Interpolation PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Chapter Objectives Understanding that splines minimize oscillations by fitting lower-order polynomials to data in a piecewise fashion. Knowing how to develop code to perform table lookup. Recognizing why cubic polynomials are preferable to quadratic and higher-order splines. Understanding the conditions that underlie a cubic fit. Understanding the differences between natural, clamped, and not-a-knot end conditions. Knowing how to fit a spline to data with MATLAB’s built-in functions. Understanding how multidimensional interpolation is implemented with MATLAB.

Introduction to Splines An alternative approach to using a single (n-1)th order polynomial to interpolate between n points is to apply lower-order polynomials in a piecewise fashion to subsets of data points. These connecting polynomials are called spline functions. Splines minimize oscillations and reduce round-off error due to their lower-order nature.

Higher Order vs. Splines Splines eliminate oscillations by using small subsets of points for each interval rather than every point. This is especially useful when there are jumps in the data: 3rd order polynomial 5th order polynomial 7th order polynomial Linear spline seven 1st order polynomials generated by using pairs of points at a time

Spline Development Spline function (si(x))coefficients are calculated for each interval of a data set. The number of data points (fi) used for each spline function depends on the order of the spline function.

Spline Development First-order splines find straight-line equations between each pair of points that Go through the points Second-order splines find quadratic equations between each pair of points that Match first derivatives at the interior points Third-order splines find cubic equations between each pair of points that Match first and second derivatives at the interior points Note that the results of cubic spline interpolation are different from the results of an interpolating cubic.

Cubic Splines While data of a particular size presents many options for the order of spline functions, cubic splines are preferred because they provide the simplest representation that exhibits the desired appearance of smoothness. Linear splines have discontinuous first derivatives Quadratic splines have discontinuous second derivatives and require setting the second derivative at some point to a pre-determined value *but* Quartic or higher-order splines tend to exhibit the instabilities inherent in higher order polynomials (ill-conditioning or oscillations)

Cubic Splines (cont) In general, the ith spline function for a cubic spline can be written as: For n data points, there are n-1 intervals and thus 4(n-1) unknowns to evaluate to solve all the spline function coefficients.

Solving Spline Coefficients One condition requires that the spline function goes through the first and last point of the interval, yielding 2(n-1) equations of the form: Another requires that the first derivative is continuous at each interior point, yielding n-2 equations of the form: A third requires that the second derivative is continuous at each interior point, yielding n-2 equations of the form: These give 4n-6 total equations and 4n-4 are needed!

Two Additional Equations There are several options for the final two equations: Natural end conditions - assume the second derivative at the end knots are zero. Clamped end conditions - assume the first derivatives at the first and last knots are known. “Not-a-knot” end conditions - force continuity of the third derivative at the second and penultimate points (results in the first two intervals having the same spline function and the last two intervals having the same spline function)

Piecewise Interpolation in MATLAB MATLAB has several built-in functions to implement piecewise interpolation. The first is spline: yy=spline(x, y, xx) This performs cubic spline interpolation, generally using not-a-knot conditions. If y contains two more values than x has entries, then the first and last value in y are used as the derivatives at the end points (i.e. clamped)

Not-a-knot Example Generate data: x = linspace(-1, 1, 9); y = 1./(1+25*x.^2); Calculate 100 model points and determine not-a-knot interpolation xx = linspace(-1, 1); yy = spline(x, y, xx); Calculate actual function values at model points and data points, the 9-point not-a-knot interpolation (solid), and the actual function (dashed), yr = 1./(1+25*xx.^2) plot(x, y, ‘o’, xx, yy, ‘-’, xx, yr, ‘--’)

Clamped Example Generate data w/ first derivative information: x = linspace(-1, 1, 9); y = 1./(1+25*x.^2); yc = [1 y -4] Calculate 100 model points and determine not-a-knot interpolation xx = linspace(-1, 1); yyc = spline(x, yc, xx); Calculate actual function values at model points and data points, the 9-point clamped interpolation (solid), and the actual function (dashed), yr = 1./(1+25*xx.^2) plot(x, y, ‘o’, xx, yyc, ‘-’, xx, yr, ‘--’)

MATLAB’s interp1 Function While spline can only perform cubic splines, MATLAB’s interp1 function can perform several different kinds of interpolation: yi = interp1(x, y, xi, ‘method’) x & y contain the original data xi contains the points at which to interpolate ‘method’ is a string containing the desired method: ‘nearest’ - nearest neighbor interpolation ‘linear’ - connects the points with straight lines ‘spline’ - not-a-knot cubic spline interpolation ‘pchip’ or ‘cubic’ - piecewise cubic Hermite interpolation

Piecewise Polynomial Comparisons

Multidimensional Interpolation The interpolation methods for one-dimensional problems can be extended to multidimensional interpolation. Example - bilinear interpolation using Lagrange-form equations:

Multidimensional Interpolation in MATLAB MATLAB has built-in functions for two- and three-dimensional piecewise interpolation: zi = interp2(x, y, z, xi, yi, ‘method’) vi = interp3(x, y, z, v, xi, yi, zi, ‘method’) ‘method’ is again a string containing the desired method: ‘nearest’, ‘linear’, ‘spline’, ‘pchip’, or ‘cubic’ For 2-D interpolation, the inputs must either be vectors or same-size matrices. For 3-D interpolation, the inputs must either be vectors or same-size 3-D arrays.