Sunteți pe pagina 1din 4

Lecture 5 Curve Interpolation. Newtons Divided Differences.

Lagrange Polynomials
5.1. INTERPOLATING AND APPROXIMATING POLYNOMOALS In general, free form ship curves, i.e., frame, waterline, buttock lines, are given in tabular forms as follows:

Mathematical representation of ship lines will require to generate an approximating function that will allow an estimation of the offset value y for x xi, i = 1, 2, , n. It may be assumed that these offset points are defined by a non-analytic function y = f(x). We wish to approximate f(x) by a suitable analytic function g(x) which has the general characteristic shape. The algebraic polynomials are the most important and popular approximating functions. Polynomials are easy to evaluate and their sums, products and differences are also polynomials. Polynomials can be differentiated and integrated easily, yielding other polynomials in both cases. The polynomials can be simply divided into two categories; interpolating and approximating polynomials. Examples of interpolating and approximating polynomials are illustrated in Figures 5.1 a and 5.1.b, respectively.

Figure 5.1 a

Figure 5.1 b

Given a set of n ordered data points (xi, yi), i = 0,1,, n 1, let y = p(x) be a polynomial of degree n 1 in x with unknowns a0, a1, , an 1. That p(x) traverses through data points above implies 2 3 n 1 ) y0 = p ( x 0 ) = a0 + a1 x0 + a2 x0 + a3 x0 + ... + an 1 x0 y1 = p ( x1) = a0 + a1 x1 + a2 x12 + a3 x13 + ... + an 1 x1n 1 )
2 3 n 1 ) y2 = p ( x 2 ) = a0 + a1 x2 + a2 x2 + a3 x2 + ... + an 1 x2

(5.1)

...
2 3 n 1 yn 1 = p ( x n 1) = a0 + a1 xn 1 + a2 xn 1 + a3 xn 1 + ... + an 1 xn 1 )

which is a system of n linear equations in ai, i = 0,1,, n 1, and can be solved by inverting an nn matrix. The n equations can be given in matrix form as: n 1 1 x0 a0 y0 x0 x1n 1 a1 y1 1 x1 = n 1 1 xn 1 xn 1 an 1 yn 1

There is unique solution for the ai, and hence there is only one polynomial p(x) which exactly produces yi values. This type of polynomial may be ideal for representing simple sections; however, for high values of n (degree of the polynomial) the linear system of equations can produce illconditioning. Also, it is computationally expensive to change one of the points, since the entire system has to be resolved. It is possible to reduce some effort in computation by posing the interpolating polynomial in a slightly different manner. 5.2. NEWTONS DIVIDED DIFFERENCES In the Newtons divided differences approach, the polynomial is presented as y p ( x) = a0 + a1 ( x x0 ) + a2 ( x x0 )( x x1 ) + ... + an 1 ( x x0 )( x x1 )( x xn 2 ) so that at the data points, the equations in unknowns ai take the form y 0 p ( x0 ) = a 0 a0 = y 0 y a y1 p( x1 ) = a0 + a1 ( x1 x0 ) a1 = 1 0 x1 x0 (5.2)

y2 p( x2 ) = a0 + a1 ( x2 x0 ) + a2 ( x2 x0 )( x2 x1 )

a2 =

y2 a0 a1 ( x2 x0 ) ( x2 x0 )( x2 x1 )

yn1 p( xn1 ) = a0 + a1 ( x2 x0 ) + a2 ( x2 x0 )( x2 x1 ) + ... + an1 ( xn1 x0 )( xn1 x1 )( xn1 xn2 )

an1 =

yn1 a0 a1 ( xn1 x0 ) an2 ( xn1 x0 )( xn1 x1 )...( xn1 xn2 ) ( xn1 x0 )( xn1 x1 )...( xn1 xn2 )

The unknowns ai are determined by a series of forward substitutions. Note that a0 depends only on y0, a1 depends on y0 and y1, a2 depends on y0, y1 and y2, and so on. If, additionally, a new data point, (xn, yn) is introduced, an equation is further added with only one unknown an to be determined, that is, the addition of a new data point does not alter the previously calculated coefficients. This is in contrast to the system of equations in (5.1) wherein the addition of a data point requires all the n + 1 coefficients to be recomputed by inverting an (n + 1)(n + 1) matrix. 5.3. LAGRANGE POLYNOMIALS

The third possibility in curve interpolation due to Lagrange does not require computing the coefficients and can be elucidated using the following example. For three data points (x0, y0), (x1, y1) and (x2, y2), consider the expression

L2 0 ( x) =

