Piecewise Polynomial Interpolation

Similar documents
Piecewise Polynomial Interpolation

Global polynomial interpolants suffer from the Runge Phenomenon if the data sites (nodes) are not chosen correctly.

Numerical Methods I: Polynomial Interpolation

Cubic Splines MATH 375. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Cubic Splines

Engineering 7: Introduction to computer programming for scientists and engineers

1 Review of Interpolation using Cubic Splines

Numerical Methods I: Interpolation (cont ed)

Cubic Splines; Bézier Curves

SPLINE INTERPOLATION

Interpolation. Chapter Interpolation. 7.2 Existence, Uniqueness and conditioning

Interpolation Theory

Cubic Spline. s(x) = s j (x) = a j + b j (x x j ) + c j (x x j ) 2 + d j (x x j ) 3, j = 0,... n 1 (1)

Curve Fitting and Interpolation

1 Piecewise Cubic Interpolation

Outline. 1 Interpolation. 2 Polynomial Interpolation. 3 Piecewise Polynomial Interpolation

SYSTEMS OF NONLINEAR EQUATIONS

3.1 Interpolation and the Lagrange Polynomial

Lecture 10 Polynomial interpolation

Input: A set (x i -yy i ) data. Output: Function value at arbitrary point x. What for x = 1.2?

Lecture Note 3: Interpolation and Polynomial Approximation. Xiaoqun Zhang Shanghai Jiao Tong University

Chapter 3 Interpolation and Polynomial Approximation

CHAPTER 2 POLYNOMIALS KEY POINTS

Additional exercises with Numerieke Analyse

How fast can we add (or subtract) two numbers n and m?

Interpolation. 1. Judd, K. Numerical Methods in Economics, Cambridge: MIT Press. Chapter

Some notes on Chapter 8: Polynomial and Piecewise-polynomial Interpolation

1 Roots of polynomials

Chapter 4: Interpolation and Approximation. October 28, 2005

Solving Integral Equations by Petrov-Galerkin Method and Using Hermite-type 3 1 Elements

9.4 Cubic spline interpolation

Exam 2. Average: 85.6 Median: 87.0 Maximum: Minimum: 55.0 Standard Deviation: Numerical Methods Fall 2011 Lecture 20

MA2501 Numerical Methods Spring 2015

Applied Numerical Analysis Homework #3

Q 0 x if x 0 x x 1. S 1 x if x 1 x x 2. i 0,1,...,n 1, and L x L n 1 x if x n 1 x x n

Chapter 1 Numerical approximation of data : interpolation, least squares method

Finite Elements. Colin Cotter. January 18, Colin Cotter FEM

Jim Lambers MAT 460/560 Fall Semester Practice Final Exam

Lecture Note 3: Polynomial Interpolation. Xiaoqun Zhang Shanghai Jiao Tong University

There is a unique function s(x) that has the required properties. It turns out to also satisfy

G-SPLINE INTERPOLATION FOR APPROXIMATING THE SOLUTION OF FRACTIONAL DIFFERENTIAL EQUATIONS USING LINEAR MULTI- STEP METHODS

Section 0.2 & 0.3 Worksheet. Types of Functions

Scientific Computing

MATH ASSIGNMENT 07 SOLUTIONS. 8.1 Following is census data showing the population of the US between 1900 and 2000:

Advanced Math Quiz Review Name: Dec Use Synthetic Division to divide the first polynomial by the second polynomial.

Interpolation & Polynomial Approximation. Hermite Interpolation I

Polynomial Interpolation with n + 1 nodes

Lectures 9-10: Polynomial and piecewise polynomial interpolation

INTERPOLATION. and y i = cos x i, i = 0, 1, 2 This gives us the three points. Now find a quadratic polynomial. p(x) = a 0 + a 1 x + a 2 x 2.

Empirical Models Interpolation Polynomial Models

CONTROL POLYGONS FOR CUBIC CURVES

Curves. Hakan Bilen University of Edinburgh. Computer Graphics Fall Some slides are courtesy of Steve Marschner and Taku Komura

Polynomials 6c Classifying the Zeros of a Polynomial Functions

Numerical solution of nonlinear sine-gordon equation with local RBF-based finite difference collocation method

Preliminary Examination in Numerical Analysis

n 1 f n 1 c 1 n+1 = c 1 n $ c 1 n 1. After taking logs, this becomes

Vector Spaces and SubSpaces

Lagrange Interpolation and Neville s Algorithm. Ron Goldman Department of Computer Science Rice University

Outline. 1 Numerical Integration. 2 Numerical Differentiation. 3 Richardson Extrapolation

Maria Cameron Theoretical foundations. Let. be a partition of the interval [a, b].

Math Numerical Analysis Mid-Term Test Solutions

13 Path Planning Cubic Path P 2 P 1. θ 2

MTH5112 Linear Algebra I MTH5212 Applied Linear Algebra (2017/2018)

