21
1 MA8491 Numerical Methods . Topic 1 : Lagrangian Polynomials(Equal and unequal intervals) Lagrange’s interpolation formula(x given, finding y in terms of x) Let y =f(x) be a function which takes the values y = y 0 , y 1 ,…, y n corresponding to x = x 0 , x 1 ,…, x n . 1 2 0 0 1 0 2 0 ( )( ) ( ) () () ( )( ) ( ) n n x x x x x x y yx fx y x x x x x x 0 2 1 1 0 1 2 1 0 1 1 2 0 2 1 1 ( )( ) ( ) ( )( ) ( ) ( )( ) ( ) ( )( ) ( ) n n n n n x x x x x x y x x x x x x x x x x x x y x x x x x x Inverse Lagrange’s interpolation formula(y given, finding x in terms of y) 1 2 0 0 1 0 2 0 ( )( ) ( ) () () ( )( ) ( ) n n y y y y y y x xy f y x y y y y y y 0 2 1 1 0 1 2 1 0 1 1 2 0 2 1 1 ( )( ) ( ) ( )( ) ( ) ( )( ) ( ) ( )( ) ( ) n n n n n y y y y y y x y y y y y y y y y y y y x y y y y y y Note: Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol: Lagrange’s interpolation formula can be used whether the values of x, the independent variable are equally spaced or not whether the difference of y become smaller or not. 2. What is the disadvantage in practice in applying Lagrange’s interpolation formula? Sol: Though Lagrange’s formula is simple and easy to remember, its application is not speedy. It requires close attention to sign and there is always a chance of committing some error due to a number of positive and negative signs in the numerator and the denominator. UNIT II: INTERPOLATION AND APPROXIMATION Lagrangian Polynomials – Divided differences – Interpolating with a cubic spline – Newton’s forward and backward difference formulas.

denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

1MA8491 Numerical Methods .

Topic 1 : Lagrangian Polynomials(Equal and unequal intervals)Lagrange’s interpolation formula(x given, finding y in terms of x)

Let y =f(x) be a function which takes the values y = y0, y1,…, yn corresponding to x = x0, x1,…, xn.

1 20

0 1 0 2 0

( )( ) ( )( ) ( )

( )( ) ( )n

n

x x x x x xy y x f x y

x x x x x x

……

0 21

1 0 1 2 10 1 1

2 0 2 1 1

( )( ) ( )

( )( ) ( )( )( ) ( )

( )( ) ( )

n

nn

nn

x x x x x xy

x x x x x xx x x x x x

yx x x x x x

……

………

Inverse Lagrange’s interpolation formula(y given, finding x in terms of y)

1 20

0 1 0 2 0

( )( ) ( )( ) ( )

( )( ) ( )n

n

y y y y y yx x y f y x

y y y y y y

……

0 21

1 0 1 2 10 1 1

2 0 2 1 1

( )( ) ( )

( )( ) ( )( )( ) ( )

( )( ) ( )

n

nn

nn

y y y y y y xy y y y y yy y y y y y xy y y y y y

… …………

Note:Lagrange’s interpolation formula can be used for equal and unequal intervals.

Part A:1. What is the assumptions we make when Lagrange’s formula is

used?Sol: Lagrange’s interpolation formula can be used whether the values of x, the independent variable are equally spaced or not whether the difference of y become smaller or not.

2. What is the disadvantage in practice in applying Lagrange’s interpolation formula?Sol: Though Lagrange’s formula is simple and easy to remember, its application is not speedy. It requires close attention to sign and there is always a chance of committing some error due to a number of positive and negative signs in the numerator and the denominator.

UNIT II: INTERPOLATION AND APPROXIMATIONLagrangian Polynomials – Divided differences – Interpolating with a cubicspline – Newton’s forward and backward difference formulas.

Page 2: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

2 UNIT II: Interpolation And Approximation

3. What is ‘inverse interpolation’?Sol: Suppose we are given a table of values of x and y. Direct interpolation is the process if finding the values of y corresponding to a value of x, not present in the table. Inverse interpolation is the process of finding the values of x corresponding to a value of y, not present in the table.

4. Construct a linear interpolating polynomial given the points 0 0 1 1( , ) and ( , ).x y x y

Sol:01

0 10 1 1 0

( )( )( ) ( )( ) ( )

x xx xy y x f x y yx x x x

