Numerical Methods in
Engineering
Chapter 4: Numerical Differentiation
and Integration
1
MOTIVATION
How do we calculate derivatives?
• The mathematical definition of the derivative
begins with a difference approximation.
• We start with the slopes and for the limit case
we end up with derivatives.
• If Δx is allowed to approach zero, the
difference becomes a derivative.
2
3
Other derivatives
• Second derivatives tells us how fast the
slope is changing
• Partial derivatives, on the other hand,
depends on more than one variable, one of
which can be held as constant
4
What does integration means?
• Integration is basically area finding problem.
5
• And they are inverse of each other!
• If 𝑣 𝑡
𝑑
= 𝑦(𝑡) then y 𝑡
𝑑𝑡
𝑡
= 0 𝑣 𝑡 𝑑𝑡
6
Non-computer Methods for
Differentiation and Integration
• The function to be differentiated or integrated
will typically be in one of the following three
forms
1. A simple continuous function→Analytical Sln.
2. A
complicated
Numerical Sln.
continuous
function→
3. A tabulated function, where values of x and
f(x) are given at a number of discrete points
7
Equal-area graphical differentiation method
• If the function is given in discrete manner it
can be differentiated with equal area
graphical differentiation:
8
An area problem
• Hand
calculation of
integrals with
a graphing
paper is also
simple
9
Where do we use numerical
integration in Engineering?
(a) A surveyor might need to know the area of a field bounded by a meandering stream and
two roads.
(b) A water-resource engineer might need to know the cross-sectional area of a river.
(c) A structural engineer might need to determine the net force due to a non-uniform wind
blowing against the side of a skyscraper.
10
NEWTON-COTES INTEGRATION
• Newton cotes formulas replaces the original
function with a polynomial.
• where,
11
Newton-Cotes/ Graphically explained
• Below is the graphical representation of first
and
second
order
polynomial
approximation.
• What is the accuracy of approximation?
12
Improvement of the method
•The integral can also be approximated
using a series of polynomials applied
piecewise to the function or data over
segments of constant length.
13
•In the figure three straight-line segments
are used to approximate the integral.
Higher-order polynomials can be utilized for
the same purpose.
14
• The method is quite similar to curve fitting.
• Do you remember how we increase our
accuracy at curve fitting?
– More dense points
– Higher order polynomials
15
The Trapezoidal Rule
• This is the simplest first order approximation.
Replace the function with a straight line:
16
17
Example 4.1
• Calculate the integral of the following function from 𝑎 = 0
to 𝑏 = 0.8.
Solution
• The exact solution is 𝐼 = 1.640533 Therefore error is
18
19
Error estimation of Trapezoidal Method
• In reality we cannot know the exact error. Therefore we
need an measure for truncation error:
• Therefore expected error for the previous calculation is:
• The ORDER of error is the same with the exact error.
20
Multi-step Application of
Trapezoidal Rule
• If we divide the integration into
multiple steps we can achieve
better results:
21
• In a more compact
form
• With error measure
22
Example 4.2
• Use the two-segment trapezoidal rule (n=2)
to estimate the integral of
from 𝑎 = 0 to 𝑏 = 0.8.
Solution
23
Computer algorithm of Trapezoidal Rule
Results for multipleapplication
trapezoidal rule to
estimate the integral
of the previous
example
24
Simpson`s Rules
• Simpson`s
rules
are
higher
order
approximations.
– Numerous applications can be found in the
literature.
• Since they are in higher order, they require
higher number of base points.
25
Simpson`s 1/3 Rule
• Second order approximation is called 1/3 rule
and based on fitting a second order
Lagrange polynomial.
26
• After
integration
and
algebraic
manipulation, the following formula results.
• The derivation is in your text book!
27
• The formula is:
• Notice that we have divided the interval into 2
pieces. Therefore, h=(b-a)/2. The alternative
formulation becomes:
• With an error:
28
Example 4.3
• Solve the previous equation with 1/3 rule with single step
• Solution:
• With an error of
• Estimated error calculated with the formula:
29
Multiple Application Simpson`s 1/3 Rule
• We can again subdivide the integral and
solve each piece with 1/3 rule:
• Which becomes:
30
• When you apply high order integration rules:
– Try not to use long formulas. Just divide and conquer!
– Never overlap regions. (See figure below)
31
Example 4.4
• Apply multi-step Simpson’s 1/3 rule with n=4
to solve the integral problem given before
from 𝑎 = 0 to 𝑏 = 0.8.
32
Solution
33
Simpson’s 3/8 Rule
•
rd
Now if we proceed one step further and fit a 3
order Lagrange polynomial, we can obtain a better
estimate:
• to yield
• This equation is called Simpson’s 3/8 rule because h
is multiplied by 3/8.
34
• The truncation error in the estimation is:
• Note that, both 1/3 rule and 3/8 rule has third
order accuracy. However the truncation
error is less in 3/8 rule!
35
36
1.
A 4-m beam is subjected to a load, and shear force follows the equation V=5+0.25x2.
Bending momentum is the integral of shear stress along the beam. Calculate the bending moment using:
a. trapezoidal method with 4 segments.
b. Simpson’s 1/3 rule with 4 segments.
c. 3-points Gauss-Quadrature.
4
𝑀=
4
2
𝑉𝑑𝑥 =
0
(5 + 0.25𝑥 )𝑑𝑥
0
37
Other extension of the methods
• You
can
extend
the
Newton-Cotes
integration in many ways:
– You can use higher order methods,
– You can mix the methods in the same problem
– You can even use unequal segments
• Never use unequal segments inside single step of
higher formulas
38
39