Chapter 15 Curve Fitting : Splines

Slides:



Advertisements
Similar presentations
Splines and Piecewise Interpolation
Advertisements

Numerical Methods.  Polynomial interpolation involves finding a polynomial of order n that passes through the n+1 points.  Several methods to obtain.
CS 445/645 Fall 2001 Hermite and Bézier Splines. Specifying Curves Control Points –A set of points that influence the curve’s shape Knots –Control points.
Selected from presentations by Jim Ramsay, McGill University, Hongliang Fei, and Brian Quanz Basis Basics.
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 Chapter 4 Interpolation and Approximation Lagrange Interpolation The basic interpolation problem can be posed in one of two ways: The basic interpolation.
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.
1Notes  Assignment 0 is due today!  To get better feel for splines, play with formulas in MATLAB!
Curve-Fitting Interpolation
1cs426-winter-2008 Notes  Ian Mitchell is running a MATLAB tutorial, Tuesday January 15, 5pm-7pm, DMP 110 We won’t be directly using MATLAB in this course,
Engineering Computation Curve Fitting: Interpolation 1
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 23 CURVE FITTING Chapter 18 Function Interpolation and Approximation.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 24 Regression Analysis-Chapter 17.
ECIV 301 Programming & Graphics Numerical Methods for Engineers REVIEW II.
Lecture 9 Interpolation and Splines. Lingo Interpolation – filling in gaps in data Find a function f(x) that 1) goes through all your data points 2) does.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Interpolation Chapter 18.
Bezier and Spline Curves and Surfaces CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Chapter 6 Numerical Interpolation
CpE- 310B Engineering Computation and Simulation Dr. Manal Al-Bzoor
Scientific Computing Linear and Quadratic Splines.
Curves.
1 Interpolation. 2 What is Interpolation ? Given (x 0,y 0 ), (x 1,y 1 ), …… (x n,y n ), find the value of ‘y’ at a.
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.
Chapter 14 Curve Fitting : Polynomial Interpolation Gab Byung Chae.
Interpolation.
CS559: Computer Graphics Lecture 19: Curves Li Zhang Spring 2008.
Computers in Civil Engineering 53:081 Spring 2003 Lecture #15 Spline Interpolation.
Jump to first page Chapter 3 Splines Definition (3.1) : Given a function f defined on [a, b] and a set of numbers, a = x 0 < x 1 < x 2 < ……. < x n = b,
Introduction to Numerical Analysis I MATH/CMPSC 455 Splines.
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-
Cubic Spline Interpolation. Cubic Splines attempt to solve the problem of the smoothness of a graph as well as reduce error. Polynomial interpolation.
Spline Interpolation A Primer on the Basics by Don Allen.
Table of Contents First get all nonzero terms on one side. Quadratic Equation: Solving by factoring Example: Solve 6x 2 – 13x = 8. 6x 2 – 13x – 8 = 0 Second.
2.1 – Linear and Quadratic Equations Linear Equations.
 3.3 Hermite Interpolation Chapter 3 Interpolation and Polynomial Approximation -- Hermite Interpolation Find the osculating polynomial P(x) such that.
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.
1 Chapter 4 Interpolation and Approximation Lagrange Interpolation The basic interpolation problem can be posed in one of two ways: The basic interpolation.
Curves University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
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.
CSCI480/582 Lecture 9 Chap.2.2 Cubic Splines – Hermit and Bezier Feb, 11, 2009.
Computational Methods CMSC/AMSC/MAPL 460 Polynomial Interpolation Ramani Duraiswami, Dept. of Computer Science.
Part 7 - Chapter 25.
EEE 244-7: Curve Fitting.
Chapter 10-2: Curves.
Curve-Fitting Spline Interpolation
Numerical Analysis Lecture 25.
Interpolation.
Ordinary Differential Equations
Interpolation Methods
Spline Interpolation Class XVII.
Part 7 - Chapter 25.
Splines and Piecewise Interpolation
Interpolation Methods
Topic/ Objective: To evaluate and graph piecewise and step functions.
MATH 174: Numerical Analysis I
Splines There are cases where polynomial interpolation is bad
SKTN 2393 Numerical Methods for Nuclear Engineers
INTERPOLATION For both irregulary spaced and evenly spaced data.
SKTN 2393 Numerical Methods for Nuclear Engineers
Theory of Approximation: Interpolation
Presentation transcript:

Chapter 15 Curve Fitting : Splines Gab Byung Chae

Oscillation in a higher order interpolation

The alternative : spline

Notation used to derive splines n-1 intervals in n data points

Splines in 1st, 2nd, 3rd order Linear spline Quadratic spline Cubic spline

15.2 Linear Splines linear splines passing thru Example : (3,2.5),(4.5,1),(7,2.5),(9,.5) -> (5,?)

15.3 Quadratic Splines The objective in quadratic splines is to derive a second-order polynomial for each interval between data points The polynomial : si(x) =ai + bi(x-xi)+ ci(x-xi)2 For n data points, there are n-1 intervals and, consequently, 3(n-1) unknown constants to evaluate.  3(n-1) equations or conditions are required to evaluate the unknowns.

Let for all i=1,,..,n-1 1. Continuity condition : the function must pass through all the points. --- (15.6) for all i=1,,..,n-1 : (n-1) equations 2. The function values of adjacent polynomials must be equal at the knots. --- (15.8) for all i=1,,..,n-1 : (n-1) equations

