CH7 Numerical Integration

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 66

Numerical Methods:

Numerical Integration
Introduction
Numerical integration is a technique in numerical
analysis that is used to approximate the value of a
definite integral. It involves dividing the area
under a curve into small sub-intervals and
computing the area of each sub-interval using
some approximation formula. Numerical
integration is widely used in various fields such
as engineering, physics, economics, and finance
to solve complex problems that cannot be solved
analytically.
Introduction
In this presentation, we will explore several methods of numerical
integration, starting from the basic ones such as Trapezoidal Rule,
Simpson's 1/3 Rule, Simpson's 3/8 Rule, and Boole's Rule. Then,
we will move on to more advanced methods such as Romberg
Integration, Gauss Integration, and Monte Carlo Integration. We
will discuss the theoretical background of each method, their
advantages and disadvantages, and provide examples to illustrate
their application in solving practical problems. By the end of this
presentation, you will have a good understanding of numerical
integration and be able to choose the appropriate method for a given
problem.
Table of contents

01 02
Analytical Integration vs Purpose and
Numerical Integration importance

03 04
Comparison of
Methods
Methods
Analytical vs
01
Numerical
Integration
Analytical
Integration
Analytical integration is the process of finding the exact
value of a definite integral using analytical methods.
It involves applying integration rules and techniques to
derive a closed-form expression for the integral.
Analytical integration is often the preferred method for
computing integrals when a closed-form expression
exists, as it provides exact results.
However, analytical integration is not always possible or
practical, especially for complex or highly oscillatory
functions.
Analytical Integration

Limitations of Analytical Integration

Analytical integration is not always possible for complex or


  highly oscillatory functions.
Even for simpler functions, finding a closed-form expression
for the integral may be difficult or impossible.
Analytical integration is limited by the availability of
integration techniques and rules, which may not exist or be
well-suited for certain functions.
Even when a closed-form expression for the integral exists, it
may not be computationally efficient to evaluate, especially
for large or high-dimensional integrals.
Analytical Integration vs Numerical Integration
Analytical Numerical
Integration Integration
Provides exact results when a closed-form expression Approximates the value of the integral using numerical
for the integral exists methods
Can be computationally efficient for simple functions Provides reasonable accuracy for a wide range of
Limited by the availability of integration techniques functions
and rules May be more computationally efficient than analytical
Not always possible or practical for complex or highly integration for large or high-dimensional integrals
oscillatory functions Accuracy depends on the choice of integration method
and number of subintervals used

Choosing between Analytical and Numerical Integration:

Analytical integration should be used when a closed-form expression for the integral exists and is
computationally efficient to evaluate.
Numerical integration should be used when analytical methods are not possible or practical, or when the integral
is too complex or high-dimensional for analytical methods.
02
Purpose and importance
Purpose of Numerical Integration

Numerical integration is used to approximate the value


of definite integrals when analytical methods are not
possible or practical.
It is a fundamental tool for computing areas, volumes,
and other quantities in many fields, including physics,
engineering, and economics.
Numerical integration is also used as a building block
for more complex numerical methods, such as
differential equation solvers.
Importance of Numerical Integration

Numerical integration allows for the computation of integrals that


cannot be evaluated analytically or are too complex to be evaluated
by hand.
It provides a means of verifying analytical results or checking the
accuracy of computer simulations.
Numerical integration is essential for solving many real-world
problems, such as predicting the behavior of a physical system or
calculating the value of a financial derivative.
In summary, numerical integration is a crucial tool for numerical
analysis and provides a powerful means of solving a wide range of
problems across many fields.
Examples of practical applications:

Economics and
Physics
Finance
Numerical integration is used in physics to Numerical integration is used in
compute the trajectory of a projectile, simulate finance to compute the value of
the behavior of a fluid, or calculate the energy financial derivatives, such as options
of a system. For example, it can be used to or futures contracts. For example, it
simulate the motion of planets in the solar can be used to compute the price of a
system or to calculate the scattering cross- call option on a stock or the value of a
section of particles. bond.
Practical Application of Numerical
Integration

