Wk5 Lagrangian Polynomials

18
 Engineering Mathematics 2 – Week 5_2 Interpolation (BEng in CE / CSE / CGE Intake 1!

description

civil engineering maths sem 2

Transcript of Wk5 Lagrangian Polynomials

Solution of Algebraic and Transcendental Equations

Engineering Mathematics 2 Week 5_2Interpolation

(BEng in CE / CSE / CGE Intake 14)Interpolation and Polynomial ApproximationIntroduction: A census of the population of the United States is taken every 10 years. The following table lists the population, in thousands of people, from 1940 to 1990.

In reviewing these data, we might ask whether they could be used to provide a reasonable estimate of the population, say, in 1965, or even in the year 2010. Predictions of this type can be obtained by using a function that fits the given data.

Year194019501960 1970 1980 1990Population132,165151,326179,323203,302226,542249,633Lagrangian Polynomials (Interpolation with unevenly spaced points)We assume that the given data are exact and represent values of some unknown function. If we desire to find a polynomial that passes through the same points as our unknown function, we could set up a system of equations involving the coefficients of the polynomial. For example, suppose we want to fit a cubic to these data:

First, we need to select four points to determine our polynomial. (The maximum degree of the polynomial is always one less than the number of points.) Suppose we choose the first four points. If the cubic is ax3 + bx2 + cx + d. We can write 4 equations involving the unknown coefficients a, b, c and d:

xF (x)3.222.02.717.81.014.24.838.35.651.7Lagrangian PolynomialsWhen x = 3.2: a(3.2)3 + b(3.2)2 + c(3.2) + d = 22.0x =2.7: a(2.7)3 + b(2.7)2 + c(2.7) + d = 17.8x = 1.0: a(1.0)3 + b(1.0)2 + c(1.0) + d = 14.2x = 4.8: a(4.8)3 + b(4.8)2 + c(4.8) + d = 38.3The set of equations gives a= -0.5275, b= 6.4952, c= -16.1177, d= 24.3499And our polynomial is -0.5275 x3 + 6.4952 x2 -16.1177 x + 24.3499We can then estimate the values of the function at some value of x , say, x = 3.0 by substituting 3.0 for x in the polynomial. At x=3.0,the estimated value is 20.21.We seek a better and simpler way of finding such interpolating polynomials. The Lagrangian polynomial is perhaps the simplest way to exhibit the existence of a polynomial for interpolation with unevenly spaced data.

Lagrangian PolynomialsSuppose we have a table of data with four pairs of x and f(x) values.xf(x)------ ---------x0f0x1f1x2f2x3f3

Here we do not assume uniform spacing between the x values, nor do we need the x-values arranged in a particular order. The x values must all be distinct, however. Through these four data pairs we can pass a cubic. The Lagrangian form for this is

.

Lagrangian PolynomialsExample: Certain corresponding values of x and log10x are (300, 2.4771),(304, 2.4829), (305,2.4843) and (307, 2.4871). Find log10 301.

= 1.2739+ 4.9658 4.4717 + 0.7106 = 2.4786

Example: If y1 = 4, y3 = 12, y4 = 19 and yx = 7, find x.

The actual value is 2.0,since the above value is obtained from the polynomial y(x)=x2 +3

Finite DifferencesAssume that we have a table of values ( xi , yi ) , i = 0,1,2,,n of any function y = f(x), the values of x being equally spaced, i.e. xi = x0 + ih, i = 0,1,2,,n. Suppose that we are required to recover the values of f(x) for some intermediate value of x, or to obtain the derivative of f(x) for some x in the range x0 < x < xn. The methods for the solution of these problems are based on the concept of the differences of a function which we now proceed to define.

Forward Differences If y0, y1,,yn denote a set of values of y, then y1-y0, y2 y1,,yn yn-1 are called the differences of y. Denoting these differences by respectively, we have

Where is called the forward difference operator and are called the first forward differences.

Finite DifferencesThe differences of the first forward differences are called second forward differences and are denoted by Similarly, one can define third forward differences, fourth forward differences. etc.Thus

It is therefore clear that any higher order difference can easily be expressed in terms of the ordinates.The following table shows how the forward differences of all orders can be performed:

.

Newtons Formulae for InterpolationGiven the set of (n+1) values, viz., ( x0, y0), ( x1, y1),,( xn, yn), of x and y, it is required to find yn (x), a polynomial of the nth degree such that y and yn(x) agree at the tabulated points. Let the values of x be equidistant, i.e., let xi = x0 + ih, i = 0,1,2,,n.Since yn(x) is a polynomial of the nth degree, it may be written as yn(x) = a0 + a1 (x x0 ) + a2 (x x0) (x x1)+ +an(x x0)( x x1)( x xn-1) (i)Imposing now the condition that y and yn(x) should agree at the set of tabulated points, we obtain

Setting x = x0 + ph and substituting for a0, a1,, equation (i) gives

which is Newtons forward difference interpolation formula.

Newtons Formulae for InterpolationExample:Find the cubic polynomial which takes the following values:y (0) = 1, y (1) = 0 , y (2) = 1 and y (3) = 10. Hence or otherwise , obtain y(4).

We form the difference table:

Here h = 1, hence using the formula x = x0+ph and choosing x0=0, we obtain p=x. Substituting this value of p in (ii), we get y (x) = 1 + x(-1) + x(x-1).(2) / 2 + x(x-1)(x-2).(6)/6 = x3 2x2 + 1, which is the polynomial from which we obtained the above tabular values. y (4) = 1 + 4(-1) +12 +24 = 33Which is the same value as that obtained by substituting x = 4 in the cubic polynomial above.Note: This process of finding the value of y for some value of x outside the given range is called extrapolation.

Newtons Formulae for InterpolationExample: The table below gives the values of tanx for 0.10 < x < 0.30.Find (i) tan 0.12(ii) tan 0.26(iii) tan 0.40(iv) tan 0.50The table of difference is x y0.10 0.10030.05080.15 0.15110.00080.05160.00020.20 0.20270.00100.00020.05260.00040.25 0.25530.00140.05400.30 0.3093

To find tan(0.12),we have 0.12 = 0.10 + p(0.05) which gives p = 0.4. Hence formula (ii) gives tan(0.12) = 0.1003 + 0.4(0.0508) + 0.4(0.4 1) (0.0008) /2 + 0.4(0.4 1)( 0.4 2)(0.0002) / 6 + 0.4(0.4 1)( 0.4 2) ( 0.4 3)(.0002) / 24= 0.1205

Task: ii, iii & ivNewtons Formulae for InterpolationTask: The population of a town in the decennial census was as given below. Estimate the population for the year 1895.

Divided DifferencesLet ( x0, y0), ( x1,y1), , ( xn,yn) be the given (n+1) points. Then the divided differences of orders 1,2,,n are defined by the relations

Even if the arguments are equal, the divided difference may still have a meaning. We then set x1=x0 +

It is easy to see that:

Hence the divided differences are symmetrical in their arguments.

Divided DifferencesNow let the arguments be equally spaced so that x1-x0 = x2 x1 = = xn xn-1 = h. Then

If the tabulated function is a polynomial of nth degree, then would be a constant and hence the nth divided difference would also be a constant.

Newtons General Interpolation FormulaWe have, from the definition of divided differences,

This formula is called Newtons general interpolation formula with divided differences, the last term being the remainder term after (n+1) terms.

Newtons General Interpolation FormulaExample: Certain corresponding values of x and log10x are (300, 2.4771),(304, 2.4829), (305,2.4843) and (307, 2.4871). Find log10 301.The divided difference table is

Hence Newtons formula gives log10 301= 2.4771 +0.00145 + (-3)(-0.00001) = 2.4786.

xlog10x3002.47710.001453042.4829-0.000010.001403052.484300.001403072.4871Newtons General Interpolation FormulaExample: Using the following table find f(x) as a polynomial in x.

The divided difference table is

Hence f (x ) = 3 + (x+1)(-9) + x(x+1)(6) + x(x+1)(x-3)(5) + x(x+1)(x-3)(x-6) = x4 3x3 + 5x2 6.

xf ( x )-13-90-661553394112611368221327897 1611NextMore Numerical Methods