You are on page 1of 29

Numerical Integration & Differentiation

Newton-Cotes Integration
Learning outcome
Recognizing that Newton-Cotes integration formulas are based on the strategy of
replacing a complicated function or tabulated data with a polynomial that is easy to
integrate.

Knowing how to implement the following single application Newton-Cotes


formulas:
Trapezoidal rule
Simpsons 1/3 rule
Simpsons 3/8 rule

Knowing how to implement the following composite Newton-Cotes formulas:


Trapezoidal rule
Simpsons 3/8 rule
Recognizing that even-segment-odd-point formulas like Simpsons 1/3 rule achieve
higher than expected accuracy.
Knowing how to use the trapezoidal rule to integrate unequally spaced data.
Introduction
Differentiation?
Process of finding derivative (dy/dx) - rate of change of a dependent variable
with respect to an independent variable.

y f(xi x) f(xi )

x x
dy f(xi x) f(xi )
x lim 0
dx x
Integration?
Process of finding integral, I - the area under a function plotted on a graph.

f(x)

Area,A I f x dx
b
a
A
Introduction
Why? engineering deals with systems/processes that are changing.
derivative and integral calculus are used to describe physical worlds such as...
Derivative - finding the velocity of a body from acceleration functions, and
displacement of a body from velocity data.
Integral - finding area under the curves, centroid, moment of inertia, work
by variable force (Hookes Law), electric charge, average value, force by
liquid pressure.

What can be differentiated and integrated?


1. Simple continuous function such as polynomial, exponential and trigonometry
Analytical approach
2. Tabulated values (discrete data) Numerical approach
3. Continuous complicated functions (difficult or impossible) Numerical
approach.
Non-computer method for differentiation and integration
Equal-area graphical differentiation
Given - (x,y) are tabulated data
a) Find divided difference (y/x) for each interval.
b) Plot y/x as stepped curve versus x
c) Draw smooth curve to approximate area under the curve.

Read from the


curve
Non-computer method for differentiation and integration
Using grid to approximate an integral
Given - (x, y) are tabulated data.
a) Plot the curve
b) Count the number of boxes that approximate the area.

A = (heights x widths)

better approximation is achieved using finer grid or thinner strips


(Form the basis for computer methods)
Numerical integration
Numerical Integration (i.e. QUADRATURE)

Integral,I A f x dx
b
a
f(x)

f(x) = integrand
x = variable
a, b = integration limits A
Methods of numerical integration
Newton-Cotes integration formula
1. Trapezoidal rule
2. Simpsons rule
Simpsons 1/3rule
Simpsons 3/8 rule

Romberg integration
Gauss quadrature
Newton-Cotes Integration Formula
Newton-Cotes Formula;
Replace complicated function or tabulated data (i.e. integrand) with an nth
order polynomial across the integration interval
b b


I f(x)dx f n (x)dx
a a

f n (x) a 0 a1x a n 1x n 1 a n x n Integrating function


i.e. interpolating
polynomial
fn(x) is an nth order interpolating polynomial.

The integrating function can be


polynomials for any order, e.g.
a) straight lines 1st order
b) parabolas 2nd order
c) Cubic 3rd order

Newton-Cotes closed formula


I = (b-a) x (Average Height)
Newton-Cotes Integration Formula
Methods of application

Single application
less accurate if a & b are widely spaced

f x dx
b
I
a
Multiple-application
repeatedly apply single integral for each
sub-interval of data points
higher accuracy

b

I f(x) dx I1 I 2 I3 .... I n
a

Note: Higher order polynomial can be


used for higher accuracy
1.a Trapezoidal rule
The trapezoidal rule uses a first order
polynomial as the integrating function.
b b


I f(x)dx f1 (x)dx
a a
f1 (x) a 0 a 1x

b
f1 (x)dx Area of trapezoid
a

Parallelsides
(Height) Newton-Cotes closed formula
2 I = (b-a) x (Average Height)

f(a) f(b) Trapezoidal for


I (b a) single integral
2
1.a Trapezoidal rule - Error
the truncation error of a single application
of the trapezoidal rule is:

E t f b a
1 3

12
Where, is somewhere between a
and b.

error is dependent upon the second-


derivative of the actual function
It is 1st order accurate give exact result
if the actual function is linear.
error is dependent on the third power of
the step size
Error can thus be reduced by breaking the
curve into parts
Use multiple-application/composite
1.a Trapezoidal rule - Example
Integrate f(x)=0.2 + 25x - 200x + 675x3 - 900x4 + 400x5 from a=0 to b=0.8.
True value 1.640533.