Engineering Biology Computer Graphics


Numerical integration is used in Numerical integration is used in
Numerical integration is used to
compute the area, volume, and other biology to simulate the behavior of computer graphics to compute the
quantities of complex shapes in complex systems, such as the spread lighting and shading of 3D objects.
of diseases or the growth of a For example, it can be used to
mechanical, civil, and electrical
simulate the reflection and
engineering. For example, it can be used population. For example, it can be
refraction of light in a virtual scene
to compute the volume of a fuel tank or used to simulate the spread of a virus
in a population or to model the or to compute the color of each
the stress on a structural beam.
dynamics of a food chain. pixel in a digital image.
Practical applications of numerical
integration in aerospace engineering
Aerodynamics analysis Flight simulation Structural design and analysis
analyze the heat transfer in aerospace systems, such as
analyze the aerodynamic performance of aircraft analyze the structural behavior of aerospace
spacecraft thermal control systems or hypersonic
and spacecraft. For example, it can be used to components, such as wings, fuselages, and rocket
vehicles. For example, it can be used to calculate the
simulate the flow of air over a wing, calculate the stages. For example, it can be used to simulate the
temperature distribution on the surface of a spacecraft
deformation of a wing under aerodynamic loads or
drag on a spacecraft during re-entry, or model the during re-entry or to simulate the cooling of a rocket the failure of a rocket stage under high stress.
behavior of a supersonic shockwave. nozzle.

Control system Propulsion system


design Trajectory Calculation
design
design and optimize rocket engines and other
Numerical integration is used to design and calculate the trajectory of a spacecraft during
analyze control systems for aerospace vehicles. propulsion systems. For example, it can be used to a mission. For example, it can be used to
For example, it can be used to simulate the simulate the combustion process in a rocket
simulate the motion of a spacecraft from
response of a spacecraft to changes in its attitude engine, calculate the thrust generated by a jet launch to landing, taking into account
or to design a guidance system for a missile. engine, or model the performance of a solid rocket gravity, atmospheric drag, and other factors.
motor.
03 Methods
Methods of Numerical Differentiation
Methods of Numerical
Integration
Newton-Cotes Integration Formulas

Trapezoidal Rule
Simpson’s Rule
Simpson’s 1/3 Rule
Simpson’s 3/8 Rule
Boole's Method
Romberg Integration

Gaussian Quadrature

Monte Carlo Method


Newton-Cotes
Integration Formulas
The Newton-Cotes formulas are the most common
numerical integration schemes. They are based
on the strategy of replacing a complicated
function or tabulated data with an approximating
function that is easy to integrate.
Trapezoidal Rule
Trapezoidal Rule
Trapezoidal Rule is a rule that evaluates the area under the curves by dividing
the total area into smaller trapezoids rather than using rectangles. This
integration works by approximating the region under the graph of a
function as a trapezoid, and it calculates the area.
The Trapezoidal rule is a first-order method, meaning that its error decreases
linearly with the size of the integration interval.
The Trapezoidal rule is simple to implement and computationally efficient,
but it may not be accurate for functions that are highly curved or have
rapidly varying slopes.
Trapezoidal Rule
Trapezoidal Rule
Trapezoidal Rule
Procedure for Trapezoidal Rule
Calculate the step size h using the Compute the sum of the areas of all
formula h = (b-a)/n, where n is the the trapezoids formed by each pair
Step 1 number of segments. Step 3 of adjacent subintervals

Use Trapezoidal rule formula to calculate the


Divide the interval [a,b] Step 2 approximation of the integral for each set of 2
Step 4
into an given number of adjacent points:
segments.  

Continue this process by starting the second point


base on the number of segments given until all points
are covered.
Example
● Approximate the integration of the function f(x)
= sin(x) + e^x with the interval [0.1, 0.5], using
the Trapezoidal Rule method with 1 segments.
Solution:
Step 1: Determine the step size (h) using the formula h = (b - a) / n, where n
is the number of segments and a and b are the endpoints of the interval. In
this case, a = 0.1, b = 0.5, and n = 1, so h = (0.5 - 0.1) / 1 = 0.4.

