0% found this document useful (0 votes)
12 views

Lecture 8

This document discusses numerical methods for differentiation and integration. It introduces Simpson's rules as higher-order Newton-Cotes formulas for numerical integration. Simpson's rules approximate the integral of a function using a polynomial of degree two or three to fit the function values at specified points. The document provides examples of applying the trapezoidal rule and two-segment trapezoidal rule to estimate integrals, illustrating the use of numerical integration methods.

Uploaded by

haqeemifarhan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Lecture 8

This document discusses numerical methods for differentiation and integration. It introduces Simpson's rules as higher-order Newton-Cotes formulas for numerical integration. Simpson's rules approximate the integral of a function using a polynomial of degree two or three to fit the function values at specified points. The document provides examples of applying the trapezoidal rule and two-segment trapezoidal rule to estimate integrals, illustrating the use of numerical integration methods.

Uploaded by

haqeemifarhan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

KIL1005: NUMERICAL METHODS FOR ENGINEERING

SEMESTER 2, SESSION 2022/2023

LECTURE 8: NUMERICAL DIFFERENTIATION


AND INTEGRATION

DR MAHAR DIANA HAMID


DEPARTMENT OF CHEMICAL ENGINEERING
INTRODUCTION
• Calculus is the mathematics of change. Because engineers must continuously
deal with systems and processes that change, calculus is an essential tool of
engineering.
• Standing in the heart of calculus are the mathematical concepts of
differentiation and integration:
y f ( xi  x)  f ( xi )

x x
dy f ( xi  x)  f ( xi )
 x lim 0
dx x
b
Total value/summation of f(x) over
I   f ( x)dx the range of x=a to x=b
a

Intergrad 2
Figure PT6.1

3
Figure PT6.2 y f ( xi  x)  f ( xi )

x x
dy f ( xi  x)  f ( xi )
 x lim 0
dx x
b
I   f ( x)dx
a

For function I, the integral


corresponds to the area under the
curve between a &b

4
NONCOMPUTER METHODS FOR
DIFFERENTIATION AND INTEGRATION
• The function to be differentiated or integrated will
typically be in one of the following three forms:

• A simple continuous function such as polynomial, an


exponential, or a trigonometric function (can be done
analytically using calculus)
• A complicated continuous function that is difficult or
impossible to differentiate or integrate directly.
• A tabulated function where values of x and f(x) are given Approximate method
at a number of discrete points, as is often the case with
experimental or field data.

5
Figure PT6.4: Equal-area differentiation
(a) The (x,y) data are tabulated, and for
each interval, a simple divided
difference ᐃy/ ᐃx is employed to
estimate the slope.
(b) The difference estimates are plotted
as a bar graph (PT6.4). Smooth curve
is superimposed to approximate the
area under the bar graph. This can be
done by drawing the curve so that
equal positive and negative areas are
balanced.
(c) Values of dy/dx can be read off the
smooth curve.

6
Figure PT6.7: Application of a numerical integration method

(a) A complicated, continuos function,

(b) Table of discrete f(x) generated from the function

(c) Use of numerical method to estimate the integral on


the basis of discrete points.

7
NEWTON-COTES INTEGRATION
FORMULAS
• The Newton-Cotes formulas are the most common
numerical integration schemes. (Open or closed)

• They are based on the strategy of replacing a complicated


function or tabulated data with an approximating function
that is easy to integrate:
b b
I   f ( x)dx   f n ( x)dx Fn(x) is a polynomial where
a a n = the order of the polynomial

f n ( x)  a0  a1 x    an 1 x n1  an x n
8
Figure 21.1: The approximation of an integral by the area under
(a) a single straight line and (b) a single parabola

A first order polynomial, n=1 A parabola, n=2

9
Figure 21.2: The approximation of an integral by the area under three straight-
line segments.
• Fig. 21.2: Three straight
strips/segments are used
to approximate the
integral. Higher-order
polynomials can be
utilized for the same
purpose.

10
NEWTON-COTES FORMULAS
• Open and closed forms of Newton-Cotes formulas are available.
• Closed – the data points at the beginning and end of the limits of integration are Focus in
this
known. subject
• Open- integration limits that extend the range of the data
THE TRAPEZOIDAL RULE
• The Trapezoidal rule is the first of the
Newton-Cotes closed integration
formulas, corresponding to the case • Derivation: p. 605
where the polynomial is first order: • Equivalent to
b b
approximating the area of
a trapezoid under the
I   f ( x)dx   f1 ( x)dx straight line connecting
a a f(a) and f(b)
• The area under this first order
polynomial is an estimate of the
integral of f(x) between the limits of a
and b:
f (a)  f (b) Trapezoidal rule
I  (b  a)
2 12
Figure 21.4
Height no.1

Width (b-a)

Trapezoid
Height no.2
𝐴𝑟𝑒𝑎 = 𝐼 ≅ 𝑤𝑖𝑑𝑡ℎ × 𝑎𝑣𝑒𝑟𝑎𝑔𝑒 ℎ𝑒𝑖𝑔ℎ𝑡

All Newton Cotes closed formulas can be expressed in the general format of
ℎ𝑒𝑖𝑔ℎ𝑡 𝑛𝑜. 1 + ℎ𝑒𝑖𝑔ℎ𝑡 𝑛𝑜. 2
𝐴𝑟𝑒𝑎 = 𝐼 ≅ (𝑏 − 𝑎) ×
2
The only difference only in the formulation of the average height
13
The Multiple Application Trapezoidal Rule

• One way to improve the accuracy of the trapezoidal rule is to