5. What is the Lagrange’s formula to find ‘y’ if three sets of values 0 0 1 1 2 2( , ),( , ) and ( , )x y x y x y are given.

Sol:0 2 0 11 2

0 1 20 1 0 2 1 0 1 2 2 0 2 1

( )( ) ( )( )( )( )( )( ) ( )( ) ( )( )

x x x x x x x xx x x xy y y yx x x x x x x x x x x x

6. Find the second degree polynomial fitting the following data:x 1 2 4y 4 5 13Sol: Here x0 =

1, x1 = 2, x2 = 4y0 = 4, y2 = 5, y3 = 13

By Lagrange’s formula for three points is 0 2 0 11 2

0 1 20 1 0 2 1 0 1 2 2 0 2 1

( )( ) ( )( )( )( )( )( ) ( )( ) ( )( )

x x x x x x x xx x x xy y y yx x x x x x x x x x x x

( 2)( 4) ( 1)( 4) ( 1)( 2)(4) (5) (13)(1 2)(1 4) (2 1)(2 4) (4 1)(4 2)x x x x x xy

2 2 2

2 2 2

2 2 2

2

( 6 8) ( 5 4) ( 3 2)(4) (5) (13)( 1)( 3) (1)( 2) (3)(2)

( 6 8) ( 5 4) ( 3 2) (4) (5) (13)3 2 6

1 8 48 64 15 75 60 13 39 2661 6 12 306

x x x x x xy

x x x x x x

x x x x x x

x x

Part B:Eg.1. Using Lagrange interpolation formula, find f(4) given that

(0) 2, (1) 3, (2) 12, (15) 3578.f f f f

Sol:Given x 0 0x 1 1x 2 2x 3 15x

y = f(x) 0 2y 1 3y 2 12y 3 3587y

Lagrange interpolation formula is

2( ) 2 5y f x x x

Page 3: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

3MA8491 Numerical Methods .

1 2 3 0 2 30 1

0 1 0 2 0 3 1 0 1 2 1 30 1 3 0 1 2

2 32 0 2 1 2 3 3 0 3 1 3 2

( )( )( ) ( )( )( )( )( )( ) ( )( )( )

( )( )( ) ( )( )( )

( )( )( ) ( )( )( )(4 1)(4 2)(4 15)4(0 1)(0 2)(

x x x x x x x x x x x xy y y

x x x x x x x x x x x xx x x x x x x x x x x x

y yx x x x x x x x x x x x

f

(4 0)(4 2)(4 15)2 30 15) (1 0)(1 2)(1 15)

(4 0)(4 1)(4 15) (4 0)(4 1)(4 2) 12 3587(2 0)(2 1)(2 15) (15 0)(15 1)(15 2)(3)(2)( 11) (4)(2)( 11)2 3

( 1)( 2)( 15) (1)( 1)( 14)(4)(3)( 11) (4)(3)( 2 12(2)(1)( 13)

) 3587(15)(14)(13)

77.99 78

CW.2. Find polynomial f(x) by using Lagrange formula from the given data and find f(8).

x 3 7 9 10f(x) 168 120 72 63

Sol: Lagrange polynomial f(x) = x3 – 21 x2 + 119 x – 27.y(x = 8) or y(x = 8) or f(x = 8) = 93

HW.3. Use Lagrange’s formula to fit a polynomial to the data x – 1 0 2 3

y = f(x) – 8 3 1 12and hence find y(1).Sol: Lagrange polynomial f(x) = 2 x3 – 6 x2 + 3 x + 3.

y(x = 1) = y(x = 1) = f(x = 1) = 2.Eg.4. Using Lagrange’s formula, prove that

1 3 5 3 3 50.3( ) 0.2( ).y y y y y y

Sol: From the equation, the values of x are0 31 2

1 3 2 30 5 3 5

5 53 3x xx xy y y yy y y y

The x values are not equally space, so use Lagrange’s formula to find y = f(x). Lagrange’s formula for a set of 4 pair of values is

1 2 3 0 2 30 1

0 1 0 2 0 3 1 0 1 2 1 30 1 3 0 1 2

22 0 2 1 2 3 3 0 3 1 3 2

( )( )( ) ( )( )( )( )( )( ) ( )( )( )

( )( )( ) ( )( )( )

( )( )( ) ( )( )( )

xx x x x x x x x x x x x

