Numerical
Integratio
n
Prepared by: Engr.
Cielito V. Maligalig
Introduction
• Find the area bounded by y = x2, from x
= 2 to x = 4.
Numerical Integration
What is integration?
Basically, integration is an operation of
finding the area under the given function.
Where:
f(x) – integrand
a = lower boundary
b = upper boundary
Using LaGrange Interpolation
What is trapezoidal rule?
It is numerical integration to approximate the
integral of f(x) which is based from a Newton-
Cotes formula.
Trapezoidal Formula
• There are three ways to derive the
formula but the simplest way is
deriving it analytically.
• from the diagram, it is conceivably the
trapezoid, where f(a) and f(b) are the
the parallel sides of the trapezoid and
b-a as its altitude.
Area of a trapezoid
• A = (b1 + b2)h/2
= (f(a) + f(b))(b-a)/2
= 1/2h(f0 + f1)
where:
I = definite integral between a and b
h = increment
fo,f1 = value of the function
Simpson’
s 1/3 Rule
• It is another
Newton Cotes
formula, where
subdivided the
interval between
a and b into two
equal parts.
Simpson’s 1/3 Rule
• Newton Cotes 2nd order function.
• Using method of coefficients
Cont’
= (b-a)/6 [f(a) + 4f(a+b/2) + f(b)]
If b-a/6 is factored as 1/3 (b-a)/2
The h = (b-a)/2
Since the interval is subdivided into two
(b-a)/6 = 1/3 (b-a)/2[f0 + 4f1 + f2] = 1/3h [f0 + 4f1 + f2]
Simpson’s 3/8 Rule
• It is a Newton-Cotes 3rd order
polynomial function. In this method,
the interval (b-a) is subdivided into
three equal parts, then
= 3/8h(f0 + 3f1 + 3f2 + f3)
where:
h = (b-a)/3
•
• Find the integral of xsinx
from 0.5 to 1.2.
•
• Exact solution
• Use by parts formula
• uv -
• Let v = x
Example dv = dx u = -cosx
Substitute to formula
-xcosx +
= -xcosx + sinx, from 0.5 to
1.2
= (-1.2cos1.2 +sin 1.2)-(-
0.5cos 0.5 + sin 0.5) = (do
the mathematics)
Using trapezoidal rule
f(x) = x sinx
a = 0.5
b = 1.2
f(a) = 0.5sin 0.5 = 0.239713
Solution: f(b) = 1.2sin 1.2 = 1.118447
h = b – a = 1.2 – 0.5 = 0.7
I = 1/2h(f0 + f1)
=1/2 (0.7) (0.239713 + 1.118447)
=0.475356
h = (b-a)/2 = (1.2 – 0.5)/2 = 0.35
X0 =0.5; x1 = 0.85; x2 = 1.2
f0 = 0.5 sin 0.5 =0.239713
f1 = 0.85 sin 0.85 = 0.638588
Using
f2 = 1.2 sin 1.2 = 1.118447
Simpson’s
The substitute to the formula
1/3 rule
I = 1/3h(f0 + 4f1 + f2)
= 1/3(0.35) (0.239713 + 4(0.638588)+ 1.118447 )
= 0.45646
Using Simpson’s 3/8 rule
• I = 3/8*(0.23333)*
(2.64458) = x f(x)
0.5 0.239713
0.733333 0.490857
0.966667 0.795564
1.2 1.118447
Sum 2.64458
Modified Trapezoidal
Rule x f(x)
◦
0.5 0.239713
0.733333 0.490857
0.966667 0.795564
1.2 1.118447
◦ A=
f f f f Sum 2.64458
o 1 2 n
◦ A = ½ h {f0 + fn + 2(f1 + f2 + f3 + … + f(n-1)}
◦ Where h = (b – a)/n
Modified 1/3
Simpson’s Rule
◦
◦ A = = + + + …+
f f f f
◦ A = 1/3 h {f0 o+ fn 1+2 (f2
2 +f4+f6
n + … + f(n-2)) + 4(f1 + f3 + f5 + … + f(n-1)}
◦ Where: h = (b – a)/2n
Modified 3/8 Simpson’s
Rule
◦
f f f f
o 1 2 n
◦ A = = + + + …+
◦ A = 3/8 h { f0 + fn + 3(f1 + f2 + f4 + f5 + f 7 + f8 + … + f(n-2) + f(n-1)) + 2 (f3 + f6 + f9 + … + f(n-3)}
◦ Where: h = (b – a) 3n
Assignment(lec & lab)
use excel app for lab ex.3
◦
◦ Determine the approximate integration of the
following using simple & modified
trapezoidal,1/3 Simpson’s and 3/8 Simpson’s
Rule.
a. , use n = 4
b. n =3