CSE 541 - Interpolation Roger Crawfis.

Slides:



Advertisements
Similar presentations
Interpolation A standard idea in interpolation now is to find a polynomial pn(x) of degree n (or less) that assumes the given values; thus (1) We call.
Advertisements

9.7 Taylor Series. Brook Taylor Taylor Series Brook Taylor was an accomplished musician and painter. He did research in a variety of areas,
Chapter 3. Interpolation and Extrapolation Hui Pan, Yunfei Duan.
CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari
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.
Computational Methods in Physics PHYS 3437
EARS1160 – Numerical Methods notes by G. Houseman
ES 240: Scientific and Engineering Computation. InterpolationPolynomial  Definition –a function f(x) that can be written as a finite series of power functions.
KFUPM SE301: Numerical Methods Topic 5: Interpolation Lectures 20-22:
Curve-Fitting Interpolation
Curve-Fitting Regression
Curve-Fitting Polynomial Interpolation
Interpolation Used to estimate values between data points difference from regression - goes through data points no error in data points.
Polynomial Interpolation
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 22 CURVE FITTING Chapter 18 Function Interpolation and Approximation.
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.
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. 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
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 21 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 171 Least.
CpE- 310B Engineering Computation and Simulation Dr. Manal Al-Bzoor
Interpolation. Interpolation is important concept in numerical analysis. Quite often functions may not be available explicitly but only the values of.
Unit 4: Modeling Topic 6: Least Squares Method April 1, 2003.
Curve Fitting and Interpolation: Lecture (I)
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Curve Fitting.
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.
Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis
Chapter 8 Curve Fitting.
Chapter 14 Curve Fitting : Polynomial Interpolation Gab Byung Chae.
Integration of 3-body encounter. Figure taken from
Curve-Fitting Regression
1. Interpolating polynomials Polynomial of degree n,, is a linear combination of Definitions: (interval, continuous function, abscissas, and polynomial)
In section 11.9, we were able to find power series representations for a certain restricted class of functions. Here, we investigate more general problems.
Chap. 11 Numerical Differentiation and Integration
Lecture 22 Numerical Analysis. Chapter 5 Interpolation.
Chapter 3 Interpolation
KFUPM SE301: Numerical Methods Topic 5: Interpolation Lectures 20-22:
EE3561_Unit 5(c)AL-DHAIFALLAH14361 EE 3561 : Computational Methods Unit 5 : Interpolation Dr. Mujahed AlDhaifallah (Term 351) Read Chapter 18, Sections.
This is an example of an infinite series. 1 1 Start with a square one unit by one unit: This series converges (approaches a limiting value.) Many series.
Review of fundamental 1 Data mining in 1D: curve fitting by LLS Approximation-generalization tradeoff First homework assignment.
Principles of Extrapolation
By: Mark Coose Joetta Swift Micah Weiss. What Problems Can Interpolation Solve? Given a table of values, find a simple function that passes through the.
Fourier Approximation Related Matters Concerning Fourier Series.
1 Chapter 4 Interpolation and Approximation Lagrange Interpolation The basic interpolation problem can be posed in one of two ways: The basic interpolation.
Interpolation - Introduction
1 Approximating functions, polynomial interpolation (Lagrange and Newton’s divided differences) formulas, error approximations.
Computational Methods CMSC/AMSC/MAPL 460 Polynomial Interpolation Ramani Duraiswami, Dept. of Computer Science.
Numerical Analysis Lecture 25.
Interpolation.
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.
Chapter 18.
Today’s class Multiple Variable Linear Regression
Numerical Analysis Lecture 26.
Numerical Computation and Optimization
MATH 174: Numerical Analysis I
SKTN 2393 Numerical Methods for Nuclear Engineers
9.7 Taylor Polynomials & Approximations
Curve Fitting Filling in the gaps.
Theory of Approximation: Interpolation
Presentation transcript:

CSE 541 - Interpolation Roger Crawfis

Taylor’s Series and Interpolation Taylor Series interpolates at a specific point: The function Its first derivative … It may not interpolate at other points. We want an interpolant at several f(c)’s. April 17, 2017 OSU/CIS 541

Basic Scenario We are able to prod some function, but do not know what it really is. This gives us a list of data points: [xi,fi] f(x) fi fi+1 xi xi+1 April 17, 2017 OSU/CIS 541

Interpolation & Curve-fitting Often, we have data sets from experimental/observational measurements Typically, find that the data/dependent variable/output varies… As the control parameter/independent variable/input varies. Examples: Classic gravity drop: location changes with time Pressure varies with depth Wind speed varies with time Temperature varies with location Scientific method: Given data identify underlying relationship Process known as curve fitting: April 17, 2017 OSU/CIS 541