Table of contents. Polynomials Quadratic Functions Polynomials Graphs of Polynomials Polynomial Division Finding Roots of Polynomials

SMOOTH APPROXIMATION OF DATA WITH APPLICATIONS TO INTERPOLATING AND SMOOTHING. Karel Segeth Institute of Mathematics, Academy of Sciences, Prague

An Efficient Algorithm Based on Quadratic Spline Collocation and Finite Difference Methods for Parabolic Partial Differential Equations.

The highest degree term is x $, therefore the function is degree 4 (quartic) c) What are the x-intercepts?

Department of Applied Mathematics Preliminary Examination in Numerical Analysis August, 2013

ADDITONAL MATHEMATICS

x x2 2 + x3 3 x4 3. Use the divided-difference method to find a polynomial of least degree that fits the values shown: (b)

Data Analysis-I. Interpolation. Soon-Hyung Yook. December 4, Soon-Hyung Yook Data Analysis-I December 4, / 1

Math 578: Assignment 2

Linear Algebra, part 2 Eigenvalues, eigenvectors and least squares solutions

Edexcel GCE Further Pure Mathematics (FP1) Required Knowledge Information Sheet. Daniel Hammocks

Math 365 Homework 5 Due April 6, 2018 Grady Wright

Geometry of Phylogenetic Inference

Direct Learning: Linear Classification. Donglin Zeng, Department of Biostatistics, University of North Carolina

MATH 2360 REVIEW PROBLEMS

Section 3.2 Polynomial Functions and Their Graphs

Polynomials. p n (x) = a n x n + a n 1 x n 1 + a 1 x + a 0, where

Numerical solution of surface PDEs with Radial Basis Functions

CS 323: Numerical Analysis and Computing

Interpolation APPLIED PROBLEMS. Reading Between the Lines FLY ROCKET FLY, FLY ROCKET FLY WHAT IS INTERPOLATION? Figure Interpolation of discrete data.

U a C o & I & I b t - - -, _...

Keyframing. CS 448D: Character Animation Prof. Vladlen Koltun Stanford University

Radial Basis Functions I

CS412: Introduction to Numerical Methods

Polynomial approximation and Splines

Power Functions and Polynomial Functions

Applied Math 205. Full office hour schedule:

Numerical integration and differentiation. Unit IV. Numerical Integration and Differentiation. Plan of attack. Numerical integration.

2.2 BEGINS: POLYNOMIAL

Examination paper for TMA4215 Numerical Mathematics

Computing the Hausdorff Distance between Two B-Spline Curves. Zachi Shtain

Linear vector spaces and subspaces.

Numerical Analysis Preliminary Exam 10.00am 1.00pm, January 19, 2018

November 20, Interpolation, Extrapolation & Polynomial Approximation

Lecture 4: Piecewise Cubic Interpolation

Positive Definite Kernels: Opportunities and Challenges

Chapter I. Linear Equations

Regularization in Reproducing Kernel Banach Spaces

Transcription:

Piecewise Polynomial Interpolation 1

Piecewise linear interpolation Suppose we have data point (x k,y k ), k =0, 1,...N. A piecewise linear polynomial that interpolates these points is given by p(x) =p k (x), x 2 [x k,x k+1 ] where the polynomials p k (x) can be written as p k (x) =a 1 (x x k )+a 0, k =1, 2,...N 1 At this point, we could easily compute the coe cients a =[a 1,a 0 ], but let s go through a more general procedure that we can use for higher order piecewise polynomials. 2

Piecewise linear interpolation We can write this as a function of a local variable t which measures the distance along the interval. t = x x k x k+1 x k x = h k t + x k where h k = x k+1 x k. Then, for 0 apple t apple 1, we have p k (x) =ep k (t) =ea 1 t + ea 0 t =1 (x k+1,y k+1 ) t =0 Constraints to impose ep k (0) = y k (x k,y k ) 0 <t<1 ep k (1) = y k+1 3

Piecewise linear interpolation This leads to a linear system apple 0 1 1 1 apple ea1 ea 0 = apple yk y k+1 which we write as Aea = p. To solve for the coe we use the matrix co-factor C to get A 1 A 1 = CT det(a) = 1 det(a) apple 1 1 1 0 cients, We have det(a) = 1, and so ea = C T p 4

Piecewise linear interpolation To see what ep k (t) looks like, we let q(t) =[t, 1] and write ep k (t) = ea T q(t) = p T Cq(t) apple T = yk y k+1 1 1 1 0 apple t 1 The advantage of this form is that we can clearly see how the polynomial ep k (t) depends on our data y k and y k+1 : ep k (t) =(1 t)y k + ty k+1 5

Piecewise linear interpolation To build a spline in Matlab, we need to have the coefficients a 0 and a 1 of our original polynomial. p k (x) =a 1 (x x k )+a 0 We can recover these coe cients by substituting t = (x x k )/h k into ep k (t) =ea 1 t + ea 0 to get p k (x) =ea 1 x h k xk + ea 0 = a 1 (x x k )+a 0 where a 1 = ea 1 /h k and ea 0 = a 0. 6

