Sei sulla pagina 1di 10

NUMERICAL

INTEGRATION
Lec. 3.4: Newton-Cotes Integration Formulae
Dr. Niket Kaisare
Department of Chemical Engineering
IITMadras
NPTEL Course: MATLAB Programming for Numerical Computations Week-3

Numerical Integration

Integration is area under a curve

Single application
Trapezoidal Rule
Simpsons 1/3rd Rule
Simpsons 3/8th Rule

Numerical Integration

Integration is area under a curve


Single application
Trapezoidal Rule

Simpsons 1/3rd Rule


Simpsons 3/8th Rule

Numerical Integration

Integration is area under a curve


Single application
Trapezoidal Rule
Simpsons 1/3rd Rule
Simpsons 3/8th Rule

Newton Cotes Integration Formulae


Trapezoidal Rule:
On(

! # m# = / ! k + ! k +

Simpsons 1/3rd
On/(

! # m# = R ! k + 4! k + + ! k + 2

Simpsons 3/8th
OnR(

Rule:

Rule:

! # m# =

R(
p

! k + 3! k + + 3! k + 2 + ! k + 3

Local Truncation Errors


Local Truncation Errors for single application of Newton Cotes Formulae:

Method
Trapezoid
Simp 1/3rd
Simp 3/8th

Formula
(
! k
/
(
! k
R
R(
! k
p

+ ! k +

LTE
3 R

+ 4! k + + ! k + 2

3 ;

+ 3! k + + 3! k + 2 + ! k + 3

3 ;

Example
Consider example from Computational Techniques (Module 6, Part 3)

http://nptel.ac.in/courses/103106074/22:
! # = 2 # + ln #
For this function,

#/
r ! # m# = # + # ln #
2

Use Trapezoidal and Simpsons 1/3rd Rules and compare with true value

End of Lecture 3.4

NUMERICAL INTEGRATION
Lec. 3.5: Multi-Step Trapezoid/Simpsons Rules
Dr. Niket Kaisare
Department of Chemical Engineering
IITMadras
NPTEL Course: MATLAB Programming for Numerical Computations Week-3

Multiple Applications of Trapezoidal Rule


Multiple application of Trapezoidal Rule:
For Interval-1:
(

s8 = / ! k

+ ! k +

For Interval-2:

s/ =

(
/

! k +

And so on

+ ! k + 2
s = s8 + s/ + sc
=

t6O
c

2 n

a+h

Multiple Applications of Trapezoidal Rule


Multiple application of Trapezoidal Rule:
For Interval-1:
(

s8 = / !If we write: !
k + ! k + k
For Interval-2:

s/ =

(
/

! k +

And so on

= !8 , ! k + = !/, , ! v = !cn8

s+=
! + 2 !/ + + !c + !cn8
! 2k +82
s = s8 + s/ + sc
=

1
a

2 n

a+h

t6O
c

Example 1
Consider example from Computational Techniques (Module 6, Part 3)

http://nptel.ac.in/courses/103106074/22:
! # = 2 # + ln #
Compute integral using _

= 2, 5, 10, 20 intervals

Make a log-log plot of error vs. step-size

Local and Global Truncation Errors


Local Truncation Errors for single application of Newton Cotes Formulae:

Method
Trapezoid
Simp 1/3rd Rule
Simp 3/8th Rule

LTE
3 R
3 ;
3 ;

GTE
3 /
3 7
3 7

Practice Problem: Simpsons Rules

Write code for multiple applications of Simpsons 1/3rd rule

Verify global truncation errors

End of Lecture 3.5

NUMERICAL INTEGRATION
Lec. 3.6: MATLAB Functions and Application
Dr. Niket Kaisare
Department of Chemical Engineering
IITMadras
NPTEL Course: MATLAB Programming for Numerical Computations Week-3

Trapezoidal Rule: MATLAB Function trapz


Usage of MATLAB function:

I = trapz(x,fval);
Function values fval are specified at corresponding x values
We solve again for !

# = 2 # + ln #

Quadrature: MATLAB Function quad


Using functions:
Usage of MATLAB function:

@(x,y,) nameOfFun(<var list>)

I = quad(@(x) myFun(x),x);
A function myFun is defined to return ! # for a given value of #

Reactor Problem

Let us consider the reactor design problem from Computational

Techniques (Module 6, Part 4):


{|}~

mz
1 z
*
for  = 10, @ = 5 and _ = {0.5}.
w=r

x
y

8./;

End of Lecture 3.6

Potrebbero piacerti anche