y y f x y yx x x x x x x x x x x x

x x x x x x x x x x x xy y

x x x x x x x x x x x x

3

5 3

3 5

( 3)( 3)( 5) ( 5)( 3)( 5) ( 5 3)( 5 3)( 5 5) ( 3 5)( 3 3)( 3 5)

( 5)( 3)( 5) ( 5)( 3)( 3) (3 5)(3 3)(3 5) (5 5)(5 3)(5 3)

x x x x x xy y

x x x x x xy y

Page 4: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

4 UNIT II: Interpolation And Approximation

1 5 3

3 5

5 3 3 55 3

Put 1, we get(1 3)(1 3)(1 5) (1 5)(1 3)(1 5)

( 5 3)( 5 3)( 5 5) ( 3 5)( 3 3)( 3 5)(1 5)(1 3)(1 5) (1 5)(1 3)(1 3) (3 5)(3 3)(3 5) (5 5)(5 3)(5 3)0.2 0.5 0.30.2 0.2 0.

xy y y

y y

y y y yy y

3 3 51 3 5 3 3 5

3 0.30.3( ) 0.2( )

y y yy y y y y y

CW.5. Find the age corresponding to the annuity value 13.6 from the given table

Age (x) 30 35 40 45 50Annuity value (y) 15.9 14.9 14.1 13.3 12.5

Sol: x13.6 or (y = 13.6) = 43HW.6. Find x for which y = 7, given

x 1 3 4y 4 12 19

Sol: x(y = 7) = 1.8572Anna University Questions:

AU1. Use Lagrange formula to calculate f(3) from the following table.x 0 1 2 4 5 6

f(x) 1 14 15 5 6 19 (Anna Univ. Nov./Dec., 2007(EEE)) Ans: f(3) = 10

AU2. Find the Lagrange’s polynomial of degree 3 to fit the data : y(0) = −12, y(1) = 0, y(3) = 6 and y(4) = 12. Hence find y(2).

(M/J, 2007) Ans: f(x) = x3 − 7x2 + 18x − 12; y(2) = 4AU3. From the given table, the values of y are consecutive terms of a

series of which 23.6 is the 6th term. Find the first and tenth terms of the series.x 3 4 5 6 4 5 6y 4.8 8.4 14.5 23.6 36.2 52.8 73.9

(N/D, 2007) Ans: y(x) = 1

12 [x3 + 3x2 − 14.8x + 48]; y(1) = 3.1; y(10) = 100

AU4. Find the missing term in the following table using Lagrange’s interpolation.

x 0 1 2 3 4y 1 3 9 – 81

Ans: 31AU5. Find the value of x corresponding to y = 100 from the table.

x 3 5 7 9 11y 6 24 58 108 174

Ans: 8.656

Page 5: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

5MA8491 Numerical Methods .

Topic 2 : Divided Difference (Equally and unequally spaced intervals)First divided difference for arguments 0 1,x x :

1 00 1 0 0 1 1 0 1

1 01 0

( ) ( )( , ) ( ) [ , ]( )[ , ] ( )

x x

f x f xf x x f x x x or x x f x

x x

First divided difference for arguments 1 2, :x x

2 11 2 1 1 2 2 1 2

2 12 1

( ) ( )( , ) ( ) [ , ]( )[ , ] ( )

x x

f x f x f x x f x x x or x x f xx x

Second divided difference for arguments 0 1 2, , :x x x

1 022 1

0 1 2 0 0 1 22 12 0

( ) ( )( , , ) ( ) [ , , ]x x

x x

f x f xf x x x f x x x x

x x

Second divided difference for arguments 1 2 3, , :x x x

2 123 2

1 2 3 1 1 2 33 23 1

( ) ( )( , , ) ( ) [ , , ]x x

x x

f x f xf x x x f x x x x

x x

Third divided difference for arguments 0 1 2 3, , , :x x x x2 2

1 033 2 2 1

0 1 2 3 0 0 1 2 33 2 13 0

( ) ( )( , , , ) ( ) [ , , , ]x x x x

x x x

f x f xf x x x x f x x x x x

x x

Third divided difference for arguments 1 2 3 4, , , :x x x x

2 22 1

34 3 3 21 2 3 4 1 1 2 3 4

4 3 24 1

( ) ( )( , , , ) ( ) [ , , , ]x x x x

x x x

f x f xf x x x x f x x x x x

