Top Banner
57

Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Nov 06, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct
Page 2: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Derivatives from difference table

The interpolating polynomial of degree n that fits aset of data points can be writtenas

0 1 2, , ,........

np p p p

0 0 1 0

0 1 2 0 1

1

0 1

0

( ) ( ) [ , ]( )

[ , , ]( )( )

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

n

n

n i error

i

p x f x f x x x x

f x x x x x x x

f x x x x x P!

=

= + !

+ ! !

+ ! +"

Page 3: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

The derivative of this polynomial will thenapproximate the derivative of the function and isgiven by

'

0 1 0 1 2 0 1

1

11

0 1

0

( ) [ , ] [ , , ]{( ) ( )}

( )

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

n

j n

ji nj

n

i i

p x f x x f x x x x x x x

x x

f x x xx x

error

= !

= !=

=

= + ! + !

!

+ +!

+

"#

Page 4: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

This is given by

1'

1

( )( ) ( )

( 1)!

n j n

error i i j

jj i

fP x x x

n

!+ =

="

= #+

$

Note that this error does not vanish even though weare evaluating it at a tabulated point!

Once the difference table for a given set of data isconstructed we can read of the derivative from thatat any point.

Page 5: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Derivatives from evenly spaced data In the previous example we saw that we canconstruct the polynomial and its derivative at aspecific point x by entering the difference table atvarious different points.

We will now identify the polynomial obtained byentering the difference table at point iSuppose the data given to us is evenly spaced inx such that . Then the difference tablefor a function will look like the following,

1i ih x x

+= !

( ) xf x e=

Page 6: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

0 1.30 3.669 1 1.90 6.686

2 2.50 12.182

3 3.10 22.198

4 3.70 40.447 5 4.30 73.700

6 4.90 134.290

2.041

3.0172.479

5.496

10.016

18.249

33.253

60.590

4.520

8.233

15.004

27.337

3.713

6.771

12.333

1.672

3.058

5.562 2.504

1.386 1.118

i ix ( )if x

if! 2

if! 3

if!

4

if!

5

if! 6

if!

Page 7: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Here is just the differenceand is related to the coefficients of the interpolating

polynomial through .

We will now define a variable .

In this variable we can write

similarly for other terms .

if! 1( ) ( )

i if x f x

+!

0 1 2[ , , ,........, ]

!

n

in n

ff x x x x

n h

!=

2

1( - )( - ) ( - )( - - ) ( 1)i i i i

x x x x x x x x h h s s+

= = !

ix x

sh

!=

Page 8: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

2 3

1

0

( 1) ( 1)( 2)( )

2! 3!

........ ( )!

= !

=

! ! != + " + " + "

"+ + ! +#

n i i i i

nj n

j

s s s s sP x f s f f f

fs j error

n

The derivative of this polynomial will then be

2 3

11

0 0

( ) ( )

( 1) ( 1)( 2) ( 1) ( 2)

2! 3!1

........ ( )!

n n

i i i

nj nk n

k jj k

d ds dP x P x

dx dx ds

s s s s s s s sf f f

Errorfh

s jn

= != !

= ="

=

+ ! ! ! + ! + !# $% + % + %& '& '

= +( )& '%* *& '+ + !+ ,

& '* *- ./ 0

1 2

The interpolating polynomial is then

Page 9: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

where the error term can be again evaluated usingthe next term rule of the interpolating polynomial.

An important point to note: The index i used in theabove expressions indicate the point at which weenter the difference table.

For example: if we have to compute the derivativeof at x=3.9 using the above differencetable we could enter at i=4 and use a polynomialof order one. This will result is the answer

( ) xf x e=

2 4

1 1( 3.9) (33.253)

.6 .6

dP x f Error

dx= = ! = +

Page 10: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

The parameter and theerror

is compare this

with the correct answer.

43.9 3.7 2

.6 .6 3

x xs

! != = =

27.337 2 / 3 (2 / 3 1)