divide the integration interval from a to b into a number of
segments and apply the method to each segment (Figure 21.8)
• The areas of individual segments can then be added to yield the
integral for the entire interval.
ba
h a  x0 b  xn
n
x1 x2 xn

I  f ( x)dx   f ( x)dx     f ( x)dx


x0 x1 xn1

f ( x0 )  the
Substituting f ( xtrapezoidal
1)  f (for
f ( x1 )rule x2 )each integral 1 )  f ( xn )
f ( xnyields:
I h h   h
2 2 2
14
Figure 21.8: Application of multiple-application trapezoidal rule

f ( x0 )  f ( x1 ) f ( x1 )  f ( x2 ) f ( xn1 )  f ( xn )
I h h   h
2 2 2

𝑓 𝑥 +2∑ 𝑓 𝑥 +𝑓 𝑥
𝐼 = (𝑏 − 𝑎)
2𝑛
width Average height

15
EXAMPLE 1
Use the two-segment trapezoidal rule to estimate the integral of
𝑓 𝑥 = 0.2 + 25𝑥 − 200𝑥 + 675𝑥 − 900𝑥 + 400𝑥
From a = 0 and b=0.8
Solution:
n=2 ( h = 0.4)
f(0)=0.2
f(0.4)=2.456
. . .
f(0.8)=0.232 𝐼 = 0.8 = 1.0688
SIMPSON’S RULES
• More accurate estimate of an integral is obtained if a high-order polynomial is
used to connect the points. The formulas that result from taking the integrals
under such polynomials are called Simpson’s rules.

Simpson’s 1/3 Rule


• Results when a second-order interpolating polynomial is used.

17
Figure 21.10

18
𝐼= 𝑓(𝑥)𝑑𝑥 ≅ 𝑓 (𝑥)𝑑𝑥

𝑎=𝑥 𝑏=𝑥
(𝑥 − 𝑥 )(𝑥 − 𝑥 ) (𝑥 − 𝑥 )(𝑥 − 𝑥 ) (𝑥 − 𝑥 )(𝑥 − 𝑥 )
𝐼= 𝑓(𝑥 ) + 𝑓(𝑥 ) + 𝑓(𝑥 ) 𝑑𝑥
(𝑥 − 𝑥 )(𝑥 − 𝑥 ) (𝑥 − 𝑥 )(𝑥 − 𝑥 ) (𝑥 − 𝑥 )(𝑥 − 𝑥 )

ℎ 𝑏−𝑎
𝐼≅ 𝑓(𝑥 ) + 4𝑓(𝑥 ) + 𝑓(𝑥 ) ℎ=
3 2
(𝑏 − 𝑎)
𝐼≅ 𝑓(𝑥 ) + 4𝑓(𝑥 ) + 𝑓(𝑥 )
6

Simpson’s 1/3 Rule


Simpson’s 1/3 rule is more accurate than trapezoidal rule.

19
EXAMPLE 2
Use the 1/3 Simpson’s rule to estimate the integral of
𝑓 𝑥 = 0.2 + 25𝑥 − 200𝑥 + 675𝑥 − 900𝑥 + 400𝑥
From a = 0 and b=0.8. If the exact integral is 1.640533, what is the absolute error of the solution?
Solution:
n=2 ( h = 0.4)
f(0)=0.2
f(0.4)=2.456
. . .
f(0.8)=0.232 𝐼 = 0.8 = 1.367467

1.640533 − 1.365467
𝐴𝑏𝑠𝑜𝑙𝑢𝑡𝑒 𝑒𝑟𝑟𝑜𝑟 = 100% = 16.6%
1.640533
The Multiple-Application Simpson’s 1/3 Rule

• Just as the trapezoidal rule, Simpson’s rule can be improved


by dividing the integration interval into a number of
segments of equal width.

• Yields accurate results and considered superior to trapezoidal


rule for most applications.

• However, it is limited to cases where values are equispaced.

• Further, it is limited to situations where there are an even


number of segments and odd number of points.
21
Figure 21.11: Graphical representation of the multiple application of the
Simpson’s 1/3 rule. Note that the method can be employed only if the
number of the segments is event.

22
Simpson’s 3/8 Rule
• An odd-segment-even-point formula used in conjunction with
the 1/3 rule to permit evaluation of both even and odd numbers
of segments.

𝐼= 𝑓(𝑥)𝑑𝑥 ≅ 𝑓 (𝑥)𝑑𝑥

3ℎ
𝐼≅ 𝑓(𝑥 ) + 3𝑓(𝑥 ) + 3𝑓(𝑥 ) + 𝑓(𝑥 )
8
(𝑏 − 𝑎)
ℎ=
3
𝑓(𝑥 ) + 3𝑓(𝑥 ) + 3𝑓(𝑥 ) + 𝑓(𝑥 )
𝐼 ≅ (𝑏 − 𝑎)
8

23
Figure 21.12

24
EXAMPLE 3
Use the 3/8 Simpson’s rule to estimate the integral of
𝑓 𝑥 = 0.2 + 25𝑥 − 200𝑥 + 675𝑥 − 900𝑥 + 400𝑥
From a = 0 and b=0.8.
Solution:
A single application of Simpson’s 3/8 rule requires four equally spaced points:
f(0)=0.2
f(0.2667)=1.432724
0.2 + 3 1.432724 + 3.487177 + 0.232
f(0.5333)=3.487177 𝐼 = 0.8
8
= 1.519170

f(0.8)=0.232 𝐴𝑏𝑠𝑜𝑙𝑢𝑡𝑒 𝑒𝑟𝑟𝑜𝑟 =


1.640533 − 1.519170
100% = 7.4%
1.640533
NEWTON-COTES FORMULAS

You might also like