You are on page 1of 10

NUMERICAL

INTEGRATION
Lec. 3.4: Newton-Cotes Integration Formulae
Dr. Niket Kaisare
Department of Chemical Engineering
IIT–Madras

NPTEL Course: MATLAB Programming for Numerical Computations — Week-3

Numerical Integration

• Integration is area under a curve

Single application
Trapezoidal Rule
Simpson’s 1/3rd Rule
Simpson’s 3/8th Rule
Numerical Integration

• Integration is area under a curve

• Single application
• Trapezoidal Rule

Simpson’s 1/3rd Rule


Simpson’s 3/8th Rule

Numerical Integration

• Integration is area under a curve

• Single application
• Trapezoidal Rule

• Simpson’s 1/3rd Rule

• Simpson’s 3/8th Rule


Newton Cotes Integration Formulae

• Trapezoidal Rule:
On( (
∫O ! # m# = / ! k + ! k + ℎ

• Simpson’s 1/3rd Rule:


On/( (
∫O ! # m# = R ! k + 4! k + ℎ + ! k + 2ℎ

• Simpson’s 3/8th Rule:


OnR( R(
∫O ! # m# = ! k + 3! k + ℎ + 3! k + 2ℎ + ! k + 3ℎ
p

Local Truncation Errors

• Local Truncation Errors for single application of Newton Cotes Formulae:

Method Formula LTE


Trapezoid (
! k + ! k + ℎ 3 ℎR
/
Simp 1/3rd (
! k + 4! k + ℎ + ! k + 2ℎ 3 ℎ;
R
Simp 3/8th R(
! k + 3! k + ℎ + 3! k + 2ℎ + ! k + 3ℎ 3 ℎ;
p
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 Simpson’s 1/3rd Rules and compare with true value

End of Lecture 3.4


NUMERICAL INTEGRATION
Lec. 3.5: Multi-Step Trapezoid/Simpson’s Rules
Dr. Niket Kaisare
Department of Chemical Engineering
IIT–Madras

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:
( 1 2 … … n
s/ = /
! k +ℎ + ! k + 2ℎ
a b
a+h
• And so on… è s = s8 + s/ + ⋯ sc
t6O
ℎ=
c
Multiple Applications of Trapezoidal Rule

• Multiple application of Trapezoidal Rule:


• For Interval-1:
(
s8 = / !If we write: !
k + ! k + ℎk = !8 , ! k + ℎ = !/, … , ! v = !cn8
• For Interval-2:

s/ =
(
! k +ℎ
s+= ! + 2 !/ + ⋯ + !c + !cn8
! 2k +82ℎ
1 2 … … n
/
a b
a+h
• And so on… è s = s8 + s/ + ⋯ sc
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 LTE GTE


Trapezoid 3 ℎR 3 ℎ/
Simp 1/3rd Rule 3 ℎ; 3 ℎ7
Simp 3/8th Rule 3 ℎ; 3 ℎ7

Practice Problem: Simpson’s Rules

• Write code for multiple applications of Simpson’s 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
IIT–Madras

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:
@(x,y,…) nameOfFun(<var list>)
• Usage of MATLAB function:
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):
{|}~
x mz
w=r y 8./;
* 1 −z
for  = 10, @ = 5 and ÄÅ_Ç = {0.5}.

End of Lecture 3.6

You might also like