Interpolation. Escuela de Ingeniería Informática de Oviedo. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 1 / 34

Similar documents
Optimization. Escuela de Ingeniería Informática de Oviedo. (Dpto. de Matemáticas-UniOvi) Numerical Computation Optimization 1 / 30

Lecture 10 Polynomial interpolation

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

3.1 Interpolation and the Lagrange Polynomial

Scientific Computing: An Introductory Survey

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

Numerical Mathematics & Computing, 7 Ed. 4.1 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.

Introduction Linear system Nonlinear equation Interpolation

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

(0, 0), (1, ), (2, ), (3, ), (4, ), (5, ), (6, ).

A first order divided difference

1 Lecture 8: Interpolating polynomials.

Chapter 4: Interpolation and Approximation. October 28, 2005

Lectures 9-10: Polynomial and piecewise polynomial interpolation

Scientific Computing

Function approximation

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

Interpolation Theory

Neville s Method. MATH 375 Numerical Analysis. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Neville s Method

Q1. Discuss, compare and contrast various curve fitting and interpolation methods

UNIT-II INTERPOLATION & APPROXIMATION

Interpolation and extrapolation

Curve Fitting and Interpolation

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

Chapter 2 Interpolation

1 Piecewise Cubic Interpolation

CS 323: Numerical Analysis and Computing

Applied Numerical Analysis Quiz #2

Numerical Methods I: Interpolation (cont ed)

SPLINE INTERPOLATION

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

Cubic Splines; Bézier Curves

Geometric Interpolation by Planar Cubic Polynomials

Numerical Methods I: Polynomial Interpolation

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

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

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

GENG2140, S2, 2012 Week 7: Curve fitting

BSM510 Numerical Analysis

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

Convergence rates of derivatives of a family of barycentric rational interpolants

Mathematics for Engineers. Numerical mathematics

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

Jim Lambers MAT 460/560 Fall Semester Practice Final Exam

MAT300/500 Programming Project Spring 2019

CS 323: Numerical Analysis and Computing

Empirical Models Interpolation Polynomial Models

Interpolation. Chapter Interpolation. 7.2 Existence, Uniqueness and conditioning

We consider the problem of finding a polynomial that interpolates a given set of values:

CS 450 Numerical Analysis. Chapter 8: Numerical Integration and Differentiation

Two hours. To be provided by Examinations Office: Mathematical Formula Tables. THE UNIVERSITY OF MANCHESTER. 29 May :45 11:45

INTERPOLATION Background Polynomial Approximation Problem:

Numerical Marine Hydrodynamics

Math 365 Homework 5 Due April 6, 2018 Grady Wright

November 20, Interpolation, Extrapolation & Polynomial Approximation

Computational Physics

Engineering 7: Introduction to computer programming for scientists and engineers

CHAPTER 4. Interpolation

CS412: Introduction to Numerical Methods

Applied Numerical Analysis (AE2220-I) R. Klees and R.P. Dwight

Integration, differentiation, and root finding. Phys 420/580 Lecture 7

Motivation Subgradient Method Stochastic Subgradient Method. Convex Optimization. Lecture 15 - Gradient Descent in Machine Learning

Chapter 3 Interpolation and Polynomial Approximation

MA3232 Summary 5. d y1 dy1. MATLAB has a number of built-in functions for solving stiff systems of ODEs. There are ode15s, ode23s, ode23t, ode23tb.

Non-polynomial Least-squares fitting

The Normal Equations. For A R m n with m > n, A T A is singular if and only if A is rank-deficient. 1 Proof:

Numerical Integration (Quadrature) Another application for our interpolation tools!

Section 5.3 The Newton Form of the Interpolating Polynomial

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

Intro Polynomial Piecewise Cubic Spline Software Summary. Interpolation. Sanzheng Qiao. Department of Computing and Software McMaster University

Numerical Methods for Differential Equations Mathematical and Computational Tools

C O M P U L S O R Y R E A D I N G S 1

Hilbert-Huang and Morlet wavelet transformation

M2R IVR, October 12th Mathematical tools 1 - Session 2

Numerical Analysis: Interpolation Part 1

Preliminary Examination in Numerical Analysis

MA2501 Numerical Methods Spring 2015

Ay190 Computational Astrophysics

Fourier Reconstruction from Non-Uniform Spectral Data

Arsène Pérard-Gayot (Slides by Piotr Danilewski)

Polynomial Interpolation

Function Approximation

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

Examination paper for TMA4215 Numerical Mathematics

Lecture 6 September 21, 2016

1 Lecture 24: Linearization

Interpolation and Approximation

Interpolation and polynomial approximation Interpolation

University of Houston, Department of Mathematics Numerical Analysis, Fall 2005

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

