Scientific Computing Interpolation – Divided Differences Efficiency and Error Analysis.

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

Chapter 6: Roots: Open Methods
Copyright © 2007 Pearson Addison-Wesley. All rights reserved. Problem Reduction Dr. M. Sakalli Marmara Unv, Levitin ’ s notes.
1 Chapter 4 Interpolation and Approximation Lagrange Interpolation The basic interpolation problem can be posed in one of two ways: The basic interpolation.
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.
KFUPM SE301: Numerical Methods Topic 5: Interpolation Lectures 20-22:
Chapter 4 Roots of Equations
Curve-Fitting Interpolation
Curve-Fitting Polynomial Interpolation
Interpolation Used to estimate values between data points difference from regression - goes through data points no error in data points.
ON MULTIVARIATE POLYNOMIAL INTERPOLATION
Lagrange interpolation Gives the same results as Newton, but different method.
Chapter 6 Numerical Interpolation
Warm up Use the Rational Root Theorem to determine the Roots of : x³ – 5x² + 8x – 6 = 0.
Polynomials. 2 Content Evaluation Root finding Root Bracketing Interpolation Resultant.
Computational Methods in Physics PHYS 3437 Dr Rob Thacker Dept of Astronomy & Physics (MM-301C)
1 Calculating Polynomials We will use a generic polynomial form of: where the coefficient values are known constants The value of x will be the input and.
CSE 330 : Numerical Methods
Scientific Computing Linear Systems – LU Factorization.
Interpolation. Interpolation is important concept in numerical analysis. Quite often functions may not be available explicitly but only the values of.
Scientific Computing Linear and Quadratic Splines.
Simpson Rule For Integration.
Great Theoretical Ideas in Computer Science.
Numerical Computation
2.3 Synthetic Substitution
Advanced Algebraic Algorithms on Integers and Polynomials Prepared by John Reif, Ph.D. Analysis of Algorithms.
Lecture 8 Numerical Analysis. Solution of Non-Linear Equations Chapter 2.
Chapter 14 Curve Fitting : Polynomial Interpolation Gab Byung Chae.
2.3 Synthetic Substitution OBJ:  To evaluate a polynomial for given values of its variables using synthetic substitution.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 31.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Key Concept 1. Example 1 Leading Coefficient Equal to 1 A. List all possible rational zeros of f (x) = x 3 – 3x 2 – 2x + 4. Then determine which, if any,
Polynomial Interpolation Lagrange Interpolation. Interpolation An Interpolating Function for a set of data: {( x 1, y 1 ),( x 2, y 2 ),( x 3, y 3 )…(
1. Interpolating polynomials Polynomial of degree n,, is a linear combination of Definitions: (interval, continuous function, abscissas, and polynomial)
Newton’s Interpolation. Newton Interpolation Newton’s Interpolating polynomial for a set of data {( x 1, y 1 ),( x 2, y 2 ),( x 3, y 3 ),…,( x m,y m )}
Introduction to Numerical Analysis I MATH/CMPSC 455 Interpolation.
Interpolation produces a function that matches the given data exactly. The function then can be utilized to approximate the data values at intermediate.
By Adam Mallen.  What is it?  How is it different from regression?  When would you use it?  What can go wrong?  How do we find the interpolating.
CHAPTER 3 NUMERICAL METHODS
MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
Lecture 22 Numerical Analysis. Chapter 5 Interpolation.
Chapter 3 Interpolation
Introduction Synthetic division, along with your knowledge of end behavior and turning points, can be used to identify the x-intercepts of a polynomial.
KFUPM SE301: Numerical Methods Topic 5: Interpolation Lectures 20-22:
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,
Copyright © 2006 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
MA2213 Lecture 2 Interpolation.
MAT 2401 Linear Algebra 2.5 Applications of Matrix Operations
Real Zeros of Polynomial Functions. Solve x 3 – 2x + 1 = 0. How? Can you factor this? Can you use the quadratic formula? Now what if I tell you that one.
5. Interpolation 5.1 Definition of interpolation. 5.2 Formulas for Interpolation. 5.3 Formulas for Interpolation for unequal interval. 5.4 Applications.
1 Chapter 4 Interpolation and Approximation Lagrange Interpolation The basic interpolation problem can be posed in one of two ways: The basic interpolation.
Introduction Previously, you learned how to graph logarithmic equations with bases other than 10. It may be necessary to convert other bases to common.
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.
Warm Up Compute the following by using long division.
Theorems about Roots of Polynomial Equations and
Analysis of Algorithms
Copyright © Cengage Learning. All rights reserved.
Numerical Analysis Lecture 25.
Theorems about Roots of Polynomial Equations and
Numerical Analysis Lecture 23.
Numerical Analysis Lecture 26.
MATH 174: Numerical Analysis
Numerical Computation and Optimization
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Numerical Analysis Lecture 21.
Numerical Analysis Lecture 24.
Interpolation with unequal intervals
Theory of Approximation: Interpolation
Presentation transcript:

Scientific Computing Interpolation – Divided Differences Efficiency and Error Analysis

How is Interpolation used? Here is a table of values for the temperature at a given depth for a lake. We want a good estimate of the temperature at a depth of 7.5 meters.

Newton’s Nested Formula Recall: Newton’s method is iterative with P k+1 (x) = P k (x) + c k (x – x 0 )(x – x 1 ) … (x – x k ) Now, P k (x) satisfies a similar formula: P k (x) = P k-1 (x) + c k-1 (x – x 0 )(x – x 1 ) … (x – x k-1 ) So, P k+1 (x) = P k-1 (x) + [c k-1 (x – x 0 )…(x – x k-1 )] + + [c k (x – x 0 )…(x – x k )] Thus, P n (x) = c 0 + [c 1 (x – x 0 )] + … + [c n (x – x 0 )…(x – x n )]

Newton Nested Formula P n (x) = c 0 + [c 1 (x – x 0 )] + … + [c n (x – x 0 )…(x – x n )] We can write this in a compact form as Here we define the product for k =0 to be 1, so the first term is c 0, as it should be. We can rewrite this formula as (verify this!!) P n (x) = c 0 + (x – x 0 )[c 1 + (x – x 1 )[c 2 + (x – x 2 )[…]]]

Newton Nested Formula P n (x) = c 0 + (x – x 0 )[c 1 + (x – x 1 )[c 2 + (x – x 2 )[…]]] This allows a better way of calculating P n (t) for a value of t (or x): Then, v n = P n (x) This is called Newton’s Nested formula for P n

Efficiency Newton’s Nested formula Requires 2n additions, n multiplications O(n) Lagrange Interpolation Requires at least n 2 additions O(n 2 )

Newton Divided Differences v n = P n (x) This is efficient, but is there a fast way to calculate the c k ‘s?

Newton Divided Differences P n (x) = c 0 + c 1 (x – x 0 ) + … + c n (x – x 0 )…(x – x n )] 1) Substituting x 0 for x and y 0 for y=P n (x), we get c 0 = y 0 =f[x 0 ] 2) Now, substituting x 1 for x and y 1 for y, we get 3) Substitute once more (x 2,y 2 ) to get

