Chapter 14 Curve Fitting : Polynomial Interpolation Gab Byung Chae.

Slides:



Advertisements
Similar presentations
Splines and Piecewise Interpolation
Advertisements

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.
Chapter 6: Roots: Open Methods
Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.
Chapter 18 Interpolation The Islamic University of Gaza
CITS2401 Computer Analysis & Visualisation
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.
Polynomial Interpolation
Curve Fitting and Interpolation: Lecture (II)
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 REVIEW II.
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.
CSE Interpolation Roger Crawfis.
Lagrange interpolation Gives the same results as Newton, but different method.
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.
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.
Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis
CISE301_Topic41 CISE301: Numerical Methods Topic 4: Least Squares Curve Fitting Lectures 18-19: KFUPM Read Chapter 17 of the textbook.
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. Applied Numerical Methods With MATLAB ® for Engineers.
Curve Fitting and Regression EEE 244. Descriptive Statistics in MATLAB MATLAB has several built-in commands to compute and display descriptive statistics.
Part 4 Chapter 17 Polynomial Interpolation PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill.
Polynomial Interpolation You will frequently have occasions to estimate intermediate values between precise data points. The function you use to interpolate.
Advanced Topics- Polynomials
Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis
Chapter 8 Curve Fitting.
Numerical Methods For Slides Thanks to Lecture 6 Interpolation
Polynomial Interpolation (多項式內插法)
Chapter 4 Interpolation and Approximation. 4.1 Lagrange Interpolation The basic interpolation problem can be posed in one of two ways: The basic interpolation.
Scientific Computing Interpolation – Divided Differences Efficiency and Error Analysis.
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.
Copyleft  2005 by MediaLab Chapter 8 Interpolation (1)
CHAPTER 3 NUMERICAL METHODS
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.
Recap Cubic Spline Interpolation Multidimensional Interpolation Curve Fitting Linear Regression Polynomial Regression The Polyval Function The Interactive.
MODEL FITTING jiangyushan. Introduction The goal of model fitting is to choose values for the parameters in a function to best describe a set of data.
Principles of Extrapolation
Chapter 13 Objectives Familiarizing yourself with some basic descriptive statistics and the normal distribution. Knowing how to compute the slope and intercept.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
1 Lecture 8 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
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.
CHAPTER 3 NUMERICAL METHODS
Polynomial 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.
Chapter 15 Curve Fitting : Splines
Chapter 18.
Chapter 12 Curve Fitting : Fitting a Straight Line Gab-Byung Chae
Today’s class Multiple Variable Linear Regression
MATH 2140 Numerical Methods
Interpolasi Pertemuan - 7 Mata Kuliah : Analisis Numerik
Splines and Piecewise Interpolation
POLYNOMIAL INTERPOLATION
Numerical Computation and Optimization
SKTN 2393 Numerical Methods for Nuclear Engineers
Numerical Analysis Lecture 21.
Presentation transcript:

Chapter 14 Curve Fitting : Polynomial Interpolation Gab Byung Chae

You’ve got a problem Estimation of intermediate values between data points

14.1 Introduction to Interpolation

(2) MATLAB Function : polyfit and polyval Only one straight line that connects two points. Only one parabola connects a set of three points.

Determining polynomial coefficients Interpolating polynomial of solve Ill-conditioned system (Vandermonde matrices)

4.1.2 MATLAB Functions >> format long >> T = [ ]; >> density = [ ]; >> p = polyfit(T, density,2) >> d = polyval(p,350)

14.2 Newton Interpolating polynomial

Graphical depiction of linear interpolation. The shaded areas indicate the similar triangles used to derive the Newton linear -interpolation formula [Eq. (14.5)]. Figure 14.2

FDD = finite divided difference The second FDD

Two linear interpolations to estimate ln 2. Note how the smaller interval provides a better estimate. Figure 14.3

Example 14.3 Problem : f(x) = ln x –x 1 = 1 f(x 1 ) =0 –x 2 = 4 f(x 2 ) = –x 3 = 6 f(x 3 ) = Solution : –b 1 = 0 –b 2 = ( – 0) /(4-1) = –b 3 = f 2 (x) = (x-1) – (x-1)(x-4) f 2 (x) = (x-1) – (x-1)(x-4)

The use of quadratic interpolation to estimate ln 2. The linear interpolation from x = 1 to 4 is also included for comparison. Figure 14.4

Newton Interpolation  Divided-difference table : Adding (3,14) and (4,22) <- a 1 <- a 2 <- a 3

Graphical depiction of the recursive nature of finite divided differences. This representation is referred to as a divided difference table. Figure 14.5

Example 14.4 Problem : f(x) = ln x –x 1 = 1 f(x 1 ) =0 –x 2 = 4 f(x 2 ) = –x 3 = 6 f(x 3 ) = –x 4 = 5 f(x 4 ) = f 3 (x) = b1 + b2(x-x1)+ b3(x-x1)(x-x2)+b4(x-x1)(x- x2)(x-x3) b3(x-x1)(x-x2)+b4(x-x1)(x- x2)(x-x3)