Automatic Control Motion planning

Curve Fitting. Objectives

Numerical Methods in Physics and Astrophysics

PARTITION OF UNITY FOR THE STOKES PROBLEM ON NONMATCHING GRIDS

Interpolation Atkinson Chapter 3, Stoer & Bulirsch Chapter 2, Dahlquist & Bjork Chapter 4 Topics marked with are not on the exam

Introduction. Region of interest. Linear Lagrange Polynomials

Interpolation. s(s 1)(s 2) Δ 3 f ! s(s 1) Δ 2 f 0 + 2! f(x s )=f 0 + sδf 0 +

Name of the Student: Unit I (Solution of Equations and Eigenvalue Problems)

University of British Columbia Math 307, Final

Transcription:

Interpolation Escuela de Ingeniería Informática de Oviedo (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 1 / 34

Outline 1 Introduction 2 Lagrange interpolation 3 Piecewise polynomial interpolation (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 2 / 34

Introduction Outline 1 Introduction 2 Lagrange interpolation 3 Piecewise polynomial interpolation (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 3 / 34

Introduction Motivation Often, when solving mathematical problems, we need to get the value of a function in several points. But: it can be expensive in terms of processor use or machine time (for instance, a complicated function which we need to evaluate many times). possibly, we only have the function values in few points (for instance, if they come from data trials). A possible solution is to replace the complicated function by another similar but simpler to evaluate. These simpler functions are polynomials, trigonometric functions,... (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 4 / 34

Introduction Interpolation Data: n + 1 different points x 0, x 1,..., x n n + 1 values ω 0, ω 1,..., ω n Problem: Find a (simple) function f verifying f (x i ) = y i with i = 0, 1,..., n. Remarks: x 0, x 1,..., x n are called interpolation nodes ω 0, ω 1,..., ω n can be the values of a function f in the nodes: ω i = f (x i ) i = 0, 1,..., n (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 5 / 34

Introduction Example Here, f P 5 is a polynomial of degree 5: (x i,ω i ) P 5 (x 4,ω 4 ) (x 2,ω 2 ) (x 0,ω 0 ) (x 1,ω 1 ) (x 3,ω 3 ) (x 5,ω 5 ) (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 6 / 34

Introduction Polynomial interpolation If f is a polynomial or a piecewise polynomial function we speak of polynomic interpolation. Main examples: 1 Lagrange interpolation. 2 Piecewise polynomial interpolation. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 7 / 34

Lagrange interpolation Outline 1 Introduction 2 Lagrange interpolation 3 Piecewise polynomial interpolation (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 8 / 34

Lagrange interpolation Lagrange interpolation Data: n + 1 different points x 0, x 1,..., x n n + 1 values ω 0, ω 1,..., ω n Problem: We seek for a polynomial P n of degree at most n verifying P n (x 0 ) = ω 0 P n (x 1 ) = ω 1 P n (x 2 ) = ω 2... P (n) n (x n ) = ω n (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 9 / 34

Lagrange interpolation Lagrange linear interpolation (n = 1) Data: 2 different points x 0, x 1 2 values ω 0, ω 1 Problem: Find a polynomial P n of degree at most 1 verifying P 1 (x 0 ) = ω 0 P 1 (x 1 ) = ω 1 y = P 1 (x) is the straight line joining (x 0, ω 0 ) and (x 1, ω 1 ) P 1 (x) = ω 0 + ω 1 ω 0 x 1 x 0 (x 1 x 0 ) (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 10 / 34

Lagrange interpolation Lagrange interpolation (for any n) Problem: Find a polynomial satisfying P n (x) = a 0 + a 1 x + a 2 x 2 + + a n x n P n (x 0 ) = ω 0 P n (x 1 ) = ω 1 P n (x 2 ) = ω 2... P n (x n ) = ω n (1) Conditions (1) imply that coefficients solve 1 x 0 x0 2 x n 0 1 x 1 x1 2 x1 n....... 1 x n xn 2 xn n a 0 a 1. a n = ω 0 ω 1. ω n (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 11 / 34

Lagrange interpolation The coefficient matrix is of Vandermonde type: 1 x 0 x0 2 x0 n 1 x 1 x1 2 x1 n A =....... 1 x n xn 2 xn n, with det (A) = 0 l k n (x k x l ) 0. Therefore, the system has a unique solution which determines P n. P n is the Lagrange interpolation polynomial at x 0, x 1,..., x n relative to the values ω 0, ω 1,..., ω n. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 12 / 34

Lagrange interpolation An example of Lagrange interpolation (x i,ω i ) P 1 (x) (x i,ω i ) P 2 (x) (x i,ω i ) P 3 (x) (x i,ω i ) P 4 (x) (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 13 / 34

Lagrange interpolation Computing the Lagrange s interpolation polynomial Computing the Lagrange s interpolation polynomial Motivation: Solving the Vandermonde system of equations is not efficient and large errors may arise due to bad conditioning. Two ways of computing: Using fundamental Lagrange polynomials. Using divided differences. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 14 / 34

Lagrange interpolation Computing the Lagrange s interpolation polynomial Fundamental Lagrange polynomials Fundamental polynomials: For each i = 0, 1,..., n there exists an unique polynomial l i of degree at most n such that l i (x k ) = δ ik (zero if i k, one if i = k): l i (x) = n j = 0 j i x x j x i x j, l 0, l 1,..., l n are the fundamental Lagrange polynomials of degree n. Lagrange formula: Lagrange s polynomial at x 0, x 1,..., x n relative to ω 0, ω 1,..., ω n is P n (x) = ω 0 l 0 (x) + ω 1 l 1 (x) + + ω n l n (x). Remark: If we want to add new nodes, we need to re-compute all the fundamental polynomials. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 15 / 34

Lagrange interpolation Computing the Lagrange s interpolation polynomial Example 3 2 1 0 1 l 0 (x) 2 0 1 2 3 4 3 2 1 0 1 l 1 (x) 2 0 1 2 3 4 3 2 1 0 1 l 2 (x) 2 0 1 2 3 4 3 2 1 0 1 ω 0 l 0 (x) 2 0 1 2 3 4 3 2 1 0 1 ω 1 l 1 (x) 2 0 1 2 3 4 3 2 1 0 1 ω 2 l 2 (x) 2 0 1 2 3 4 3 2 1 0 1 P 2 (x) 2 0 1 2 3 4 (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 16 / 34

Lagrange interpolation Computing the Lagrange s interpolation polynomial Divided differences Divided differences of 0-order [ω i ] = ω i, i = 0, 1,..., n. Divided differences of order 1 Divided differences of order 2 [ω i, ω i+1 ] = ω i+1 ω i x i+1 x i, i = 0, 1,..., n 1. [ω i, ω i+1, ω i+2 ] = [ω i+1, ω i+2 ] [ω i, ω i+1 ] x i+2 x i, i = 0, 1,..., n 2. Divided differences of order k (k = 1,..., n) [ω i, ω i+1,..., ω i+k ] = [ω i+1,..., ω i+k ] [ω i, ω i+1,..., ω i+k 1 ] x i+k x i, i = 0, 1,..., n k. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 17 / 34

Lagrange interpolation Computing the Lagrange s interpolation polynomial Newton s formula: Lagrange polynomial at x 0, x 1,..., x n relative to ω 0, ω 1,..., ω n is P n (x) = [ω 0 ] + [ω 0, ω 1 ] (x x 0 ) + [ω 0, ω 1, ω 2 ] (x x 0 ) (x x 1 ) + + + [ω 0, ω 1,..., ω n ] (x x 0 ) (x x 1 ) (x x n 1 ). Consequence: P 0, P 1,..., P n may be computed recursively, adding in each iteration a new term, P n (x) = P n 1 (x) + [ω 0, ω 1,..., ω n ] (x x 0 ) (x x 1 ) (x x n 1 ). Notation: If ω i = f (x i ), with i = 0, 1,..., n, f [x i,..., x i+k ] = [ω i,..., ω i+k ]. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 18 / 34

Example Lagrange interpolation Computing the Lagrange s interpolation polynomial P 1 (x) P 2 (x) P 3 (x) P 4 (x) (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 19 / 34

Error Lagrange interpolation Error Hypothesis: f : [a, b] R is n + 1 times differentiable in [a, b] with continuous derivatives. x 0, x 1,..., x n [a, b]. ω i = f (x i ) for i = 0, 1,..., n. Error estimate: The absolute error satisfies f (x) P n (x) sup f (n+1) (y) (x x 0) (x x 1 ) (x x n ). (n + 1)! y [a,b] (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 20 / 34

Piecewise polynomial interpolation Outline 1 Introduction 2 Lagrange interpolation 3 Piecewise polynomial interpolation (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 21 / 34

Piecewise polynomial interpolation Piecewise polynomial interpolation Motivation: If we increase the number of nodes The Lagrange s interpolation polynomial degree increases as well, generating oscillations. Often, when increasing the number of nodes the error also increases (not intuitive). Estrategy: Use low degree piecewise polynomials. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 22 / 34

Piecewise polynomial interpolation Example: oscillations of Lagrange polynomials e x2 (x i,ω i ) P 10 (x) (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 23 / 34

Piecewise polynomial interpolation Example: piecewise linear interpolation e x2 (x i,ω i ) s (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 24 / 34

Piecewise polynomial interpolation Constantwise polynomial interpolation Interpolation by degree zero piecewise polynomials is that in which the polynomials are constant between nodes. For instance, ω 0 if x [x 0, x 1 ), ω 1 if x [x 1, x 2 ), f (x) =... ω n 1 if x [x n 1, x n ), ω 0 if x = x n. Observe that if ω i ω i+1 then f is discontinuous at x i+1. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 25 / 34

Piecewise polynomial interpolation Linearwise polynomial interpolation The degree one piecewise polynomial interpolation is that in which the polynomials are straight lines joining two consecutive nodes, for i = 0,..., n 1. f (x) = ωi + (ω i+1 ω i ) x x i x i+1 x i if x [x i, x i+1 ], In this case, f is continuous, but its first derivative is, in general, discontinuous at the nodes. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 26 / 34

Piecewise polynomial interpolation Spline interpolation Data: n + 1 points x 0 < x 1 <... < x n. n + 1 values ω 0, ω 1,..., ω n. Problem: Interpolating by splines of order p (or degree p) consists on finding a function f such that: 1 f is p 1 times continuously differentiable in [x0, x n ]. 2 f is a piecewise function given by the polynomials f0, f 1,..., f n 1 defined, respectively, in [x 0, x 1 ], [x 1, x 2 ],..., [x n 1, x n ], and of degree lower or equal to p. 3 Interpolation condition: f 0 (x 0 ) = ω 0,..., f n (x n ) = ω n. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 27 / 34

Piecewise polynomial interpolation The problem has solution! Each solution f is called spline interpolator of order p at x 0, x 1,..., x n relative to ω 0, ω 1,..., ω n. The most used spline is that ot third order, known as cubic spline. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 28 / 34

Example Piecewise polynomial interpolation Cubic spline sin(x) Lineal Spline (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 29 / 34

Piecewise polynomial interpolation Cubic spline Cubic spline Definition: A Cubic spline is a function f such that 1 f is twice continuously differentiable in [x0, x n ]. 2 f0, f 1,..., f n 1 are of degree at most 3. 3 f (x0 ) = ω 0 f (x1 ) = ω 1... f (xn ) = ω n Remarks: In each sub-interval [x i, x i+1 ], the interpolant f is determined from the values of f at x i and x i+1. Such values ( f (x i ) and f (x i+1 )) are obtained by solving a linear system of equations. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 30 / 34

Piecewise polynomial interpolation Computing the cubic spline Cubic spline Task: Deduce an algorithm to compute the cubic spline. By definition, f is continuous in [x 0, x n ]. Therefore ω 0 = ω 1 = ω 2 = f f f 0 (x 0) 0 (x 1) = f 1 (x 1) 1 (x 2) = f 2 (x 2) ω n 1 = f n 2 (x n 1) = ω n = f n 1 (x n) f n 1 (x n 1) (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 31 / 34

Piecewise polynomial interpolation Cubic spline Integrating twice, we get fi (x) = ω i (x i+1 x) 3 + ω (x x i ) 3 i+1 + a i (x i+1 x) + b i (x x i ), 6h i 6h i where a i = ω i ω h i i h i 6, b i = ω i+1 ω h i i+1 h i 6. Therefore, once ω i are known, the cubic spline is fully determined. Using that f is twice continuously differentiable gives the n 1 linear equations h i 6 ω i + h i+1 + h i ω i+1 + h i+1 3 6 ω i+2 = ω i ( 1 + 1 ) ωi+1 + ω i+2. h i h i+1 h i h i+1 For full determination of the n + 1 values ω i we need two additional equations. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 32 / 34

Piecewise polynomial interpolation Cubic spline Natural cubic spline: There are several options to determine uniquely the cubic spline, for instance adding two equations to close the system, fix the value of two unknowns. If the values of ω 0 and ω n are fixed, we talk about natural splines. In this case, ω in = (ω 1,..., ω n ) are solution of Hω in = 6d, where d = ( 1 0,..., n 1 n 2 ), with i = (ω i+1 ω i )/h i, H = 2 (h 0 + h 1 ) h 1 0 0 0 h 1 2 (h 1 + h 2 ) h 2 0 0......... 0 0 0 2 (h n 3 + h n 2 ) h n 2 0 0 0 h n 2 2 (h n 2 + h n 1 ) (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 33 / 34

Error Piecewise polynomial interpolation Error Hypothesis: f : [a, b] R is four times continuously differentiable in [a, b]. x 0, x 1,..., x n [a, b]. Error estimation: Let h = max i=0,...,n h i. Then, for all x [a, b] we have f (x) f (x) c h p+1 max f (p+1) (y), y [a,b] where c is a constant independent of f, x and h. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 34 / 34