Piecewise linear interpolation We can also write a =[a 1,a 0 ]using a = p T apple 1 1 CS = y k y k+1 1 0 " yk+1 y # k = h k y k apple 1/hk 0 0 1 These are exactly the coefficients that Matlab needs to build a spline using mkpp. function pp_linear = build_linear_spline(xdata,ydata)! N = length(xdata)-1;! h = diff(xdata); %(x1-x0, x2-x1, x3-x2,...)! C = [1-1; -1 0];! for k = 1:N,! p = [ydata(k); ydata(k+1)];! S = diag([1./h(k) 1]);! coeffs(k,:) = -p'*c*s;! end! pp_linear = mkpp(xdata,coeffs);! end 7

Piecewise linear interpolation (x 4,y 4 ) (x 0,y 0 ) (x 2,y 2 ) (x 5,y 5 ) 8

Piecewise linear interpolation Piecewise linear interpolation has these properties Continuous at nodes (x k,y k ). Derivatives are not continuous (the function is not smooth!) Can we come design a method that matches derivatives at the nodes as well? 9

Hermite interpolation We can impose smoothness at the nodes to get a nicer looking curve. Suppose we match the function values and derivatives. p(x k+1 )=y k+1 p 0 (x k+1 )=d k+1 This approach assumes that we have derivatives dk at each of the nodes xk. p(x k )=y k Four conditions allow us to find the four coefficients of a cubic polynomial p 0 (x k )=d k p k (x) =a 3 (x x k ) 3 + a 2 (x x k ) 2 + a 1 (x x k )+a 0 10

Hermite interpolation As before, define t = x x k x k+1 x k,! x = h k t + x k where h k = x k+1 x k. Then, for 0 apple t apple 1, we have p k (x) ep k (t) =ea 3 t 3 + ea 2 t 2 + ea 1 t + ea 0 and our four conditions become ep k (0) = y k ep k (1) = y k+1 ep 0 k (0) = d kh k ep 0 k (1) = d k+1h k 11

Hermite interpolation This leads to the following linear system for the coe cients ea n : We write the above system as Aea = p. To invert A, weusethe co-factor matrix C to get A 1 = CT det(a) See Strang s Introduction to Linear Algebra for more information on the co-factor formula for the matrix inverse. 12

Hermite interpolation We can then write ep k (t) as ep k (t) =ea T q(t) = p T Cq(t) where q(t) =[t 3,t 2,t,1] T and we have used the fact that det(a) = 1. Computing C, we get 2 3 2 2 3 0 1 t 3 ep k (t) = T y k y k+1 d k h k d k+1 h k 6 2 3 0 0 7 6 t 2 4 1 2 1 0 5 4 t 1 1 0 0 1 3 7 5 which leads to a formula that clearly shows how the polynomial depends on our data y k, y k+1, d k and d k+1 : ep k (t) = 1 t 2 (3 2t) y k + t 2 (3 2t) y k+1 + t(t 1) 2 h k d k + t 2 (t 1) h k d k+1 13

Piecewise Cubic Hermite Interpolating Polynomial (PCHIP) ep k (t) = 1 t 2 (3 2t) y k + t 2 (3 2t) y k+1 + t(t 1) 2 h k d k + t 2 (t 1) h k d k+1 x k )/h k, we can recover our original poly- If we substitute t =(x nomial in x : p k (x) =a 3 (x x k ) 3 + a 2 (x x k ) 2 + a 1 (x x k )+a 0 where a n = ea n /h n k. We can write these coe a = p T CS cients as These are exactly the coefficients that Matlab needs to build a spline using mkpp. where S = diag(h 3 k,h 2 k,h 1 k, 1), p =[y k,y k+1,d k h k,d k+1 h k ], and C is the co-factor matrix of our original coe cient matrix A. 14

The derivatives? Where do we get the derivatives d k from? If we know f(x), we can set d k = f 0 (x k ). We can approximate derivatives using data (x k,y k ). d k = G ( k 1, k), k = y k+1 y k h k where, for example, we could take G(a, b) = a+b 2, G(a, b) = a, G(a, b) = b or some other reasonable function. Matlab s PCHIP chooses derivatives to avoid introducing new extrema in the spline. We can impose additional smoothness conditions and solve implicitly for the derivatives. 15

Derivatives? Given data points (x 0,y 0 ),...,(x N,y N ), impose continuity in the second derivative at the interior nodes, p 00 k(x k+1 )=p 00 k+1(x k+1 ), k =1, 2,...N 1. We can formulate this as a linear expression F(d) =Bd + c =0 where B 2R (N+1) (N+1), c 2R (N+1) 1 and F(d) =0expresses the equality of the second derivative at the internal nodes, plus two additional constraints. Solving for d, we have d = B 1 c, d 2R N+1 16

End conditions? 17

Cubic spline 18

Periodic spline 19