Solution : –b 1 = f(x 1 ) = 0 –b 2 = f[x 2, x 1 ] = ( – 0) /(4-1) = –f[x 3,x 2 ] = ( – ) /(6-4) = –f[x 4,x 3 ] = ( – ) /(5-6) = –b 3 = f[x 3,x 2,x 1 ] = ( – ) /(6-1) = = –f[x 4,x 3,x 2 ] = ( – ) /(5-4) = = –b 4 =f[x 4,x 3,x 2,x 1 ] = ( ) /(5-1) = =

f 3 (x) = (x-1) (x-1)(x-4) (x-1)(x-4) (x-1)(x- 4)(x-6) (x-1)(x- 4)(x-6)

function yint = Newtint(x,y,xx) % yint = Newtint(x,y,xx): % Newton interpolation. Uses an (n - 1)-order Newton % interpolating polynomial based on n data points (x, y) % to determine a value of the dependent variable (yint) % at a given value of the independent variable, xx. % input: % x = independent variable % y = dependent variable % xx = value of independent variable at which % interpolation is calculated % output: % yint = interpolated value of dependent variable

% compute the finite divided differences in the form of a % difference table n = length(x); if length(y)~=n, error('x and y must be same length'); end b = zeros(n,n); % assign dependent variables to the first column of b. b(:,1) = y(:); % the (:) ensures that y is a column vector. for j = 2:n for i = 1:n-j+1 for i = 1:n-j+1 b(i,j) = (b(i+1,j-1)-b(i,j-1))/(x(i+j-1)-x(i)); b(i,j) = (b(i+1,j-1)-b(i,j-1))/(x(i+j-1)-x(i)); end endend % use the finite divided differences to interpolate xt = 1; yint = b(1,1); for j = 1:n-1 xt = xt*(xx-x(j)); xt = xt*(xx-x(j)); yint = yint+b(1,j+1)*xt; yint = yint+b(1,j+1)*xt;end

14.3 Lagrange Interpolating polynomial weight coefficients The first order Lagrange interpolating polynomial Lagrange interpolating polynomial The n-th order Lagrange interpolating polynomial Lagrange interpolating polynomial

The second order Lagrange interpolating polynomial Lagrange interpolating polynomial

Example 14.5 Problem : Use a Lagrange interpolating polynomial of the first and second order to evaluate the density of unused motor oil at T = 15 o C –x 1 = 0 f(x 1 ) = 3.85 –x 2 = 20 f(x 2 ) = –x 3 = 40 f(x 3 ) = Solution : First-order at x=15: –f 1 (x)= Second-order : – f 2 (x)=

function yint = Lagrange(x,y,xx) % yint = Lagrange(x,y,xx): % Lagrange interpolation. Uses an (n - 1)-order Lagrange % interpolating polynomial based on n data points (x, y) % to determine a value of the dependent variable (yint) % at a given value of the independent variable, xx. % input: % x = independent variable % y = dependent variable % xx = value of independent variable at which the % interpolation is calculated % output: % yint = interpolated value of dependent variable MATLAB M-file:Lagrange

n = length(x); if length(y)~=n, error('x and y must be same length'); end s = 0; for i = 1:n product = y(i); for j = 1:n if i ~= j product = product*(xx-x(j))/(x(i)-x(j)); end s = s+product; end yint = s;

14.4 Inverse Interpolation (1,1) (3,3) (5,5) -> (?,2) Polynomial interpolation –Determine (n-1)-th order polynomial p(x) –solve p(t) = 2 Ex : (2, 0.5), (3,0.3333), and (4,0.25) –Find x so that f(x)=0.3 –f 2 (x) = x 2 – 0.375x –Solve 0.3 = x 2 – 0.375x for x –x = or

Extrapolation is the process of estimating a value of f(x) that lies outside the range of the known base points Extrapolation

Illustration of the possible divergence of an extrapolated prediction. The extrapolation is based on fitting a parabola through the first three known points. Figure 14.10

Example 14.6 Problem : Fit a seventh-order polynomial to the first 8 points (1920 to 1990). Use it to compute the population in 2000 by extrapolationand compare your prediction with the actual result. Solution : >> t = [1920 :10:1990]; >> t = [1920 :10:1990]; >> pop = [ ]; >> pop = [ ]; >> p = polyfit(t, pop, 7) >> p = polyfit(t, pop, 7) Warning message …… Warning message ……

>> ts = (t-1955)/35; >> P = polyfit(ts, pop, 7); >> polyval(p, ( )/35) >>tt=linspace(1920,2000); >>pp=polyval(p, (tt-1955)/35); Plot(t,pop, ‘o’, tt, pp)

Use of a seventh-order polynomial to make a prediction of U.S. population in 2000 based on data from 1920 through Figure 14.11

Oscillations Dangers of higher-order polynomial interpolation Ex : Ringe’s function

Comparison of Runge’s function (dashed line) with a fourth-order polynomial fit to 5 points sampled from the function. Figure 14.12

Comparison of Runge’s function (dashed line) with a tenth-order polynomial fit to 11 points sampled from the function. Figure 14.13