Newton Divided Differences 3) (cont’d) Simplifying, we get So, P n (x) = f[x] + f[x 0, x 1 ](x – x 0 ) + f[x 0, x 1, x 2 ](x – x 0 )(x -x 1 ) + … + c n (x – x 0 )…(x – x n )]

Newton Divided Differences Definition (Divided Differences). For a given collection of data { (x i,f(x i ) ) } a kth order divided difference is a function of k + 1 (not necessarily distinct) data values written as f[x i, x i+1, …, x i+k ]. 0 th Order: f[x i ] = f(x i ) = y i kth Order:

Newton Divided Differences Theorem For Newton’s Interpolation formula P n (x) = c 0 + [c 1 (x – x 0 )] + … + [c n (x – x 0 )…(x – x n )] the coefficients c k can be calculated as c k = f[x 0, x 1, …, x k ]

Newton Divided Differences Algorithm for Calculating Divided Differences: Calculate the differences in “pyramid” fashion, until you reach the last one.

Newton Divided Differences Example: Data (1,3), (1/2, -10), (3,2)

Newton Divided Differences Example: Data (1,3), (1/2, -10), (3,2)

Newton Divided Differences Example: Data (1,3), (1/2, -10), (3,2) Top row of the pyramid contains coefficients, c 0 = 3, c 1 = 26, c 2 = -53/5 Recall: Earlier work gave p(x) = (x-1) – (53/5) (x-1)(x-1/2)

Matlab - Newton Divided Differences Notes: We want to store the values in the “pyramid”. These can be stored in a matrix. We let F(i,k) = kth divided difference Differences are indexed from 0 to n, so F will have indexes from 1 to n+1. Vectors: x[], y[] for initial data, y = f(x).

Matlab - Newton Divided Differences Notes: F(i,k) = kth divided difference Get F(i,k+1) = (F(i+1,k)-F(i,k))/(x(i+k)-x(i))

Matlab - Newton Divided Differences function F = div_diff(x, y) % div_diff function computes all divided differences for % the data stored in x and y = f(x) n = length(x); m = length(y); if m~=n; error('x and y must be same size'); else F = zeros(n, n); for i = 1:n % define 0th divide difference F(i,1) = y(i); end for k = 1:n-1 % Get kth divided difference for i = 1:n-k F(i,k+1) = (F(i+1,k)-F(i,k))/(x(i+k)-x(i)); end

Matlab - Newton Divided Differences Example: x=[ ]‘; y=[ ]'; div_diff(x,y) ans = Top row (F(1,*)) holds coefficients c k.

Matlab - Newton Nested Formula Need loop running “Backwards” For evaluation, we replace x by a value u.

Matlab - Newton Nested Formula function v = newtonInterp(x,y,u) % v = newtonInterp(x,y,u) computes the Newton method % interpolation value p(u) for the given data x and y n = length(x); m = length(y); if m~=n; error('x and y must be same size'); else F = div_diff(x,y); % Compute Newton polynomial using nested format v = F(1,n); % v0 = cn for i = n-1:-1:1 v = F(1,i) + (u-x(i))*v; % nested formula end

Matlab - Newton Nested Formula Test: >> newtonInterp(x,y,1) ans = 3 >> newtonInterp(x,y,0.5) ans = -10 >> newtonInterp(x,y,3) ans = 2

Class Exercise Here is a table of values for the temperature at a given depth for a lake. Find a good estimate of the temperature at a depth of 7.5 meters. Use a cubic interpolating polynomial to help solve this problem.

Error Analysis 1)If we want to interpolate a given f(x) at n+1 nodes, how should we pick nodes? 2)How accurate can we make a polynomial interpolant over an interval?