f(0) = 0.2
f(0.8) = 0.232

f(a) f(b) 0.2 0.232


I (b a) ( 0.8 0) 0.1728
2 2

t 89.5%
1.b Multiple application of Trapezoidal rule
A way to improve the accuracy of the trapezoidal
rule
Sub-divide the interval [a, b] into n segment (sub-
interval)

ba
h a x0 b xn
n

Apply single integral method to every segment,


total integral is
x1 x2 xn

I f(x)dx f(x)dx f(x)dx


x0 x1 x n 1

Substitute trapezoidal rule to each integral gives,


f(x 0 ) f(x1 ) f(x ) f(x 2 ) f(x ) f(x n )
Ih h 1 h n 1
2 2 2
1.b Multiple application of Trapezoidal rule
Multiple-application Trapezoidal rule

h n 1

2 i 1

I f(xo ) 2 f(xi ) f(xn )

Error = the sum of the individual error for each segment

(b a) 3
Average value of second derivative
Ea 2
f - Error is inversely related to n2
12n
Problem
For high accuracy, need more segments more computations more
round-off errors!
Solution
Use higher-order polynomial as the integrating function!
1.b Multiple application of Trapezoidal rule - Example
Integrate f(x)=0.2 + 25x - 200x + 675x3 - 900x4 + 400x5 from a=0 to b=0.8 with n=2.
True value 1.640533.

f(0) = 0.2
f(0.4) = 2.456
f(0.8) = 0.232

0.2 2(2.456) 0.232


I (0.8 0) 1.0688
4

t 34.9%
2. Simpsons 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 Simpsons rules.

a) Simpsons 1/3 rule use 2nd-order interpolating polynomial


b) Simpsons 3/8 rule use 3rd-order interpolating polynomial
2.a Simpsons 1/3 Rule
General form; b b


I f(x)dx f 2 (x)dx
a a

f 2 (x) a 0 a 1x a 2 x 2
Using the Lagrange form for a quadratic fit of three points:

f n x
x x1 x x 2 f x x x 0 x x 2 f x x x 0 x x1 f x
x 0 x1 x 0 x 2 0 x1 x 0 x1 x 2 1 x 2 x 0 x 2 x1 2
Integration over the three points simplifies to:
ba Sub-interval is
x2
f 2 x dx h

equally spaced
I 2
x0

I
h
f x 0 4f x1 f x 2 simpsons 1/3 rule
3 for single integral
Where, x0 = a , x1=(a+b)/2 & x2 = b
Newton-Cotes closed formula

Called 1/3 because h is divided by 3 I = (b-a) x (Average Height)


2.a Simpsons 1/3 Rule - Error
Truncation error of a single application of Simpsons 1/3 rule is:

Et
b a 4
5
f
2880
where is somewhere between a and b.

error is dependent upon the fourth-derivative of the actual function

Simpsons 1/3 is third-order accurate though it is derived from 2nd order polynomial
more accurate than expected! Give exact result for cubic polynomial.

error is dependent on the fifth power of the step size (rather than the third for the
trapezoidal rule).
2.b Multiple-Application Simpsons 1/3 Rule
A way to improve the accuracy of the Simpsons
1/3 rule

Sub-divide the interval [a,b] into n segment (sub-


interval)
ba
h ax bx
n 0 n
Apply single integral method over every two
segment n must be even!, total integral is
x2 x4 xn

I f(x)dx f(x)dx f(x)dx


x0 x2 x n 2

Substitute Simpsons 1/3 rule to each integral


gives

I
h
f x 0 4f x1 f x 2 h f x 2 4f x 3 f x 4 h f x n 2 4f x n 1 f x n
3 3 3
2.b Multiple-Application Simpsons 1/3 Rule
Multiple-application Simpsons 1/3 rule;
n 1 n 2

h

I f x 0 4 f x i 2
3

f x i f x n
i 1 j 2
i, odd j, even
Error = the sum of the individual error for each segment

(b a ) 5 Average value of 4th derivative


Ea f (4)
180n 4
Very accurate superior than Trapezoidal

Problem
Limited to only equi-spaced data!
Must have even number of segments (i.e. odd number of data points)
Solution
For odd number of segment s use Simpsons 3/8 rule!
2.b Multiple-Application Simpsons 1/3 Rule
Multiple-application Simpsons 1/3 rule;
n 1 n 2