Let for all i=1,,..,n-1 3. The first derivatives at the interior nodes must be equal. (n-2) eq.s --- (15.9) 4. Assume that the second derivative is zero at the first point. 1 equation Example : (3,2.5),(4.5,1),(7,2.5),(9,.5) -> (5,?)

Example 15.2 Problem] Fit quadratic splines to the data in Table 15.1. Use the results to estimate the value at x=5.

Equation (15.9) creates 2 conditions with Solution] Equation (15.8) is written for i=1 through 3 (with c1=0) to give f1+ b1h1 = f2 f2+ b2h2 + c2h22 = f3 f3+ b3h3 + c3h32 = f4 Equation (15.9) creates 2 conditions with c1=0 : b1 = b2 b2+ 2c2h2 = b3

f1 = 2.5 h1 = 4.5-3.0 = 1.5 f2 = 1.0 h2 = 7.0-4.5 = 2.5 f3 = 2.5 h3 = 9.0-7.0 = 2.0 f4 = 0.5 2.5 + 1.5 b1 = 1.0 1.0 + 2.5 b2 + 6.25 c2 = 2.5 2.5 + 2.0 b3 + 4c3 = 0.5 b1 - b2 = 0 b2 - b3 + 5c2 = 0

b2 = -1 c2 = 0.64 b3= 2.2 c3 = -1.6 s1(x) = 2.5 –(x-3) s2(x) = 1.0 –(x-4.5)+0.64(x-4.5)2 s3(x) = 2.5 + 2.2(x-7.0)-1.6(5-7.0)2 x=5 이므로 s2(5) = 1.0 –(5-4.5)+0.64(5-4.5)2 =0.66

15.4 Cubic Splines a. (n-1) eq.s b. (n-1) eq.s c. (n-2) eq.s d. (n-2) eq.s e. 2 eq.s

Solving Cubic Splines

Example 15.3 Fit cubic splines to the data . Utilize the results to estimate the value at x =5

Solution : employ Eq.(15.27) f1 = 2.5 h1 = 4.5-3.0 = 1.5 f2 = 1.0 h2 = 7.0-4.5 = 2.5 f3 = 2.5 h3 = 9.0-7.0 = 2.0 f4 = 0.5

So we have Using MATLAB the results are c1 = 0 c2 = 0.839543726 c3 = -0.766539924 c4 = 0

Using Eq. (15.21) and (15.18), b1 = -1.419771863 d1 = 0.186565272 b2 = -0.160456274 d2 = -0.214144487 b3 = 0.022053232 d3 = 0.127756654

15.4.2 End Conditions Clamped End Condition : Specifying the first derivatives at the first and last nodes. Not-a-Knot End Condition : Force continuity of the third derivative at the second and the next-to-last knots. – same cubic functions will apply to each of the first and last two adjacent segments,

15.5 Piecewise interpolation in Matlab 15.5.1 MATLAB function : spline Syntax : yy = spline(x, y, xx)

Example 15.4 Splines in MATLAB Use MATLAB to fit 9 equally spaced data points sampled from this function in the interval [-1, 1]. a) a not-a-knot spline b) a clamped spline with end slopes of f1’=1 and f’n-1 = -4

Solution : a) >> x = linspace(-1,1,9); >> y = 1./(1+25*x.^2); >> xx = linspace(-1,1); >> yy = spline(x,y,xx); >> yr = 1./(1+25*xx.^2); >> plot(x,y,’o’,xx,yy,xx,yr,’—’)

Cubic spline of the Runge function

b) >> yc =[1 y -4]; >> yyc =spline(x,yx,xx); >> plot(x,y,’o’,xx,yyc,xx,yr,’—’)

15.5.2 MATLAB function : interp1 Implement a number of different types of piecewise one-dimensional interpolation. Syntax : yi = interp1(x,y,xi, ‘method’) yi = a vector containing the results of the interpolation as evaluated at the points in the vector xi , and ‘method’ = the desired method.

method Nearest – nearest neighbor interpolation. Linear – linear interpolation Spline – piecewise cubic spline interpolation(identical to the spline function) pchip and cubic – piecewise cubic Hermite interpolation. The default is linear.

MATLAB’s methods >> yy=spline(x,y,xx); cubic spilne >> yy=interp1(x,y,xx): (piecewise) linear spline >> yy=interp1(x,y,xx,’spline’): cubic spline >> yy=interp1(x,y,xx,’nearest’) : nearest neighbor method >> yy=interp1(x,y,xx,’pchip’): piecewise cubic Hermite interpolation >> zz=interp2(x,y,z,xx,yy): 2 dimensional interpolation

Example 15.5 Trade-offs Using interpl Linear, nearest, cubic spline, piecewise cubic Hermite interpolation

>> t = [ 0 20 40 56 68 80 84 96 104 110]; >> v = [0 20 20 38 80 80 100 100 125 125]; >> tt = linspace(0,110); >> vl=interp1(t,v,tt); %(piecewise) linear spline >> plot(t,v,’o’,tt,vl) >> vn=interp1(t,v,tt,’nearest’); % nearest >> plot(t,v,’o’,tt,vn) >> vs=interp1(t,v,tt,’spline’); % cubic spline >> plot(t,v,’o’,tt,vs) >> vh=interp1(t,v,tt,’pchip’); % piecewise cubic Hermite interpolation >> plot(t,v,’o’,tt,vh)