Step 2: Calculate the values of the function at each of the segment endpoints
using the formula f(x) = sin(x) + e^x. For 1 segments, we need to calculate
the values at 2 points:
x0 = 0.1
x1 = 0.5

f(x0) = f(0.1) = sin(0.1) + e^(0.1) ≈ 1.20500433472248


f(x1) = f(0.5) = sin(0.5) + e^(0.5) ≈ 2.128146809304330
Solution:
●  
How about 24 segments using Excel:
Simpson’s Rule of
Integration
Simpson’s Rule
Simpson's Rule is a numerical integration
technique used to approximate the value
of a definite integral of a function over an
interval.
It approximates the function with a second-
degree polynomial and integrates that
polynomial instead of the original
function.
Simpson’s Rule
Simpson’s Rule
Two version of Simpsons Rule
Simpson's 1/3 Rule Simpson's 3/8 Rule
Simpson's 1/3 Rule is used when the Simpson's 3/8 Rule is used when the
number of intervals or segments, number of intervals or segments,
n, is even. In this case, the n, is divisible by 3. In this case,
interval [a,b] is divided into n the interval [a,b] is divided into n
subintervals of equal width, h = subintervals of equal width, h =
(b-a)/n, and the area under the (b-a)/n, and the area under the
curve is approximated using curve is approximated using
parabolic segments. cubic segments.
Procedure for Simpson’s 1/3 Rule
Sum the approximations of the
Calculate the step size h using the integrals for all sets of 3 adjacent
formula h = (b-a)/n, where n is the points to obtain the final
Step 1 number of segments. Step 3 approximation of the integral over
the entire interval [a,b].

Use Simpson's 1/3 rule formula to calculate


Divide the interval [a,b] Step 2 Step 4
the approximation of the integral for each set
into an even number of of 3 adjacent segments:
segments.  

Continue this process by starting the third


point base on the number of segments given
and until all points are covered
Example
● Approximate the integration of the function f(x)
= sin(x) + e^x with the interval [0.1, 0.5], using
the Simpson’s 1/3 Rule method with 2 segments.
Solution:
Step 1: Determine the step size (h) using the formula h = (b - a) / n, where n
is the number of segments and a and b are the endpoints of the interval. In
this case, a = 0.1, b = 0.5, and n = 2, so h = (0.5 - 0.1) / 2 = 0.2 .
Step 2: Calculate the values of the function at each of the segment endpoints
using the formula f(x) = sin(x) + e^x. For 2 segments, we need to calculate
the values at 3 points:
x0 = 0.1
x1 = 0.3
x2 = 0.5

f(x0) = f(0.1) = sin(0.1) + e^(0.1) ≈ 1.20500433472248


f(x1) = f(0.3) = sin(0.3) + e^(0.3) ≈ 1.64537901423734
f(x2) = f(0.5) = sin(0.5) + e^(0.5) ≈ 2.128146809304330
Solution:
●  
How about 24 segments using Excel:
Procedure for Simpson’s 3/8 Rule
Sum the approximations of the
Calculate the step size h using the integrals for all sets of 4 adjacent
formula h = (b-a)/n, where n is the points to obtain the final
Step 1 number of segments. Step 3 approximation of the integral over
the entire interval [a,b].

Use Simpson’s 3/8 rule formula to calculate the Step 4


approximation of the integral for each set of 4 adjacent
Divide the interval [a,b] Step 2 points:
into a number of segments  
that is divisible by three.
Continue this process by starting the fourth point base
on the number of segments given and until all points
are covered
Example
● Approximate the integration of the function f(x)
= sin(x) + e^x with the interval [0.1, 0.5], using
the Simpson’s 3/8 Rule method with 3 segments.
Solution:
Step 1: Determine the step size (h) using the formula h = (b - a) / n, where n
is the number of segments and a and b are the endpoints of the interval. In
this case, a = 0.1, b = 0.5, and n = 3, so h = (0.5 - 0.1) / 3 = 0.1333… .
Step 2: Calculate the values of the function at each of the segment endpoints
using the formula f(x) = sin(x) + e^x. For 3 segments, we need to calculate
the values at 4 points:
x0 = 0.1
x1 = 0.23333…
x2 = 0.3666…
x3 = 0.5