x x

Properties of divided differences:1. The divided difference are symmetric functions of their arguments.

For example, ( ) ( )

y xf x f y

2 2 2( ) ( ) ( )yz xz xy

f x f y f z

2. The nth divided differences of a polynomial of degree n are constants.

3. The divided difference operator( ) is a linear operator.[ ( ) ( )] [ ( )] [ ( )]f x g x f x g x

and [ ( )] [ ( )]cf x c f x , c is constant.Part A:

7. Prove that 2 3

yzx x y z

.

Sol: Given the function 3( )f x x and the arguments are x,y,z.

Page 6: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

6 UNIT II: Interpolation And Approximation 3 3 2 2

2 2( ) ( ) ( )( )( )y

f y f x y x y x x xy yf x x xy yy x y x y x

Similarly, 2 2( )

zf y y yz z

2 2 2 22

( ) ( )( )Now ( ) z y

yz

f y f xy yz z x xy yf x

z x z x

2 2 ( )( ) ( )z x yz xy z x z x y z x x y zz x z x

8. Show that 3 1 1

bcd a abcd

.

Sol: If 1 1( ) , ( )f x f ax a

1 1

1 ( ) ( ) 1( , )b

f b f a b af a ba b a b a ab

Similarly,1 1 1 1( , ) , ( , )

c df b c f c d

b bc c cd

2

1 1 1 11 1( , , )

( )c b

bc

a cb b bc abf a b ca c a c a abc c a abc

Similarly,2 1 1( , , )

cdf b c d

b bcd

2 23

1 1 1 11( , , , ) cd bc

bcdb a bcd abcf a b c d

a d a d a

1

( )a d

abc d a abcd

Part B:Eg.7. Construct the divided difference table for the following data and find

the value f(2).x 4 5 7 10 11 12

y = f(x) 50 102 296 800 1010 1224Sol: Newton’s divided difference formula is

0 0 0 1 0 1 0 1 20 1 2 0 1 2 3

, , , , , ,f x f x x x f x x x x x x f x x x

x x x x x x f x x x x

Page 7: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

7MA8491 Numerical Methods .

Newton’s divided difference table is

x f(x) 0 1

( )

,

f x

f x x

0 1 2, ,

2 ( )

f x x x

f x

0 1 2 3, , ,

3 ( )

f x x x x

f x

0 1 2 3 4

4

, , , ,

( )

f x x x x x

f x

0 1 2 3 4 5

5

, , , , ,

( )

f x x x x x x

f x

4 50102 50

525 4

5 10297 52

157 4

296 10297

7 5

14.2 150.133

10 4

7 296168 97

14.210 5

.617 .133.069

11 4

800 296168

10 7

10.5 14.2.617

11 5

.158 .069.011

12 5

10 800210 168

10.511 7

1.7 .617.158

12 5

1010 800210

11 10

2 10.51.7

12 7

11 1010214 210

212 10

1224 1010214

12 11

12 1224

50 4 52 4 5 15 4 5 7 0.133 4 5 7 10 0.069 4 5 7 10 11 0.011

f x x x x x x xx x x xx x x x x

2 50 2 4 52 2 4 2 5 15 2 4 2 5 2 7 0.133 2 4 2 5 2 7 2 10 0.069 2 4 2 5 2 7 2 10 11 0.011

49.19

f x

x

CW.8. If f(0) = 0, f(1) = 0, f(2) = –12, f(4) = 0, f(5) = 600, f(7) = 7308, find a polynomial that satisfies this data using Newton’s devided difference formula. Hence find f(6), f(–1).

Sol: f(x) = 3 2( 1)[ 2 13 20]x x x x x

f(6) = 2580 , f(–1) = 60

Page 8: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

8 UNIT II: Interpolation And Approximation

HW.9. Find the third divided difference with arguments 2,4,9,10 of the function f(x) = x3 – 2x.Sol: Form divided difference table.

AU6. If f(0) = f(1) = 0, f(2) = −12, f(4) = 0, f(5) = 600 and f(7) = 7308, find a polynomial that satisfies this data using Newton’s divided difference interpolation formula. Hence, find f(6)(Anna Univ. May./June, 2007) Ans: f(6) = 2580

AU7. Given the valuesx 5 7 11 13 17