( x x1 )( x x2 ) ( x0 x1 )( x0 x2 )

(5.3)

2 On setting x=x0. L2 0 ( x ) becomes unity, however, for x=x1 or x2, L0 ( x ) =0. ( x x0 )( x x2 ) 2 ( x) = is 1 for x=x1 and 0 for x=x0 and x=x2 and that Similarly, L1 ( x1 x0 )( x1 x2 ) ( x x0 )( x x1 ) is 1 for x=x2 and 0 for x=x0 and x=x1 . L2 2 ( x) = ( x2 x0 )( x2 x1 )

2 2 Using the functions L2 0 ( x ) , L1 ( x ) and L2 ( x ) which are all quadratic in x (the superscript denotes the degree in x), and the y values, we can construct a quadratic function

2 2 PL2 = L2 0 ( x ) y0 + L1 ( x ) y1 + L2 ( x ) y2

(5.4)

1 which passes through the three data points. In general, Ln i ( x ) are termed as Lagrangian 1 interpolation coefficients where the subscript i signifies that Ln i ( x ) is the weight of yi in Eq. (5.6). The superscript n 1 denotes the degree of interpolating polynomial. By inspection from 1 Eq. (5.3) and the related expressions, Ln i ( x ) may be written as n 1 (x x j ) ( x x0 )...( x xi 1 )( x xi +1 )...( x xn 1 ) 1 (5.5) Ln ( x ) = = i ( xi x0 )...( xi xi 1 )( x xi +1 )...( xi xn 1 ) j = 0 ( xi x j )
j i

The interpolating polynomial than becomes


1 PLn 1 ( x) = Ln i ( x ) yi i =0 n 1

(5.6)

5.4.

EXAMPLES

Consider a bulb ship profile defined by 4 points. Find the interpolating polynomial using Newtons divided differences approach and Lagrange polynomials. (see also Figure 5.1)
x y 0 0 3 6 6 2 9 8

5.4.1 Newtons divided differences approach

Since there are fore data points (n=4) the polynomial is a cubic (degree =3), that is y = a0 + a1 ( x x0 ) + a2 ( x x0 )( x x1 ) + a3 ( x x0 )( x x1 )( x x2 ) Now a0 = y 0 = 0 y a0 6 0 a1 = 1 =2 = x1 x0 3 0 ( y a0 ) a1 ( x2 x0 ) (2 0) 2(6 0) 10 a2 = 2 = = ( x2 x0 )( x2 x1 ) (6 0)(6 3) 18 ( y a0 ) a1 ( x3 x0 ) a2 ( x3 x0 )( x3 x1 ) (8 0) 2(9 0) + 10 / 18(9 0)(9 3) 10 = = a3 = 3 ( x3 x0 )( x3 x1 )( x3 x2 ) (9 0)(9 3)(9 6) 81 The polynomial becomes 10 10 y = 2 x x( x 3) + x( x 3)( x 6) 18 81
5.4.2 Lagrange polynomials

Since n=4 the degree of Lagrange polynomial is n-1=3 3 3 3 y = L3 0 ( x ) y0 + L1 ( x ) y1 + L2 ( x ) y 2 + L3 ( x ) y3 or

y= +

( x x1 )( x x2 )( x x3 ) ( x x0 )( x x2 )( x x3 ) ( x x0 )( x x1 )( x x3 ) y0 + y1 + y2 + ( x0 x1 )( x0 x2 )( x0 x3 ) ( x1 x0 )( x1 x2 )( x1 x3 ) ( x2 x0 )( x2 x1 )( x2 x3 ) ( x x0 )( x x1 )( x x2 ) y3 ( x3 x0 )( x3 x1 )( x3 x2 ) Substituting with data points we obtain ( x 3)( x 6)( x 9) ( x 0)( x 6)( x 9) ( x 0)( x 3)( x 9) 0+ 6+ 2+ y= (0 3)(0 6)(0 9) (3 0)(3 6)(3 9) (6 0)(6 3)(6 9) ( x 0)( x 3)( x 6) + 8 (9 0)(9 3)(9 6) x( x 6)( x 9) x( x 3)( x 9) 4 x( x 3)( x 6) y= + 9 27 81 On simplification the both approaches will give the same result. 53 5 10 y= x x2 + x3 9 3 81 On Figure 5.1 the input points and interpolating curve are shown.
10

(9,8)
8

6 X

(6,2)

(3,6)
2

(0,0)
0 0 2 4 Y 6 8 10

Figure 5.1. Cubic polynomial representing a bulbous ship profile

S-ar putea să vă placă și