f(x0) = f(0.1) = sin(0.1) + e^(0.1) ≈ 1.20500433472248


f(x1) = f(0.233…) = sin(0.233…) + e^(0.233…) ≈1.494024148928100
f(x2) = f(0.366…) = sin(0.366…) + e^(0.366…) ≈ 1.801422537583950
f(x3) = f(0.5) = sin(0.5) + e^(0.5) ≈ 2.128146809304330
Solution:
●  
How about 24 segments using Excel:
Boole’s Rule
Boole’s Rule

Boole's rule is a numerical integration method that


uses a fourth-degree polynomial to approximate the
function being integrated over each segment. It is a
closed Newton-Cotes formula that uses five
equally spaced points to estimate the area under the
curve.
Procedure for Boole’s Rule
Sum the approximations of the
Calculate the step size h using the integrals for all sets of 5 adjacent
formula h = (b-a)/n, where n is the points to obtain the final
Step 1 number of segments. Step 3 approximation of the integral over
the entire interval [a,b].

Use Boole’s rule formula to calculate the


Divide the interval [a,b] Step 2 Step 4
approximation of the integral for each set of 5
into a number of segments adjacent points:
that is divisible by 4.  

Continue this process by starting the fifth point base


on the number of segments given and until all points
are covered
Example
● Approximate the integration of the function f(x)
= sin(x) + e^x with the interval [0.1, 0.5], using
the Boole’s Rule method with 4 segments.
Solution:
Step 1: Determine the step size (h) using the formula h = (b - a) / n, where n
is the number of segments and a and b are the endpoints of the interval. In
this case, a = 0.1, b = 0.5, and n = 4, so h = (0.5 - 0.1) / 4 = 0.1 .
Step 2: Calculate the values of the function at each of the segment endpoints
using the formula f(x) = sin(x) + e^x. For 4 segments, we need to calculate
the values at 5 points: x0 = 0.1, x1 = 0.2, x2 = 0.3, x3 = 0.4, and x4 = 0.5.

f(x0) = f(0.1) = sin(0.1) + e^(0.1) ≈ 1.20500433472248


f(x1) = f(0.2) = sin(0.2) + e^(0.2) ≈1.42007208895523
f(x2) = f(0.3) = sin(0.3) + e^(0.3) ≈ 1.64537901423734
f(x3) = f(0.4) = sin(0.4) + e^(0.4) ≈ 1.88124303994992
f(x4) = f(0.5) = sin(0.5)+ e^(0.5) ≈ 2.128146809304330
Solution:
●  
How about 24 segments using Excel:
04
Comparison of
Methods
Comparison of Methods of Numerical Differentiation
Comparison of methods
Minimum Points Name Note
Segments
(n)
1 2 Trapezoidal
rule

2 3 Simpson’s 1/3 Segments


rule must be
divisible by 2

3 4 Simpson’s 3/8 Segments


rule must be
divisible by 3
4 5 Boole’s rule Segments
must be
divisible by 4
Comparison of methods
Comparison of methods
Romberg Integration
● an extrapolation technique which allows us to take a sequence approximate solutions to an
integral and calculate a better approximation
● Computes higher-order approximations using lower-order ones
● Based on the trapezoidal rule
● Can improve accuracy without requiring additional function evaluations