Interpolation & Curve-fitting Given a data set of n+1 points (xi,yi) identify a function f(x) (the curve), that is in some (well-defined) sense the best fit to the data Used for: Identification of underlying relationship (modelling/prediction) Interpolation (filling in the gaps) Extrapolation (predicting outside the range of the data) April 17, 2017 OSU/CIS 541

Interpolation Vs Regression Distinctly different approaches depending on the quality of the data Consider the pictures below: extrapolate interpolate extrapolate Pretty confident: there is a polynomial relationship Little/no scatter Want to find an expression that passes exactly through all the points Unsure what the relationship is Clear scatter Want to find an expression that captures the trend: minimize some measure of the error Of all the points… April 17, 2017 OSU/CIS 541

Interpolation Concentrate first on the case where we believe there is no error in the data (and round-off is assumed to be negligible). So we have yi=f(xi) at n+1 points x0,x1…xi,…xn: xj > xj-1 (Often but not always evenly spaced) In general, we do not know the underlying function f(x) Conceptually, interpolation consists of two stages: Develop a simple function g(x) that Approximates f(x) Passes through all the points xi Evaluate f(xt) where x0 < xt < xn April 17, 2017 OSU/CIS 541

Interpolation Clearly, the crucial question is the selection of the simple functions g(x) Types are: Polynomials Splines Trigonometric functions Spectral functions…Rational functions etc… April 17, 2017 OSU/CIS 541

Curve Approximation We will look at three possible approximations (time permitting): Polynomial interpolation Spline (polynomial) interpolation Least-squares (polynomial) approximation If you know your function is periodic, then trigonometric functions may work better. Fourier Transform and representations April 17, 2017 OSU/CIS 541

Polynomial Interpolation Consider our data set of n+1 points yi=f(xi) at n+1 points x0,x1…xi,…xn: xj > xj-1 In general, given n+1 points, there is a unique polynomial gn(x) of order n: That passes through all n+1 points April 17, 2017 OSU/CIS 541

Polynomial Interpolation There are a variety of ways of expressing the same polynomial Lagrange interpolating polynomials Newton’s divided difference interpolating polynomials We will look at both forms April 17, 2017 OSU/CIS 541

Polynomial Interpolation Existence – does there exist a polynomial that exactly passes through the n data points? Uniqueness – Is there more than one such polynomial? We will assume uniqueness for now and prove it latter. April 17, 2017 OSU/CIS 541

Lagrange Polynomials Summation of terms, such that: Equal to f() at a data point. Equal to zero at all other data points. Each term is a nth- degree polynomial Existence!!! April 17, 2017 OSU/CIS 541

Remember this when we talk about piecewise-linear splines Linear Interpolation Summation of two lines: Remember this when we talk about piecewise-linear splines x0 x1 April 17, 2017 OSU/CIS 541

Lagrange Polynomials 2nd Order Case => quadratic polynomials The first quadratic has roots at x1 and x2 and a value equal to the function data at x0. P(x0) = f0 P(x1) = 0 P(x2) = 0 Adding them all together, we get the interpolating quadratic polynomial, such that: P(x0) = f0 P(x1) = f1 P(x2) = f2 The third quadratic has roots at x0 and x1 and a value equal to the function data at x2. P(x0) = 0 P(x1) = 0 P(x2) = f1 The second quadratic has roots at x0 and x2 and a value equal to the function data at x1. P(x0) = 0 P(x1) = f1 P(x2) = 0 x0 x2 x1 April 17, 2017 OSU/CIS 541

Lagrange Polynomials Sum must be a unique 2nd order polynomial through all the data points. What is an efficient implementation? April 17, 2017 OSU/CIS 541

Newton Interpolation Consider our data set of n+1 points yi=f(xi) at x0,x1…xi,…xn: xn > x0 Since pn(x) is the unique polynomial pn(x) of order n, write it: f[xi,xj] is a first divided difference f[x2,x1,x0] is a second divided difference, etc. April 17, 2017 OSU/CIS 541

Invariance Theorem Note, that the order of the data points does not matter. All that is required is that the data points are distinct. Hence, the divided difference f[x0, x1, …, xk] is invariant under all permutations of the xi‘s. April 17, 2017 OSU/CIS 541

Linear Interpolation Simple linear interpolation results from having only 2 data points. slope x0 x1 April 17, 2017 OSU/CIS 541

Quadratic Interpolation Three data points: April 17, 2017 OSU/CIS 541

Newton Interpolation Let’s look at the recursion formula: For the quadratic term: April 17, 2017 OSU/CIS 541

Evaluating for x2 April 17, 2017 OSU/CIS 541

