Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Numerical Integration -Mathematical Modeling and Simulation-Lecture Slides, Slides of Mathematical Modeling and Simulation

These lecture slides are delivered at The LNM Institute of Information Technology by Dr. Sham Thakur for subject of Mathematical Modeling and Simulation. Its main points are: Numerical, Integration, Matlab, Functions, Single, Trapezoid, Integral, Simpson, Rule, Error

Typology: Slides

2011/2012

Uploaded on 07/03/2012

jaee
jaee 🇮🇳

4.7

(22)

101 documents

1 / 29

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture Slides
on
Modeling and Simulation
Lecture: Numerical Integration
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d

Partial preview of the text

Download Numerical Integration -Mathematical Modeling and Simulation-Lecture Slides and more Slides Mathematical Modeling and Simulation in PDF only on Docsity!

Lecture Slides

on

Modeling and Simulation

Lecture: Numerical Integration

Numerical Integration

  • When we have integral from point a to point b, such an

integral is known a definite integral and it is a solution of a

simple ordinary differential equation.

  • Numerical integration can used when the function is a

difficult to find or when its data form is given.

  • Common numerical integration techniques are:
    • Trapezoidal rule,
    • Simpson’s method,
    • Romberg Integration, and
    • Gaussian quadratures.

You can fit a straight line and / or a polynomial between two data points.

Single trapezoid

You can just fit a straight line

as approximation to actual

function and say what is area

under this straight line.

This area will have large error

as function and straight line

are not same.

Single trapezoid

Many subdivisions

can be done

between x=a and

x=b and then a

straight line fit gives

better comparison to

the actual curve.

Many trapezoid

Many trapezoids

  • The same area for two sub-intervals is given by following:

where, f(x0) and f(x2) are same as fa and fb respectively.

  • For four sub-divisions within same boundaries, the area is:
  • When there are eight sub-divisions in the same range [a, b], the area is

f(x ) f(x ) f(x )

(b a) T (^) o

( ) 1 2

1 2 2 2

 f(x ) f(x ) f(x ) f(x ) f(x ) 

(b a) T (^) o

( ) 1 2 3 4

2 2 2 2 2 4

    

 

f(x ) f(x ) f(x ) f(x )]

[ f(x ) f(x ) f(x ) f(x ) f(x )

(b a) T (^) o

( )

5 6 7 8

1 2 3 4

3

Integral : Area under the curve

  • When many sufficiently

small strips are added

we can generate the area

under the curve from x =

a to x = b with very

small error.

f(x)

   a b x

b

a

gb ga f(x)dx

Strips = 18

Here with 18 Strips of different heights and same Width we get the

area under the curve.

Integral for N trapezoids

  • The integral in general using N compound trapezoids within

the range, is given by

  • where,
  • and
  • The error in the computed integral value is given by

 ( ) 2 ( ) 2 ( ) 2 ( ) ( )

2

f x 0 f x 1 f x 2 f xN 1 f xN

x Integral     

   

x a i x i N i

   ,  0 , 1 , 2 , 3 ,,

2

  f

b a x

error

N

b a x

(  )  

  • For two subdivisions, we need to have:
  • Thus

ff ( 2. 5 )  0. 16 o

f 1  f ( 3. 5 ) 0. 0816

Integral 

( 4. 5 ) 0. 2

ff

 f(x ) f(x ) f(x ) 

(b a) T o

( ) 1 2

1 2

2 2

 

 

Example 1 on integration

  • If we divide the interval into four equal parts, then

fof ( 2. 5 ) 0. 16

x ( 4. 5  2. 5 )/ 4  0. 5

f 1  f ( 3. 0 ) 0. 111

f 2  f ( 3. 5 ) 0. 0816

f 3  f ( 4. 0 ) 0. 0625

f 1  f ( 4. 5 ) 0.
[ 0. 16 2. ( 0. 111 0. 0816 0. 0625 ) 0. 0494 ]

Integral

f(x ) f(x ) f(x ) f(x ) f(x )

(b a)
T o

( ) 1 2 3 4

2

Example 1 on integration

% Program Name: Integral_1.m

% A MATLAB script file to compute Integral of f(x)

% over an interval [a, b] by trapezoidal rule.

% It calls an external function trapez.m using

% inputs of a, b and N (number of sub-divisions).

N = 8; a = 2.5; b = 4.5;

exact_value = 0.177778;

estimated_value = trapez(a, b, N)

error = abs(100(exact_value -*

estimated_value)/exact_value)

Example 1 on integration

  • It uses a function trapez.m as a subroutine:

function z = trapez(a, b, N)

% function for integration by trapezoidal rule: trapez.m

% to be used with integral_1.m code.

delta_x = (b - a)/N;

x(1) = a;

if(x(1) == 0), error('A is zero, change it')

end

sum = 0;

f(1) = 1.0/(x(1)^2);

for i=2: N+

x(i) = x(i-1) + delta_x;

f(i) = 1/(x(i)^2);

end

if(N > 1)

for i=2: N, sum = sum + f(i); end

end

z = double((delta_x/2)(f(1) + 2sum + f(N+1)));**

Example 1 on integration

Simpson Rule

  • When we formed trapezoids, straight lines between points of a

curve were joined; much better approximation is obtained if we

join points by segments of parabolas.

  • Suppose we have two intervals for which are known, the

interpolation formula of the second order polynomial can be

obtained.

  • Integrating the polynomial in those two intervals of  x , we

obtain the integration formula:

 ( ) 4 ( ) ( )

0

f x f x f x

x

f x dx o

x

x

k

Simpson’s Rule

-. If we have 2I intervals and apply Simpson's rule repeatedly I

times , the integration formula is

  • where, the step size is
  • and

2 ( ) 4 ( ) ( )]

[ ( ) 4 ( ) 2 ( ) 4 ( ) 2 ( )

3

( )

2 1

1 2 3 4

N N N

o

b

a

f x f x f x

f x f x f x f x f x

x f x dx

   

    

 

 

 

N

b a x

(  )  

x a i x for i N i

   ,  0 , 1 , 2 , 3 ,,