h

I f x 0 4 f x i 2
3

f x i f x n
i 1 j 2
i, odd j, even
Error = the sum of the individual error for each segment

(b a ) 5 Average value of 4th derivative


Ea f (4)
180n 4
Very accurate superior than Trapezoidal

Problem
Limited to only equi-spaced data!
Must have even number of segments (i.e. odd number of data points)
Solution
For odd number of segment s use Simpsons 3/8 rule!
2.c Simpsons 3/8 Rule
General form;
b b


I f(x)dx f 3 (x)dx
a a

f 3 (x) a 0 a1x a 2 x 2 a 3 x 3
Using the Lagrange form for a 3rd-order polynomial to fit of four points:
Integration over the three points simplifies to:
Sub-interval is
ba
f x dx h
x2 equally spaced
I 3
x0 3
I f x 0 3f x1 3f x 2 f x 3
3h SIMPSONS 3/8 RULE
8 for single integral

Where, x0 = a , x1=(a+b)/3, x2=(2a+2b)/3 & x2 = b


2.c Simpsons 3/8 Rule
Truncation error of a single application of Simpsons 3/8 rule is:

Et
b a 4
5
f
6480
where is somewhere between a and b.

error is dependent upon the fourth-derivative of the actual function

Simpsons 3/8 is still third-order accurate though it is derived from 3rd order
polynomial Give exact result for cubic polynomial.

error is dependent on the fifth power of the step size


2.c Simpsons 3/8 Rule
REMARKS

Simpsons 1/3 is usually the preferred


method because it attains third-order
accuracy with 3 points rather than the
4 points required for the 3/8 version.

Simpsons 3/8 rule is generally used in


tandem with Simpsons 1/3 rule when
the number of segments is odd.
2.d Multiple-Apllication Simpsons 3/8 Rule
Sub-divide the interval [a, b] into n segment (sub-
interval)
ba
h a x0 b xn
n
Apply single integral method over every THREE
segment n must be divisible by three!, total
integral is
x3 x6 xn


I f(x)dx f(x)dx
x0 x3
f(x)dx
x n 3

Substitute Simpsons 3/8 rule to each integral gives,

3h n 1 n 2
I f x 0 3
8
(f x i f x i 1 ) 2
i 2,5,7..
f x i f x n
j 4,7,10...
2. Simpsons Rule
FINAL REMARKS

Simpsons 1/3
for EVEN number of segments
3rd order accuracy (although based on 2nd order polynomial) thus it is a
preferred method!

Simpsons 3/8
For ODD number of segments & segment must be divisible by 3.
Can be used in combination with 1/3 rule to solve for ODD number of
segments

Simpsons rules are sufficient for most applications.

Higher-order Newton-Cotes formulas may also be used - in general, the higher the
order of the polynomial used, the higher the derivative of the function in the error
estimate and the higher the power of the step size. more accurate but rarely
used
2. Simpsons Rule
FINAL REMARKS

Simpsons 1/3
for EVEN number of segments
3rd order accuracy (although based on 2nd order polynomial) thus it is a
preferred method!

Simpsons 3/8
For ODD number of segments & segment must be divisible by 3.
Can be used in combination with 1/3 rule to solve for ODD number of
segments

Simpsons rules are sufficient for most applications.

Higher-order Newton-Cotes formulas may also be used - in general, the higher the
order of the polynomial used, the higher the derivative of the function in the error
estimate and the higher the power of the step size. more accurate but rarely
used
2. Simpsons Rule
For unequal segments, one method is to
apply trapezoidal rule to each segment and
sum the results

f(x0 ) f(x1 ) f(x1 ) f(x2 ) f(xn 1 ) f(xn )


I h1 h2 hn
2 2 2

Where hi = the width of segment i

Same approach as multiple-application trapezoidal rule


but h is the width of the unequal segments.
Newton-Cotes integration formula Final remark
Numerical integration for;
1. Tabulated values (discrete data).
2. Continuous complicated functions (difficult or impossible).

Concept:
Replace tabulated data and complicated function (i.e. integrand) with an nth
order integrating polynomial across the integration interval
b b
I f(x)dx f n (x)dx
a a

Accuracy;
Higher order polynomial more accurate

Method of application:
Single application not accurate
Multiple application more accurate (need more data values!)

You might also like