1.33k likes | 1.35k Views
CSE 551 Computational Methods 2018/2019 Fall Chapter 5 Interpolation. Outline. Polynomial Interpolation Errors in Polynomial Interpolation. References. W. Cheney, D Kincaid, Numerical Mathematics and Computing, 6ed, Chapter 4 Sections 4.1, 4.2. Polynomial Interpolation.
E N D
CSE 551 Computational Methods 2018/2019 Fall Chapter 5 Interpolation
Outline Polynomial Interpolation Errors in Polynomial Interpolation
References • W. Cheney, D Kincaid, Numerical Mathematics and Computing, 6ed, • Chapter 4 • Sections 4.1, 4.2
Polynomial Interpolation Preliminary Remarks Polynomial Interpolation Interpolating Polynomial: Lagrange Form Existence of Interpolating Polynomial Interpolating Polynomial: Newton Form Nested Form Calculating Coefficients aiUsing Divided Differences Algorithms and Pseudocode
Polynomial Interpolation (cont.) Vandermonde Matrix Inverse Interpolation Interpolation of Bivariate Functions
Preliminary Remarks • three problems concerning representation of functions • interpolation • splines • least squares
a table of numerical values of a function: • 1)-find a simple and convenient formula • reproduces the given points exactly • 2)-the given table of numerical valuesis contaminated by errors • values came from a physical experiment. • ask for a formula – • represents the data (approximately) • and –filters out the errors.
3)- a function f - computer procedure • an expensive function to evaluate • ask for another function g • simpler to evaluate and produces a reasonable approximation to f • g to approximate f with full machine precision
In these problems: a simple function p - obtained • represents or approximates the given table or function f • representation p - a polynomial • other types of simple functions – used • a simple function p - used in place of f • e.g., • the integral of f could be estimated by the integral of p, • easier to evaluate.
In many situations, a polynomial solution – unsatisfactory from a practical point of view • other classes of functions must be considered • the spline functions • polynomials • general linear families of functions; • splines and polynomials are important examples.
a polynomial can fail as a practical solution to one of the • preceding problems • its degree may be unreasonably high • e.g., table 1,000 entries • a polynomial of degree 999 required • surprising defect of being highly oscillatory • precisely represented by a polynomial p • p(xi ) = yi0 i n • For points other than the given xi • p(x) may be a very poor representation of the function • the Runge function illustrates this phenomenon.
Polynomial Interpolation • table of values: • xi’s a set of n + 1 distinct points • n + 1 points in the Cartesian plane • find a polynomial curve • passes through all points • determine a polynomial - defined for all x, • takes on values of yifor each n +1 xi’s • A polynomial p: p(xi ) = yi0 i n - interpolate the table • The points xi - nodes
A Contstant Function • simplest case, n = 0 • a constant function. • the polynomial p of degree 0 p(x) = yreproduces the one-node table.
n = 1 • a straight line - passed through two points • a linear function • the polynomial • p defined by • first degree (at most) • reproduces the table • p(x0) = y0 ,p(x1) = y1, • linear interpolation.
Example • Find the polynomial of least degree that interpolates this table: • Solution:
an interpolating polynomial can be written in a variety of forms • among these are those known as • the Newton form: the most convenient and efficient • and the Lagrange form: conceptually - several advantages
Interpolating Polynomial: Lagrange Form • interpolate arbitrary functions at a set of fixed nodes: x0, x1, . . . , xn. • define a system of n + 1 special polynomials of degree n – cardinal polynomials • denoted 0, 1, . . . , n: • interpolate any function f by the Lagrange form of the interpolation polynomial:
pn - linear combination of the polynomials , • itself a polynomial of degree at most n. • evaluate pnat xj, f (xj ): • pninterpolating polynomial for the function f at nodes x0, x1, . . . , xn. • write the formula for the cardinal polynomial ,
(x) is the product of n linear factors: • denominators numbers; • the variable x in the numerators • polynomial of degree n • (x) evaluated at x = xi • each factor in the preceding equation becomes 1 • (xi ) = 1 • (x) evaluated at any other node, say, xj • one of the factors in the above equation will be 0 • (x j ) = 0, for i j
figure shows the first few Lagrange cardinal polynomials: l0(x), l1(x), l2(x), • l3(x), l4(x), and l5(x)
Example • Write out the cardinal polynomials appropriate to the problem of interpolating the following • table, and give the Lagrange form of the interpolating polynomial:
Solution • the interpolating polynomial in Lagrange’s form
Existence of Interpolating Polynomial • There is another constructive way of proving this fact • leads to a different formula. • found a polynomial p - reproduces part of the • table • Assume p(xi) = yi 0 i k • add to p another term • enable the new polynomial to reproduce one more entry in the table • where c is a constant to be determined
surely a polynomial • reproduces the first k points in the table • p itself does so, • added portion takes the value 0 • at each of the points x0, x1, . . . , xk • adjust the parameter c • the new polynomial takes the value yk+1 at xk+1.
c - obtained from this equation • none of the factors • xk+1 − xi, 0 i k, can be zero. • xi’s are all distinct • inductive reasoning • the process can be started • that it can be continued
Theorem • THEOREM ON EXISTENCE OF POLYNOMIAL INTERPOLATION • If points x0, x1, . . . , xnare distinct, • then for arbitrary real values y0, y1, . . . , yn, • there is a unique polynomial p of degree at most n • such that p(xi) = yifor 0 i n.
Two parts of this formal statement must still be established • First, the degree of the polynomial increases by at most 1 in each step of the inductive argument • At the beginning, • the degree was at most 0, • so at the end, the degree is at most n.
Second, • the uniqueness of the polynomial p. • Suppose that another polynomial q claims to accomplish what p does; • q is also of degree at most n and satisfies • p(xi) = yifor 0 i n. • Then the polynomial p − q is of degree at most n and takes the value 0 at x0, x1, . . . , xn • a nonzero polynomial of degree n can have at most n roots. conclude that p = q, • establishes the uniqueness of p.
Interpolating Polynomial: Newton Form • In the above example, • Lagrange form of the interpolating polynomial: • It can be simplified to
this polynomial can be written in another form • the nested Newton form: • fewest arithmetic operations • recommended for evaluating p2(x) • the Newton and Lagrange forms are just two different derivations for precisely the same polynomial • The Newton form – advantage: • easy extensibility to accommodate additional data points.
a method for constructing an interpolating polynomial. • Newton algorithm, • resulting polynomial: • Newton form of the interpolating polynomial.
Example • Using the Newton algorithm, find the interpolating polynomial of least degree for this table:
Soluton • In the construction • five successive polynomials appear • labeled p0, p1, p2, p3, and p4 • polynomial p0: • polynomial p1: • The interpolation condition placed on p1 p1(1) = −3 , −5 + c(1 − 0) = −3. Hence, c = 2, p1:
polynomial p2: • The interpolation condition placed on p2 • p2(−1) = −15, −5 + 2(−1) + c(−1)(−1 − 1) = −15. • c = −4, • The remaining steps are similar, • final result: • Newton form of the interpolating polynomial:
a better algorithm for constructing the Newton interpolating polynomial • the method - systematic one • involves very little computation • important feature • each new polynomial is obtained from its predecessor by adding a new term • the final polynomial exhibits all the previous polynomials as constituents.
Nested Form • rewrite the Newton form of the interpolating polynomial for efficient evaluation.
Example • Write the polynomial p4 of previous example in nested form and use it to evaluate p4(3).
Solution • write p4: • Another solution, also in nested form, is
nested multiplication - in a formal way • a general polynomial in the Newton form: • The nested form of p(x): • Newton interpolation polynomial succinctly:
Here is interpreted to be 1: • where
Figure shows the first few Newton polynomials: π0(x), π1(x), π2(x), π3(x), π4(x), and π5(x). • In evaluating p(t) for a given numerical value of t, • start with the innermost parentheses • forming successively the following quantities: • The quantity vnis now p(t)
Pseudocode • a subscripted variable is not needed for vi. integer i, n; real t, v; real array (ai )0:n, (xi )0:n v ← an for i = n − 1 to 0 step −1 do v ← v(t − xi ) + ai end for • the array (ai )0:ncontains the n+1 coefficients of the Newton form of the interpolating polynomial of degree at most n • the array (xi )0:ncontains the n + 1 nodes xi.
Calculating Coefficients aiUsing Divided Differences • problem of determining the coefficients a0, a1, . . . , anefficiently • table of values of a function f : • x0, x1, . . . , xnassumed to be distinct • no assumption is made about • their positions on the real line.
for each n = 0, 1, . . . , there exists a unique polynomial • pnsuch that • The degree of pnis at most n. • pn(xi ) = f (xi ) for i = 0, 1, . . . , n. • pncan be expressed in the Newton form:
A crucial observation about pn: • the coefficients a0, a1, . . . do not depend on n • In other words, pnis obtained from pn-1 by adding one more term, without altering the coefficients • already present in pn-1 itself. • pnis expressed in the form
A way of systematically determining the unknown coefficients a0, a1, . . . , an • set x equal in turn to x0, x1, . . . , xnin the Newton form • to write down the resulting equations: • in compact form:
can be solved for the ai’s in turn, • starting with a0. • a0 depends on f (x0), • that a1 depends on f (x0) and f (x1), and so on • In general, akdepends on f (x0), f (x1), . . . , f (xk) • akdepends on the values of f at the nodes x0, x1, . . . , xk. • The traditional notation is
defines f [x0, x1, . . . , xk]. • The quantity f [x0, x1, . . . , xk] • divided difference of order k for f . • coefficients a0, a1, . . . , ak- uniquely • determined by • there is no possible choice for a0 other than a0 = f (x0) • there is now no choice for a1 other than [ f (x1)−a0]/(x1 − x0) and so on.