f(x) 150 392 1452 2366 5202Evaluate f(9) using Newton’s divided difference formula.(N/D, 2007) Ans: f(x) = x3 − x2 + 24x − 70; f(9) = 794

AU8. Using Newton’s divided difference interpolation, find the polynomial of the given data

x –1 0 1 3f(x) 2 1 0 –1

(Anna Univ. Nov./Dec., 2007) Ans: f(x) = 124 [x3 − 25x + 24]

Page 9: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

9MA8491 Numerical Methods .

Topic 3 : Interpolating with a cubic splineThe cubic spline interpolation formula is

3 31 1

2 2

1 1 1

1( ) ( ) [( ) ( ) ]61 1 ( )[ ] ( )[ ]

6 6

i i i i

i i i i i i

S x y x y x x M x x Mh

h hx x y M x x y Mh h

where 1 1 1 12

64 [ 2 ]i i i i i iM M M y y yh

n = number of datai = number of intervals [ i.e., i = 1,2,3,…, (n – 1)] h = length f interval = interval length.

Note: If ' ' and i iM y values are not given, then assume

0 0nM M

' ' ' '0[ 0]nor y y , and find 1 2 1, ,..., nM M M

in 1st interval,2nd interval,…, (n–1)th interval value. Part A:

9. What is a cubic spline?Sol: A cubic spline which has continuous slope and curvature

is called a cubic spline.10. What is a natural cubic spline?

Sol: A cubic spline fitted to the given data such that the end cubics approach linearity at their extremities is called a natural cubic spline.

11. State the conditions required for a natural cubic spline.Sol: A cubic spline g(x) fits to each of the points is continuous

and is continuous in slope and curvature such that ' '

0 0 0 0( ) 0M S g x and ' '

1( ) 0n n n nM S g x

is called a natural cubic spline. Let us assume that ( , ), 0,1, 2,...,i ix y i n are data points.

12. What are the advantages of cubic spline fitting?Sol: Cubic spline provide better approximation to the behavior

of functions that have abrupt local changes. Further, spline perform better than higher order polynomial approximation.

13. Write the end conditions on M i (x) in natural cubic spline. Sol: 0 ( ) 0, ( ) 0.nM x M x

14. Write the relation between the second derivatives M i (x) in cubic splines with equal mesh spacing.

Sol: 1 1 1 12

64 [ 2 ]i i i i i iM M M y y yh

,i = 1,2,…,n – 1.Or

1 1 1 12

64 [ 2 ]i i i i i iM M M f f fh

,i = 1,2,…,n – 1.

Page 10: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

10 UNIT II: Interpolation And Approximation

Part B:Eg.10. Find the cubic spline approximation for the function f(x) given by

the data:x 0 1 2 3

y = f(x) 1 2 33 244with 0 30 .M M Hence estimate the value f(1.5),f(2.5). {AU2010}

Sol: We know that cubic spline interpolation formula for 1 , 1,2,3.i ix x x i is

3 31 1

2

1 1

2

1

16

1 6

1 (1)6

i

i i i i

i i i

i i i

S x y x y

x x M x x Mh

hx x y Mh

hx x y Mh

1 1 1 126where M +4M M = 2 (2)i i i i i iy y yh

number of data 4number of intervals 3 i.e., 1, 2,3.length of inteval 1

hi ih

Given 0 2 1 20, so find , .M M M M

"0 3

1 2

Suppose or values are not given, then assume 0 and find , .

i iM y M MM M

1 2To find , :M M

0 1 2 0 1 22

1 21 2

1 2 3 1 2 32

6When 1, (2) 4 21

0 4 6 1 2 2 33 4 180 (3)

6When 2, (2) 4 21

i M M M y y y

M MM M

i M M M y y y

1 21 2

1 21 2

4 0 6 2 2 2 244 4 180 (4)Solving 3 & 4 , 3 4 180 4 4 4 16 4320

M MM M

M MM M

22

1 1

15 4140 276 3 4 180 276 24

MM

M M

Page 11: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

11MA8491 Numerical Methods .

To find Cubic spline:

10 1

When 1, Cubic spline in . ., . ., 0 1 . ., Cubic spline in 0 1 is

i i

ix x x

i e x x xi e x

i e x

331 1 1 0 0 1

1 0 0 0 1 1

3 3

1 6 11 1 1 1 1 6 1 6

1 1 0 0 246

y x S x x x M x x M

x x y M x x y M

x x

3

3