.6 2Error

+ !" #= $ %& '

Problem: Write a computer program to find thederivative of the function .Construct the difference table using h=.3 in theinterval [x=1,x=4]. Evaluate the derivative and theerror in the derivative at x=2.5 by using a 4th orderpolynomial. Enter the difference table at differentpoints in the table, plot the error and derivative thusobtained against the value at which you entered thedifference table.

( ) log( )f x x x=

Page 11: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Difference formulae If we are evaluating the derivatives at one of thetabulated points then we have s=0. The derivativewill then have a simpler formula of the form

2 311

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

nni i i

n i

f f fdP x f Error

dx h n

!" #$ $ $= $ ! + + + ! +% &

' (

The error term here can be written in the form

1 1 1

0 1 1[ , ,.., ]( 1)!1 ( )

1 ( 1) 1

n n nni n

f f x x x n h fError h

h n h n n

!+ + +

+" +

= = =+ + +

Page 12: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Thus if we approximate the derivative by a secondorder polynomial the error is of third order andthe derivative is .

This is known as the forward difference formulaefor first derivative. In terms of the functions this is

equal to

A more commonly used formulae for the firstderivative is the one obtained from the polynomial

of order one that is .

' 2 21 1( ) ( )

2

! "= # $ # +% &' (

i i if x f f O h

h

[ ]' 2

1 2

1( ) 4 ( ) 3 ( ) ( ) ( )

2i i i i

f x f x f x f x O hh

+ += ! ! +

[ ]'

1

1( ) ( ) ( ) ( )

i i if x f x f x O h

h+= ! +

Page 13: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

To evaluate the derivative at if we can enter thedifference table atwe will then have s =1 and the derivative formulaeof order two will be

.

This is the central difference formulae, since thederivative here is

Note that for the same number of functionevaluation this formulae is more accurate that theforward difference formulae.We will now look at higher order derivatives.

2' 21

1

1( ) ( )

2

ii i

ff x f O h

h

!!

" #$= $ + +% &

' (

' 21 11( ) ( )

2

i ii

f ff x O h

h

+ !!" #= +$ %& '

ix

1!ix

Page 14: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Higher order derivatives The difference operator used in the previoussections is defined as

1

or

( ) ( ) ( )

( ) ( ) ( )

i i if x f x f x

f x f x h f x

+! = "

! = + "

we will now define a stepping operator by

1

( ) ( )

or

( ) ( ) i i

Ef x f x h

Ef x f x+

= +

=

Page 15: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

The relation between is and E!

( ) ( ) - ( ) ( ) -

or

( )

1

f x f x h f x Ef x f x

E

! = + =

= + !

The action of E on a function is cumulative, that is .

( )i

f x

( ) ( ) n

i i nE f x f x

+=

The derivative operator D is then defined as

Here should be an integer. That is x shouldbe one of the tabulated points.

( ) ( ) ( ) s

i s i s i

d dDf x f x E f x

dx dx+ +

= =

ix x

sh

!=

Page 16: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

We can then write

1( ) ( ) ( )s s

i s i i

d dDf x E f x E f x

dx h ds+

= =

Since

s s s

s

s

