Presentation is loading. Please wait.

Presentation is loading. Please wait.

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 )…(

Similar presentations


Presentation on theme: "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 )…("— Presentation transcript:

1 Polynomial Interpolation Lagrange Interpolation

2 Interpolation An Interpolating Function for a set of data: {( x 1, y 1 ),( x 2, y 2 ),( x 3, y 3 )…( x m, y m )} is a function f(x) that satisfies: f(x 1 ) = y 1 f(x 2 ) = y 2 f(x 3 ) = y 3. f(x m ) = y m {(2,-39), (-1,-4), (0,5), (1,6), (2,17), (2.5,31.875)} The graphs to the right show a set of data plotted at the top. The interpolating function along with the data is graphed below to the right.

3 Interpolating Data with a Function The problem we will be discussing is how if you are given a set of data points {( x 1, y 1 ),( x 2, y 2 ),( x 3, y 3 )…( x m, y m )}, can an interpolating function f(x) be constructed to fit the data. The requirement that f(x) be a function restricts the data that can be interpolated. In the definition of a function we have if x i = x j then f(x i ) = f(x j ), requiring if two pairs of data points ( x i,y i ) and ( x j,y j ) have equal x -coordinates the y -coordinates must also be equal. For implementation of many algorithms for interpolation we require the data set {( x 1, y 1 ),( x 2, y 2 ),( x 3, y 3 )…( x m, y m )} satisfy x i  x j if i  j. Polynomial Interpolation A Polynomial Interpolation for a set of data is an interpolating function f(x) such that f(x) is a polynomial. (i.e. f(x) = a n x n + a n -1 x n -1 + a n -2 x n -2 + … + a 1 x + a 0 ) Degree of Polynomial Interpolation The degree of a polynomial p(x) = a n x n + a n -1 x n -1 + a n -2 x n -2 + … + a 1 x + a 0 is the largest exponent with a non-zero coefficient. For the given p(x) its degree is n. In general, as your data set gets larger the number of terms you need in your polynomial (i.e. its degree) will also need to get larger. We usually insist on the degree of the polynomial being as small as possible for a given data set.

4 The degree of the polynomial required is less than the number of data points. In general a data set of m points will require a polynomial of degree m -1 or less. Lagrange Interpolating Polynomial The Lagrange Form of an interpolating polynomial makes use of elimination of terms and cancellation to fit the data set. Data SetPolynomial

5 Example: Let the data set {(-1,-4),(0,-5),(1,-2)} be the data set we want to interpolate. Plugging in the values of x we get: p (-1) = 2(-1) 2 + -1 -5 = 2-1-5 = -4 p (0) = 2(0) 2 + 0 -5 = 0 + 0 - 5 = -5 p (1) = 2(1) 2 + 1 -5 = 2 + 1 - 5 = -2

6 Lagrange Interpolating Polynomial Algorithm To implement the Lagrange Polynomial Interpolating Polynomial Algorithm to a set of data it is a matter of following the formula to the right for the set of data: {( x 1, y 1 ),( x 2, y 2 ),( x 3, y 3 )…( x m, y m )} alldiffx ← True For[ i =1, i  m, i ++ For[ j =1, j <i, j ++, alldiffx=alldiffx and ( x i  x j )]] If alldiffx psum=0 For[ i =1, i  m, i ++ pprod= y i For[ j =1, j <i, j ++, If i  j then pprod=pprod*( x –x j )/( x i – x j )] psum=psum+pprod] (* else *) Print[“Data set can not be interpolated by a function”]


Download ppt "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 )…("

Similar presentations


Ads by Google