Steps:
● Define the function f(x) to be integrated over the interval [a,b].
● Choose the number of segments, n, to be used in the trapezoidal rule.
● Calculate the step size, h, using the formula h = (b-a)/n.
● Use the trapezoidal rule with step size h to calculate T(1,1), the first term in the Romberg
tableau.
● Use the trapezoidal rule with step size h/2 to calculate T(2,1), the second term in the first
column of the tableau.
● Use the extrapolation formula T(i,j) = (4^(j-1) * T(i,j-1) - T(i-1,j-1)) / (4^(j-1) - 1) to calculate
the remaining terms in the first column of the tableau, where i > j.
● Repeat steps 5-6 for the remaining columns of the tableau.
● The final estimate of the integral is the last element in the tableau, T(n,n).
Excel formula
Gaussian Quadrature
● Gauss quadrature is a numerical
integration method that uses a weighted
sum of function values at specific points to
approximate integrals. It is based on the
idea of choosing the optimal points and
weights to minimize the error in the
approximation. The method works best for
integrals over a finite interval and for
smooth functions.
Gauss Quadrature
● The main steps of Gauss quadrature are:

● Choose the number of quadrature points, n, based on the desired accuracy of the approximation.

● Determine the optimal quadrature points and weights for the chosen number of points using a
predetermined algorithm (such as the Gauss-Legendre formula).

● Evaluate the integrand at each of the quadrature points and multiply each value by its corresponding
weight.

● Sum the products to obtain the numerical approximation of the integral.

● Gaussian quadrature has a high degree of accuracy compared to other numerical integration
methods, and is particularly useful for integrals that are difficult or impossible to solve analytically.
Gauss Quadrature
●  
Monte Carlo Integration
Monte Carlo integration is a numerical integration method that relies on random sampling to approximate
the value of an integral.

Here are the general steps for Monte Carlo integration:

● Define the region of integration: Determine the region of the function you want to integrate.
● Generate random points: Generate a large number of random points within the region of integration.
● Evaluate the function at each point: Calculate the value of the function at each random point.
● Calculate the average: Find the average value of the function by summing up all the values and
dividing by the number of random points.
● Multiply by the area: Multiply the average value by the area of the region of integration to obtain the
estimate of the integral.
Monte Carlo Integration
Factors to consider when choosing a
method: Integration
Computing interval
Accuracy resources
The range of the The availability and
The accuracy requirement of integration interval. limitations of the
the integration solution.
computing resources for
the integration method.
Factors
Function Number of
properties Implementation
dimensions
The smoothness and complexity
complexity of the function The number of dimensions
to be integrated. of the function to be The complexity of
integrated. implementing and using
the integration method.
Numerical
Summary
Integration
process of finding the numerical Methods
approximation of a definite Newton-Cotes Integration includes
integral. Trapezoidal Rule, Simpson's 1/3
Newton Cotes Integration Rule, Simpson's 3/8 Rule, and
Analytical integration -Trapezoidal Rule Boole's Rule.
process of determining the definite - Simpson’s 1/3 Rule Romberg Integration uses
integral of a given function using - Simpson’s 3/8 Rule Richardson Extrapolation to
calculus. - Boole’s Rule improve the accuracy of
Factors in choosing numerical integration.
Romberg Integration Gaussian Quadrature approximates
methods Gauss Quadrature integrals using weighted sum of
Accuracy Monte Carlo Integration function values at predetermined
Integration interval points.
Computing resources Monte Carlo Integration uses random
Function properties sampling to estimate integrals.
Number of dimensions
Implementation complexity
Conclusions
In conclusion, numerical integration methods are used to approximate the definite integral of
a function when the integral cannot be evaluated analytically. There are various numerical
integration methods, such as Newton-Cotes integration methods like Trapezoidal Rule,
Simpson’s 1/3 Rule, Simpson’s 3/8 Rule, and Boole’s Rule. Additionally, there are more
advanced methods such as Romberg integration, Gaussian quadrature, and Monte Carlo
integration.
The choice of method depends on several factors, such as the accuracy required, the
smoothness of the function, and the computational resources available. Each method has its
strengths and weaknesses, and the appropriate method should be chosen based on the
problem at hand.
Overall, numerical integration methods are essential tools for approximating integrals in
various fields, including physics, engineering, and economics.

You might also like