1 1 0 0 2 24 4 1 6 4 5 1

x xx x xx x

11 2

When 2, Cubic spline in . ., . ., 1 2 . ., Cubic spline in 1 2 is

i i

ix x x

i e x x xi e x

i e x

3 32 2 2 1 1 2

2 1 1 1 2 2

3 3

1 6 1

1 1 1 1 1 6 1 6

1 2 24 1 2766

y x S x x x M x x M

x x y M x x y M

x x

3 3

3 2

1 1 2 2 24 1 33 2766 6

4 2 46 1 6 2 13 1 50 162 162 53

x x

x x x xx x x

12 3

When 3, Cubic spline in . ., . ., 2 3 . ., Cubic spline in 2 3 is

i i

ix x x

i e x x xi e x

i e x

3 33 3 3 2 2 3

3 2 2 2 3 3

3

1 6 11 1 1 1 1 6 1 6

1 3 276 06

y x S x x x M x x M

x x y M x x y M

x

3 2

3 2

1 3 33 276 2 244 06

46 27 9 27 13 3 244 488 46 414 985 715

x x

x x x x xx x x

Page 12: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

12 UNIT II: Interpolation And Approximation

31 1

3 22 2

3 23 3

Cubic spline is ( ) ( ) 4 5 1, 0 1

( ) ( ) ( ) 50 162 167 53, 1 2( ) ( ) 46 414 985 715, 2 3

S x y x x x xS x S x y x x x x x

S x y x x x x x

3 22 2

33 3

When 1.5, ( 1.5) ( 1.5) 50 1.5 162 1.5 167 1.5 53 1.75,When 2.5, ( 2.5) ( 2.5) 46 2.5 414 2.

xy x S x

xy x S x

25 985 2.5 715

121.25

CW.11. From the following table .x 1 2 3

y = f(x) –8 –1 18

Find cubic spline and compute y(1.5),' '(1), (2.5) and (3).y y y

Sol:

31 1

32 2

( ) ( ) 3( 1) 4 12, 1 2( )( ) ( ) 3(3 ) 22 48, 2 3

S x y x x x xS xS x y x x x x

&

' '1 1

' '2 2

45( 1.5) ( 1.5) , ( 1) ( 1) 48

( 2.5) ( 2.5) 7.375, ( 3) ( 3) 22.

y x S x y x S x

y x S x y x S x

HW.12. Fit a natural cubic spline for the following data: {AU2008}

x 0 1 2 3y = f(x) 1 4 0 –2

Sol: Assume 0 30 .M M

31 1

3 22 2

3 23 3

( ) ( ) 2 5 1, [0,1]( ) ( ) ( ) 3 15 20 4, [1,2]

( ) ( ) 9 28 28, [2,3]

S x y x x xS x S x y x x x x

S x y x x x x

Anna University Questions:AU9. Find the cubic Spline interpolation. (N/D, 2007)

X 1 2 3 4 5f(x) 1 0 1 0 1

Sol: Assume 0 40 .M M

( ) ( ) 2 , 1 21 11 3 2( ) ( ) [ 5 45 123 106], 2 32 2 71( ) ( ) 3 2( ) ( ) [6 72 275 332], 3 43 3 71 3 2( ) ( ) [ 5 75 363 772], 4 54 4 7

S x y x x x

S x y x x x x x

f x S x S x y x x x x x

S x y x x x x x

Page 13: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

13MA8491 Numerical Methods .

AU10.Given the following table, find f(2.5) using cubic spline functions :x 1 2 3 4

f(x) 0.5 0.3333 0.25 0.2(Anna Univ. May./June, 2007) Ans: S2(2.5) = 0.2829AU11.Fit the st.line for the data. (Anna Univ. May/June, 2007)

x 0 1 2 3f(x) 1 2 9 28

31

3 22

3 23