Example: ln(x) Interpolation of ln(2): given ln(1); ln(4) and ln(6) Data points: {(1,0), (4,1.3863), (6,1.79176)} Linear Interpolation: 0 + {(1.3863-0)/(4-1)}(x-1) = 0.4621(x-1) Quadratic Interpolation: 0.4621(x-1)+((0.20273-0.4621)/5)(x-1)(x-4) = 0.4621(x-1) - 0.051874 (x-1)(x-4) corrected Note the divergence for values outside of the data range. April 17, 2017 OSU/CIS 541

Example: ln(x) Quadratic interpolation catches some of the curvature Improves the result somewhat Not always a good idea: see later… April 17, 2017 OSU/CIS 541

Calculating the Divided-Differences A divided-difference table can easily be constructed incrementally. Consider the function ln(x). April 17, 2017 OSU/CIS 541

Calculating the Divided-Differences April 17, 2017 OSU/CIS 541

Calculating the Divided-Differences April 17, 2017 OSU/CIS 541

Calculating the Divided-Differences April 17, 2017 OSU/CIS 541

Calculating the Divided-Differences April 17, 2017 OSU/CIS 541

Calculating the Divided-Differences April 17, 2017 OSU/CIS 541

Calculating the Divided-Differences April 17, 2017 OSU/CIS 541

Calculating the Divided-Differences Finally, we can calculate the last coefficient. April 17, 2017 OSU/CIS 541

Calculating the Divided-Differences All of the coefficients for the resulting polynomial are in bold. b0 b4 b7 April 17, 2017 OSU/CIS 541

Polynomial Form for Divided-Differences The resulting polynomial comes from the divided-differences and the corresponding product terms: April 17, 2017 OSU/CIS 541

Many polynomials Note, that the order of the numbers (xi,yi)’s only matters when writing the polynomial down. The first column represents the set of linear splines between two adjacent data points. The second column gives us quadratics thru three adjacent points. Etc. April 17, 2017 OSU/CIS 541

Adding an Additional Data Point Adding an additional data point, simply adds an additional term to the existing polynomial. Hence, only n additional divided-differences need to be calculated for the n+1st data point. b8 April 17, 2017 OSU/CIS 541

Adding More Data Points Quadratic interpolation: does linear interpolation Then add higher-order correction to catch the curvature Cubic, … Consider the case where the data points are organized such the the first two are the endpoints, the next point is the mid-point, followed by successive mid-points of the half-intervals. Worksheet: f(x)=x2 from -1 to 3. April 17, 2017 OSU/CIS 541

Uniqueness Suppose that two polynomials of degree n (or less) existed that interpolated to the n+1 data points. Subtracting these two polynomials from each other also leads to a polynomial of at most n degree. April 17, 2017 OSU/CIS 541

Uniqueness Since p and q both interpolate the n+1 data points, This polynomial r, has at least n+1 roots!!! This can not be! A polynomial of degree-n can only have at most n roots. Therefore, r(x)  0 April 17, 2017 OSU/CIS 541

Example Suppose f was a polynomial of degree m, where m<n. Ex: f(x) = 3x-2 We have evaluations of f(x) at five locations: (-2,-8), (-1,-5), (0,-2), (1,1), (2,4) April 17, 2017 OSU/CIS 541

Error Define the error term as: If f(x) is an nth order polynomial pn(x) is of course exact. Otherwise, since there is a perfect match at x0, x1,…,xn This function has at least n+1 roots at the interpolation points. April 17, 2017 OSU/CIS 541

Interpolation Errors Proof is in the book. Intuitively, the first n+1 terms of the Taylor Series is also an nth degree polynomial. April 17, 2017 OSU/CIS 541

Interpolation Errors Use the point x, to expand the polynomial. Point is, we can take an arbitrary point x, and create an (n+1)th polynomial that goes thru the point x. April 17, 2017 OSU/CIS 541

Interpolation Errors Combining the last two statements, we can also get a feel for what these divided differences represent. Corollary 1 in book – If f(x) is a polynomial of degree m<n, then all (m+1)st divided differences and higher are zero. April 17, 2017 OSU/CIS 541

Problems with Interpolation Is it always a good idea to use higher and higher order polynomials? Certainly not: 3-4 points usually good: 5-6 ok: See tendency of polynomial to “wiggle” Particularly for sharp edges: see figures April 17, 2017 OSU/CIS 541

Chebyshev nodes Equally distributed points may not be the optimal solution. If you could select the xi’s, what would they be? Want to minimize the term. These are the Chebyshev nodes. For x=-1 to 1: April 17, 2017 OSU/CIS 541

Chebyshev nodes Let’s look at these for n=4. Spreads the points out in the center. April 17, 2017 OSU/CIS 541

Polynomial Interpolation in Two-Dimensions Consider the case in higher-dimensions. April 17, 2017 OSU/CIS 541

Finding the Inverse of a Function What if I am after the inverse of the function f(x)? For example arccos(x). Simply reverse the role of the xi and the fi. April 17, 2017 OSU/CIS 541