ln(E ( )) ln(E (E ( )E ( )

(E ( )

1) ln( )

ln( ) ( )

i i

i

i

s

i

d d df x f x

ds ds f x ds

df x

ds

E

E E f x

= = =

=

Page 17: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Therefore for s=0

1 1( ) ln( ) ( ) or ln(1 )

i iDf x E f x D

h h= = + !

Using Maclaurins series we can then recover thedifference formulae for the first derivatives to anyorder as

'

2 3

1( ) = ( ) ln(1 ) ( )

( ) ( )1 ( ) ......

2 3

i i i

i ii

f x Df x f xh

f x f xf x

h

= + !

" #! != ! $ + $% &

' (

Page 18: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

The higher order derivatives can now be obtainedby the repeated application of the derivativeoperator. For example the second derivative is ,

2

''

2 3 4 5

2

1( ) = ( ) ln(1 ) ( )

1 11 5 ( ) ( ) ( ) ( ) ......

12 6

i i i

i i i i

f x DDf x f xh

f x f x f x f xh

! "= + #$ %& '

( )= # *# + # * # ++ ,

- .

Problem 1: Tabulate the bessel functionbetween the interval (1,2) and find the first , secondand third derivative at x=2.1. Use the differenceformulae of order 1,2 and 3. Tabulate the error ineach of the derivatives against the order of thedifference formulae used.

0 ( )J x

Page 19: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Numerical Integration: Basic rules

Analytical formulae for integrals

is not always available. Some times we do not knowthe functional form and have only a set of tabulateddata points. In both cases it is necessary to usenumerical methods to evaluate the integrals.

( ) ( )

b

a

I f f x dx= !

There are many numerical methods for evaluatingderivatives . The theoretical basis for all thesemethods are the same. We will look at that now.

Page 20: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

We approximate the function by polynomial (x) of degree which interpolates the function at the points . Then theapproximation for the integral is . The error in the approximation ofthe function by a polynomial is given by thefollowing equation,

( )f x

k!( )f x 0

,...,k

x x

( ) ( )k

I f I p!( ( ))I f x

kp

0( ) ( ) [ ,..., , ] ( )k k k

f x p x f x x x x= + !

where

0

( ) ( )k

k j

j

x x x=

! = "#

Page 21: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

where is a continuous and integrablefunction of x .

0[ ,..., , ]

kf x x x

The error in the estimate of I( ) is thenkp

0( ) ( ) ( ) [ ,..., , ] ( )

b

k k k

a

E f I f I p f x x x x dx= ! = "#

If is of one sign in the interval (a ,b), then byusing the mean-value theorem for integrals, thiserror can be written as

( )kx!

Page 22: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

0 0[ ,..., , ] ( ) [ ,..., , ] ( )

b b

k k k k

a a

f x x x x f x x x dx! = " !# #

( , )some a b!"

If is k+1 times continuously differentiableon (c ,d) the Error term can be written as

( )f x

( 1)1( ) ( ) ( )

( 1)!

b

k

k

a

E f f x dxk

+= ! "

+ # ( , )some c d!"

Page 23: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

But when is not of the same sign but

. In such a case we use

( )kx!

( ) 0

b

k

a

x dx! ="

0 0 1

0 1 1

[ ,..., , ] [ ,..., , ]

[ ,..., , ]( )

k k k

k k

f x x x f x x x

f x x x x x

+

+ +

=

+ !

1

0 1 0 1

a

[ ,...,

which is valid for arbitrary . since

] ( ) [ ,..., ]

,

( 0

)

k

b b

k k k k

a

x

f x x x dx f x x x dx

+

+ +! = ! =" "

Page 24: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

0 1

0 1 1

( ) [ ,..., ] ( )

we can writ

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

e

b

k k

a

b

k k k

a

E f f x x x dx

f x x x x x x

+

+ +

= !

+ " !

#

#If we choose in such a way that isof one sign on (a ,b) and if is (k+2) timesdifferentiable , then it follows

1kx

+ 1( )kx

+!

( )f x

( 2)

1

1( ) ( ) ( )

( 2)!

b

k

k

a

E f f x dxk

+

+= ! "

+ # ( , )some c d!"

Page 25: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Thus the error here is of the order of . Onthe other hand if we had chosen in such away that the integral of between thelimits (a ,b) is zero then we can continue the sameprocedure to make the error of the order ofand so on.

2kf

+

3kf

+

1kx

+

1( )kx

+!

Page 26: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Rectangular , Mid point andTrapezoidal rules

We now study more specific cases of polynomialapproximation by considering polynomials ofdifferent order k .Let k=0, Then

0 0 0

0 0 0

( ) ( ) [ , ]( )

( ) [ , ]( )

f x p x f x x x x

f x f x x x x

= + !

= + !

Page 27: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Hence

0 0( ) ( ) ( - ) ( )

b

k

a

I p p x b a f x= =!

If then this approximation becomes0x a=

( ) ( - ) ( )I f R b a f a! =

This is called the Rectangle rule.

Page 28: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

The error in this case is of the order of firstderivative of and is given by,( )f x

2'( )( )'( ) ( )

2

b

R

a

f b aE f x a dx

! "= ! " =#

If , then does not have one

sign and satisfy . In this case as

discussed in the previous section we have tochoose another point to define the error.

0

( )

2

a bx

+= 0 ( )x!

0( ) 0

b

a

x x dx! ="

1x

Page 29: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

The error in I( ) with = is 0xk

p1x

3''( )( )

24

M f b aE

! "= (a,b)some !"

And

( ) ( - )2

a bI f M b a f

+! "# = $ %

& '

This gives the mid-point rule .

Page 30: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Next let us consider the case of k=1, then

1 0 1 1

0 0 1 0

0 1 1

( ) ( ) [ , , ] ( )

( ) [ , ]( )

[ , , ] ( )

f x p x f x x x x

f x f x x x x

f x x x x

= + !

= + "

+ !

If we choose the error function is of one sign .

0 1, x a x b= =

1( ) ( 0)( 1)x x x x x! = " " ( , )a b

Page 31: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Then

1 ( ) ( )[ ( ) ( )]

2I f b a f a f b! " +

3''( )( )

12

T f b aE

! "= " for (a,b) some !"

{ }( ) ( ) [ , ]( )

1 ''( ) ( )( )

2

b

a

b

a

I f f a f a b x a dx

f x a x b dx

= + !

+ " ! !

#

#

This is the Trapezoidal rule .

Page 32: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Problem: Evaluate the integral using

the rectangular, midpoint and trapezoidal rules.Calculate the error using the next term rule.

/ 2

2

0

cos ( )x dx!"

Page 33: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Simpsons rule

Here we use a polynomial of order two. i.e. we setk=2 and write the approximate polynomial to be

2 0 1 2 2 ( ) ( ) [ , , ] ( )f x p x f x x x x= + !

If we choose the three points at which the functionas to evaluated as

0 2 1 , ,

2

a bx a x x b

+= = =

Page 34: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

2 ( ) ( ) [ , ]( )

, , ( )( )2

p x f a f a b x a

a bf a b x a x b

= + !

+" #+ ! !$ %& '

The approximation for the integral is then 2

2

3

( )( ) ( )( ) [ , ]

2

( ) , ,

2 6

b

a

b ap x dx f a b a f a b

a b b af a b

!= ! +

+ !" #! $ %& '

(

Page 35: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

2

( ) ( )[ , ]

( )

, , , ,2 2

2 = ( ) ( ) 2

( - ) 2

f b f cf a b

b a

a b a bf a b f a b

a bf b f a f

b a

!=

!

+ +" # " #=$ % $ %& ' & '

( )+( )+ ! * +* +

, -, -

Page 36: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

2

( ) ( )( ) ( )( ) ( - )

2

2 ( ) 2 ( ) ( )2

6

b

a

f b f ap x dx f a b a b a

a bf b f f a b a

!" #= ! + $ %

& '

" #+" #! + !$ %$ %

& '& '!

(

or

( ) ( ) 4 ( )6 2

b a a bI f f a f f b

! "# +$ %& + +' () *

+ ,- .This is Simpsons rule

Hence

Page 37: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

The error in this integration is given by

s ( )[( ) / 2]E

90

ivf b a! "

= "

Click here to see animated comparison of thevarious integration methods

Page 38: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct
Page 39: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Gaussian Rules

The idea of Gaussian rules is to write the integral ofthe function in the form

which is the weighted sum of the function values . The points are sochosen that the error in an n point Gaussianintegration is proportional to the (2n+1)th derivativeof .

0 0 1 1( ) ( ) ( ) ( ) ... ( )k k k

I f I p A f x A f x A f x! = + + +

0( ),..., ( )k

f x f x0 1 2( , , ,.... )

nx x x x

( )f x

Page 40: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Many times it is advantages to write the integral tobe evaluated as

( ) ( ) ( ) ( )f x dx I g g x W x dx= =! !The form is especially useful when the functionis ill behaved in the interval of interest. In suchcases we may be able to split the function as aproduct of two functions, with g(x) as a wellbehaved function. We can then approximate thefunction g(x) by a polynomial and write,

( )f x

0 1 k( ) ( ) [ , ,..., ] ( )k k

g x P x f x x x x= + !

Page 41: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

The error in the integration, then is,

0 1( ) ( ) [ , ,..., ] ( ) ( )k k

E I g I P g x x x W x x dx= ! = "#where

0

( ) ( )k

k i

i

x x x

=

! = "#

As explained before if thenthe error become

b

a

( ) ( ) 0k

W x x dx! ="

0 1 1 1 [ , ,... , ] ( ) ( )k k

E g x x x x x W x dx+ +

= !"and so on.

Page 42: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Now for a polynomial of order k if we are able tochoose points such that

1 2 3( , , ,..... )k k k k mx x x x

+ + + +

b

1 2 1

a

( )( )( - )( - )...( - ) 0 k k k i

W x x x x x x x x dx+ + + +

=!

1,..., -1for i m=

then the error term becomes

0 1 1 1[ , ,..., ] ( )

b

k m k m

a

E g x x x W x dx+ + + +

= !"

Page 43: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Gaussian integration is a clever way of choosing npoints at which the function is to evaluated such thatthe error is of the order of (2n+1)th derivative.

We will use the Legendere form for the polynomialapproximation to the function g(x) to write

k

0 0

p ( ) ( )kk

j

i

i j i jj i

x xx g x

x x= =!

"=

"#$

Page 44: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

The integral is then given by

k

0 00

0

I(p ) ( ) ( )

( )

= ==!

=

" "= =

" "

=

# #$% %

#

b bkk kj j

i i

i ij i j i ja aj i

k

i i

i

x x x xg x Wdx g x Wdx

x x x x

A g x

Thus the integral is reduced to a weighted sum ofthe function values at a set of points with theweights given by

0

b kj

i

j i jaj i

x xA Wdx

x x=!

"=

"#$

Page 45: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

We will now look at the error in this integration.This is given by

0 1 1

2

1

[ , ,..... , ]

( )

( 2)!

b

n k

a

bk

k

a

E g x x x x Wdx

gWdx

k

+

+

+

= !

"= !

+

#

#

Our aim is now to choose these k points at whichthe function has to be evaluated such that the erroris of the order of (2k+1)th derivative.

Page 46: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

For this let us assume that we have a set of 2k+1points such that

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

b

k k k k

a

E x x x x x x Wdx+ + + +

= ! " " " =#

Since we can write the integrand

in the above expression for error as the product of apolynomial of order k+1 and anotherpolynomial of order m given by .

0

( ) ( )k

k i

i

x x x

=

! = "#

1 1 1k k kp

+ + += ! "

1 2

1

( )( )...( ) mk k k m

k

qx x x x x x

+ + +

+

! ! ! ="

Page 47: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

We will now choose to evaluate the function at thek+1 zeros of the polynomial and choosepoints such that

Then these two polynomials satisfy theorthogonality relation

1kp

+

1 0 2 1 1, ,......,

k k k i ix x x x x x

+ + + != = =

for 0,1,....,i k=

10 for

b

k m

a

p q Wdx m k+

= !"

Page 48: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

The properties of the orthogonal polynomials thentell us that the points are the zeros of thepolynomial satisfying the orthogonality relation

10 for

b

k m

a

p q Wdx m k+

= !"

The choice of these polynomial whose zeros are thepoints at which the function has to be evaluatednow depend on the limits of integration. Here arefew examples of orthogonal polynomials and thecorresponding orthogonality relations.

Page 49: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

1

1

1

2 1/ 2

1

0 for m 1

0 for

:

:

m 1(1 )

k m

k m

Legendre

Chebys

p q

he

dx k

p qdx k

x

v

+

!

+

!

= " !

= " !!

#

#

Page 50: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

2

0

0 for m

:

1

0 for

:

m 1

x

k m

x

k m

Laguarre

H

p q x e dx k

p q e dx

ermi

k

te

!

" #

!

#

#!

= $ #

= $ #

%

%

We will illustrate the use of these polynomials inthe Gaussian integration with few examples in thenext page .

Page 51: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Example 1: Evaluate the integralusing

four point Gaussian quadrature.

1

2 2

0

xx e dx

!

"

We change the variable such that the limits ofintegration are from -1 to +1. This is achieved bytaking the integral is then1 2t x= ! +

1 1

2 2 2 (1 )

0 1

1(1 )

4

x tI x e dx t e dt

+

! ! +

!

= = +" "We will then write the integral as the sum

0 0 1 1 2 2 3 3( ) ( ) ( ) ( )I A g x A g x A g x A g x= + + +

Page 52: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

If we use the function , then the

four points are the four zeros of the

fourth order Legendere polynomial

and the weights are given by

2 (1 )1( ) (1 )

4

xg x x e

! += +

0 1 2 3, , ,x x x x

4 235 6 3

8 7 35x x! "

# +$ %& '

1 3

01

( )

( )

jj

i

j i jj i

x xA dx

x x

+ =

=!"

!=

!#$

Page 53: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

1 3

00

( )1

2 ( )

jj

i

j i jj i

x xA dx

x x

+ =

=!

"=

"#$

On the other hand if we are usingthen the points at which the function to be

evaluated are

and the weights are given by

2 2( ) xg x x e

!=

0 01 2(1 ) (1 )(1 ) (1 )

, , and 2 2 2 2

x xx x+ ++ +

( )g x

Page 54: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

In general for an integral of the form

the weights are determined by

with the function evaluated at the points

With as the zeros of the Legendere polynomial.

( )

b

a

I f x dx= !

3

0

( )

2 ( )

b jj

i

j i jaj i

x xb aA dx

x x

=

=!

""=

"#$

'

2 2j j

a b a bx x

+ != !

jx

Page 55: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Problem 1:

a) Write a program that will give the coordinates atwhich the function has to be evaluated and thecorresponding weights for a Gauss Legendre

integration to evaluate .

b) Using the program evaluate the integral

( )

b

a

I f x dx= !

24.6

1.5 .5*( 3.0)

2.5

xI x e dx

! != "

Page 56: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

Example-2: Evaluate the integral

using 6 point Gaussian quadrature.

44x

e dx

+!

"

"!

#

Ans: The orthogonal polynomials to be used here isthe Hermite polynomials that satisfy theorthognality relation .

2 22( ) ( ) [ ( )]x x

m n mn mH x H x e dx H x e!

+" +"

# #

#" #"

=$ $

Page 57: Derivatives from difference tablephysics.iitm.ac.in/~sunil/integration.pdf · 2010. 1. 16. · Derivatives from evenly spaced data In the previous example we saw that we can construct

The sixth order Hermite polynomial is given by , the zeros of whichprovide the coordinate value at which the function has to be evaluated.44( ) xg x e

!=

6 4 2

6 ( ) 64 480 240 120H x x x x= ! + !

The integral is then given by the sum 44

0 0 1 1 2 2

3 3 4 4 5 5

( ) ( ) ( )

( ) ( ) ( )

xI e dx A g x A g x A g x

A g x A g x A g x

+!

"

"!

= = + +

+ + +

#

with the weights given by 2

5

0

( )

( )

jj x

i

j i jj i

x xA e dx

x x

+! ="

="!#

"=

"$%