4 4( ) 1, 0 15 51( ) ( ) [10 18 19 1, 1 25

102 333 159( ) 2 , 2 35 5 5

y x x x x

f x y x x x x x

y x x x x x

Topic 4 : Newton’s forward and backward difference formulas*[Uniform (or) equal intervals only] *

Newton’s forward interpolation difference formula:[if y(required x near to 0x ) = ? and use ]

02 3

0 0 0 0

( ) ( ) ( )( 1) ( 1)( 2) = ...

1! 2! 3!

y x f x f x uhu u u u u uy y y y

where 0 ,

x xuh

h = length of interval Newton’s backward interpolation difference formula:

[if y(required x near to nx ) = ? and use ]

2 3( ) ( ) ( )

( 1) ( 1)( 2) ...1! 2! 3!

n

n n n n

y x f x f x vhv v v v v vy y y y

where ,n

x xvh

h = length of intervalPart A:

15. What advantage has Lagrange’s formula over Newton?Sol: The forward and backward interpolation formulae of Newton can be used only when the values of the independent variable x are equally spaced can also be used when the differences of the dependent variable y become smaller ultimately. But Lagrange’s interpolation formula can be used whether the values of x, the independent variable are equally spaced or not and whether the difference of y become smaller or not.

Page 14: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

14 UNIT II: Interpolation And Approximation 16. Derive Newton’s forward difference formula by using operator

method. [or] Derive Gregory – Newton forward difference interpolation formula.

Page 15: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

15MA8491 Numerical Methods .

Sol: 0 0 0u u

n n nP x P x uh E P x E y

01 u y

2 3

0 0 0 0( 1) ( 1)( 2)= ...

1! 2! 3!u u u u uuy y y y

where 0x xu

h

17. Derive Newton’s backward difference formula by using operator method.

Sol: 0v v

n n n n nP x P x vh E P x E y

11 where 1v

ny E

2 3( 1) ( 1)( 2)1 ...

2! 3! nv v v v vv y

2 3( 1) ( 1)( 2) ...1! 2! 3!n n n nv v v v v vy y y y

where ,n

x xvh

18. When will we use Newton’s forward interpolation formula?Sol: The formula is used to interpolate the values of y near

the beginning of the table values and also for extrapolating the values of y short distance ahead (to the left) of y0.

19. When Newton’s backward interpolation formula is used?Sol: The formula is used mainly to interpolate the values of

y near the end of a set of tabular values and also for extrapolating the values of y short distance ahead (to the right) of yn.

Part B:Eg.13.Using New ton’s forward interpolation formula, find the cubic

polynomial which takes the following valuesx 0 1 2 3

y = f(x) 1 2 1 10Evaluate f(4). {AU 2000, 2009}

Sol: WKT, Newton forward formula to find the polynomial in x.There are only 4 data given.Hence the polynomial will be degree 3.Newton’s forward formula is

02 3

0 0 0 0

( ) ( ) ( )( 1) ( 1)( 2) = ...

1! 2! 3!

y x f x f x uhu u u u u uy y y y

where 0 ,

x xuh

h = length of interval

Page 16: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

16 UNIT II: Interpolation And Approximation

Newton’s divided difference tablex ( )y f x y 2 y

3y

0 0x 0 1y

2 1 1

1 1x 1 2y 1 1 2

1 2 1 10 2 12

2 2x 2 1y 9 1 10

10 1 9

3 3x 3 10y

3 2

1 1 21 1 2 121! 2! 3!

2 7 6 1

x x x x x xf x

x x x

When 2,(4) 41x

f

CW.14. The population of a city in a census takes once in 10 years is

given below. Estimate the population in the year 1955.Year 1951 1961 1971 1981

Population in lakhs 35 42 58 84Sol: ( 1955) ( 1955) 36.784y x f x

HW.15. From the table given below find sin 52 by using Newton’s forward interpolation formula.

x 45 50 55 60 y = sin x 0.7071 0.7660 0.8192 0.8660

Sol: ( 52) sin 52 0.788y x approximately.Eg.16.From the data given below find the number of students whose

weight is between 60 and 70.Weight in lbs 0–40 40–60 60–80 80–100 100–120

Number of students 250 120 100 70 50Sol: Let weight be denoted by x and

number of students be denoted by y, y = f(x). Use Newton's forward formula to find y where x lies between 60 – 70. Newton's forward formula is

02 3

0 0 0 0

( ) ( ) ( )( 1) ( 1)( 2) = ...

1! 2! 3!

y x f x f x uhu u u u u uy y y y

We rewrite the table as cumulative table showing the number of students less than x lbs.

x Below 40 Below 60 Below 80 Below 100 Below 120y 250 370 470 540 590

Newton's forward difference table:

Page 17: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

17MA8491 Numerical Methods .

x ( )y f x y 2 y3y

4 y

Below 40 250120

Below 60 370 –20100 –10

Below 80 470 –30 2070 10

Below 100 540 –2050

Below 120 590

Here 0 40

20x x xuh

, When 70 4070, 1.5

20x u

1.5 1.5(1.5 1) 1.5(1.5 1)(1.5 2)( 70) 250 120 20 101! 2! 3!1.5(1.5 1)(1.5 2)(1.5 3) 20

4! 423.59 424

y x

Number of students whose weight is 70 424Number of students whose weight is between 60 70 424 370 54.

CW17. Use Newton’s backward difference formula to construct as interpolating polynomial of degree 3 for the data.f(– 0.75) = – 0.07181250, f(– 0.5) = –0.024750,

f(– 0.25) = 0.33493750, f(0) = 1.10100. Find 1( ).3

f

Sol:

3 2( ) 4.001 4.002 1.101y x x x x

,1( )3

f

= 0.174518518HW.21. From the following data, find at 43x and x = 84.

x 40 50 60 70 80 90 184 204 226 250 276 304

Also express in terms of x.Sol: ( 43) 189.79x (by Newton;s forward formula)

( 84) 286.96x (by Newton;s backward formula)2( ) 0.01 1.1 124x x x (by Newton;s forward formula)

AU12. Find a polynomial of degree two for the data by Newton’s forward difference method :

x 0 1 2 3 4 5 6 7f(x) 1 2 4 7 11 16 22 29

(Anna Univ. May./June, 2007) Ans: y(x) = 21 [ 2]

2x x

Page 18: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

18 UNIT II: Interpolation And Approximation

Unit II Assignment problems:1. Find the missing term in the following table using Lagrange’s

interpolation.x 0 1 2 3 4y 1 3 9 – 81

Ans: 31

2. Find the value of

given

( ) 0.3887f

where

20

( )sin1

2

df

using the table

21 23 250.3706 0.4068 0.4433f

Sol: = 22.00203. Using Newton’s divided difference formula find f(x) and f(6) from the

following data : (M/J, 2007(EEE))x 1 2 7 8

f(x) 1 5 5 4

Ans:f(x) = 142 [3x3 − 58x2 + 321x − 224]; f(6) = 6.2381

4. Using Newton’s divided difference formula, find the value of f(8) and from the following table:

x 4 5 7 10 11 13f(x) 48 100 294 900 1210 2028

(Anna Univ. Nov./Dec., 2007(EEE)) Ans: f(8) = 448

5. Given the points (0,0), ( ,1) & ( ,0)

2

satisfying the function

sin (0 )y x x

, determine the value of ( )6

y

using the cubic spline approximation. [ Assume 0 20 .M M ]

Sol: 3

22 2 3( ) , 0,

2 2S x x x

&

0.48156 6

y S

6. Fit the cubic spline for the following data:x 0 1 2 3

y = f(x) 1 2 9 28Sol: Assume 0 30 .M M

31 1

3 22 2

3 23 3

4( ) ( ) 1, [0,1]5 51( ) ( ) ( ) (10 18 19 1, [1,2]51( ) ( ) ( 14 126 269 191, [2,3]5

xS x y x x

S x S x y x x x x

S x y x x x x

Page 19: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

19MA8491 Numerical Methods .

7. From the following table, find the value of (tan45o15’) by Newton’s forward interpolation formula.

x o 45 46 47 48 49 50tan x o 1.00000 1.03553 1.07237 1.11061 1.15037 1.19175

(M/J, 2007(EEE)) Ans: f(45o15’) = 1.008768. Given:

x 1 2 3 4 5 6 7 8f(x) 1 8 27 64 125 216 343 512

Estimate f(7.5). Use Newton’s formula.(Anna Univ. Nov./Dec., 2007(EEE)) Ans: f(7.5) = 421.87

9. The hourly declination of the moon on a day is given below. Find the declination at 3 35 15h m s and 5h .

Hour 0 1 2 3 4Declination 8 29 53.7 8 18 19.4 8 6 43.5 7 55 6.1 7 43 27.2

Ans: 3 35 15 7 48 15 , 5 1.00876h m s hy y

Page 20: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

20 UNIT II: Interpolation And Approximation

Page 21: denominator. · Lagrange’s interpolation formula can be used for equal and unequal intervals. Part A: 1. What is the assumptions we make when Lagrange’s formula is used? Sol:

21MA8491 Numerical Methods .