SlideShare a Scribd company logo
AHSANULLAH UNIVERSITY OF
SCIENCE AND TECHNOLOGY
EEE 3110
NUMERICAL TECHNIQUE LABORATORY
MATLAB : Numerical Differention and Integration
PRESENTED BY :
AINUL ISLAM (ID 12-02-05-065)
SHADMAN SAKIB AOYON (ID 12-02-05-060)
MIRZA SHAMIM ARMAN (ID 12-02-05-072)
TAUHIDUR RAHMAN AKIF (ID 12-02-05-062)
KAZI WALIDA AFROZE (ID 12-02-05-079)
CONTENTS:
• INTRODUCTION TO NUMERICAL DIFFERENTIATION
• FORWARD DIFFERENCE FORMULA
• CENTRAL DIFFERENCE FORMULA
• RICHARDSON’S EXTRAPOLATION
• INTRODUCTION TO NUMERICAL INTEGRATION
• TRAPEZOIDAL RULE
• SIMPSON’S RULE
Numerical Differentiation :
Numerical differentiation deals with the following problem : we are given the function
y = f (x) and wish to obtain one of its derivatives at the point x = xk. The term “given”
means that we either have an algorithm for computing the function, or possess a
set of discrete data points (xi , yi ), i = 1, 2, . . . , n. In either case, we have access to a
finite number of (x, y) data pairs from which to compute the derivative. If you suspect
by now that numerical differentiation is related to interpolation, you are right—one
means of finding the derivative is to approximate the function locally by a polynomial
and then differentiate it. An equally effective tool is the Taylor series expansion of
f (x) about the point xk. The latter has the advantage of providing us with information
about the error involved in the approximation.
Numerical differentiation is not a particularly accurate process. It suffers from
a conflict between round off errors (due to limited machine precision) and errors
inherent in interpolation. For this reason, a derivative of a function can never be
computed with the same precision as the function itself
Taylor series expansion can be used to generate high-
accuracy formulas for derivatives by using linear algebra
to combine the expansion around several points.
We will discuss three categories of formula:
• Forward difference formula
•Centered difference formula
•Richardson Extrapolation formula
MATLAB : Numerical Differention and Integration
FORWARD DIFFERENCE FORMULA
EXAMPLE :
Given that f(x)=(sin x) and h=.001 find the first derivative f’(x)
using forward difference formula in MATLAB :
Code :-
clear all;
close all;
clc;
h=.001;
x=0:(.001):2*pi;
f=inline(‘sin (x)’)
q=f(x)
d=f(x+h)
a=((d-q)/h)
plot(x,a)
d
a
MATLAB : Numerical Differention and Integration
MATLAB : Numerical Differention and Integration
CENTRAL DIFFERENCE FORMULA :
MATLAB : Numerical Differention and Integration
Richardson Extrapolation
• As with integration, the Richardson extrapolation can be used to combine two lower-accuracy
estimates of the derivative to produce a higher-accuracy estimate.
• For the cases where there are two O(h2
) estimates and the interval is halved (h2=h1/2), an
improved O(h4
) estimate may be formed using:
• For the cases where there are two O(h4
) estimates and the interval is halved (h2=h1/2), an
improved O(h6
) estimate may be formed using:
D=
4
3
D(h2)−
1
3
D(h1)
D=
16
15
D(h2)−
1
15
D(h1)
Numerical integration, also known as quadrature, is intrinsically a much more accurate
procedure than numerical differentiation. Quadrature approximates the definite
Integral. Numerical integration is a widely encountered problem in economics.
All rules of quadrature are derived from polynomial interpolation of the
integrand. Therefore, they work best if f (x) can be approximated by a polynomial.
Methods of numerical integration can be divided into two groups:
1.Newton–Cotes formulas (The Trapezoidal Rule and Simpson’s Rule)
2.Gaussian quadrature.
Newton–Cotes formulas are characterized by
equally spaced abscissas, and include well-known methods such as the trapezoidal
rule and Simpson’s rule. They are most useful if f (x) has already been computed at
equal intervals, or can be computed at low cost. Since Newton–Cotes formulas are
based on local interpolation, they require only a piecewise fit to a polynomial
INTRODUCTION TO NUMERICAL INTEGRATION :
The trapezoidal rule uses trapezoids
to approximate area, which usually is
a much more accurate
approximation, even with just a few
subintervals.
Notice that the height of the
trapezoids will actually be Δx
(horizontal) and bases will be the parallel
f(xi) (vertical) on each side of the
subinterval.
( )trapezoid
1 2
A =
2
b b
h
+
×
THE TRAPEZOIDAL RULE
What is Trapezoidal Method ?
1
Observe that the coefficients are 1, 2, 2, 2, 2, . . . 2, 1
TRAPEZOIDAL RULE
4
The area of the first trapezoid would be
0 1( ) ( )
2
f x f x b a
n
+ −   
× ÷    
0 1 11 2( ) ( ) ( ) ( )( ) ( )
2 2 2
n nf x f x f x f xf x f xb a
n
−+ ++−   
+ +×× × + ÷ 
   
Area =
and then total area would be
Letting the number of trapezoids n approach infinity, you
improve the approximation to the exact answer.
( ) ( ) ( )0 1 1 2 1lim ( ) ( ) ( ) ( ) ( ) ( )
2
n n
n
b a
f x f x f x f x f x f x
n
−
→∞
−
+ + + +×× × + +  
There are many alternatives to the trapezoidal rule,
but this method deserves attention because of :
•Its ease of use
•The trapezoidal rule has faster convergence.
•Moreover, the trapezoidal rule tends to become extremely accurate than
periodic functions
•Powerful convergence properties
•Straightforward analysis
Advantages
7
Thomas Simpson (1710-1761) used second-degree polynomials
(a section of a quadratic) to approximate the graph for each subinterval.
Before we get into Simpson’s Rule, we need to list a theorem for evaluating
integrals of polynomials of degree 2 or less.
THE SIMPSON’S RULE
THE SIMPSON’S RULE
Notice the coefficients are 1, 4, 2, 4, . . . 2, 4, 1
EXAMPLE OF SIMPSON’S RULE :
Given, f=(cos x); n=12; low value=-1; high value=2;
Integrate the function over the values of x using Simpson’s 1/3 rule :
clear all;
close all;
clc;
h= -0.1;
n=12;
sum=0;
f=inline(‘ cos (x)’);
sum=sum + f(a)
for i=2 : 2 :n ;
x(i)=a + i*n;
sum=sum+4*f(x(i))
end
for i =3 : 2 : (n-1) ;
x( i )=a + i *n;
sum=sum+2*f(x(i))
end
sum=sum + f(a +n * h)
p=(sum*h)/3
ERRORS :
These two expressions tell how much of an error you can expect to
get using either the Trapezoidal Rule or Simpson’s Rule.
 http://en.wikipedia.org
 www.google.com
 http://slideshare.com
 And various relevant websites
References
15
Thank You

More Related Content

PDF
Numerical Methods - Power Method for Eigen values
PPTX
Numerical analysis ppt
PPT
Numerical integration
PPTX
Presentation on Numerical Method (Trapezoidal Method)
PPTX
First order linear differential equation
PPTX
Newton Raphson
PPTX
Runge-Kutta methods with examples
PPT
Techniques of Integration ppt.ppt
Numerical Methods - Power Method for Eigen values
Numerical analysis ppt
Numerical integration
Presentation on Numerical Method (Trapezoidal Method)
First order linear differential equation
Newton Raphson
Runge-Kutta methods with examples
Techniques of Integration ppt.ppt

What's hot (20)

PPTX
lagrange interpolation
PDF
Bisection method
PPTX
Ordinary differential equations
PPTX
TENSOR .pptx
DOC
Chapter 4 (maths 3)
PPTX
PPTX
Power series
PPTX
newton raphson method
PPTX
Iterative methods
PPTX
Partial differential equations
PPTX
Bisection method
PPT
linear transformation
PDF
Integral calculus
PDF
Limits, Continuity & Differentiation (Theory)
PPTX
stirling method maths
PPTX
Newton's forward & backward interpolation
PPTX
APPLICATIONS OF DIFFERENTIAL EQUATIONS-ZBJ
PPT
Derivation of Simpson's 1/3 rule
PDF
Numerical Solution of Ordinary Differential Equations
PPTX
Runge Kutta Method
lagrange interpolation
Bisection method
Ordinary differential equations
TENSOR .pptx
Chapter 4 (maths 3)
Power series
newton raphson method
Iterative methods
Partial differential equations
Bisection method
linear transformation
Integral calculus
Limits, Continuity & Differentiation (Theory)
stirling method maths
Newton's forward & backward interpolation
APPLICATIONS OF DIFFERENTIAL EQUATIONS-ZBJ
Derivation of Simpson's 1/3 rule
Numerical Solution of Ordinary Differential Equations
Runge Kutta Method
Ad

Viewers also liked (20)

PPTX
[4] num integration
PPT
8.7 numerical integration
PDF
Applied numerical methods lec10
PPTX
NUMERICAL INTEGRATION AND ITS APPLICATIONS
PPT
Numerical method
PPT
Cyberwellness talk by mdm saedah 2011 160211
PPT
Cyberwellness 2011 hws
PPTX
Cyber wellness 2
DOCX
Bisection method solved questions
PPT
Cyber-Wellness
DOCX
numerical method solutions
PPTX
Multiple sagement trapezoidal rule
PPT
Cyberwellness Refers To The Positive Well Being Of Internet
PDF
MAT210/Integration/Basic 2013-14
PPT
Calc 4.6
PPT
1519 differentiation-integration-02
PPT
Cyberwellness
PPT
25285 mws gen_int_ppt_trapcontinuous
PPTX
Gaussian Quadrature Formula
[4] num integration
8.7 numerical integration
Applied numerical methods lec10
NUMERICAL INTEGRATION AND ITS APPLICATIONS
Numerical method
Cyberwellness talk by mdm saedah 2011 160211
Cyberwellness 2011 hws
Cyber wellness 2
Bisection method solved questions
Cyber-Wellness
numerical method solutions
Multiple sagement trapezoidal rule
Cyberwellness Refers To The Positive Well Being Of Internet
MAT210/Integration/Basic 2013-14
Calc 4.6
1519 differentiation-integration-02
Cyberwellness
25285 mws gen_int_ppt_trapcontinuous
Gaussian Quadrature Formula
Ad

Similar to MATLAB : Numerical Differention and Integration (20)

PDF
Overviewing the techniques of Numerical Integration.pdf
PDF
Computational methods for engineering students
PPTX
Newton cotes integration method
PPTX
The Trapezoidal rule is the first of the Newton-Cotes closed integration form...
PDF
numerical differentiation&integration
PDF
Ankit_Practical_File-1.pdf A detailed overview of Rizir as a brand
PPT
LECF03-Numerical-Differentiation-and-Integration.ppt
PPT
23MA401 NM Numerical integration anddifferenciation
PPTX
Numerical integration for engineering students.pptx
PDF
Efficient Accuracy: A Study on Numerical Integration.
PPT
Numerical integration
PDF
Quadrature
PPTX
NUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULA
PPTX
NUMERICAL METHOD'S
PPT
Numerical hhhhhhhhhhhhhhhhhIntegration.ppt
PDF
A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...
PDF
A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...
PPTX
trapezoidal rule.pptx
PDF
A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...
PDF
Study Material Numerical Differentiation and Integration
Overviewing the techniques of Numerical Integration.pdf
Computational methods for engineering students
Newton cotes integration method
The Trapezoidal rule is the first of the Newton-Cotes closed integration form...
numerical differentiation&integration
Ankit_Practical_File-1.pdf A detailed overview of Rizir as a brand
LECF03-Numerical-Differentiation-and-Integration.ppt
23MA401 NM Numerical integration anddifferenciation
Numerical integration for engineering students.pptx
Efficient Accuracy: A Study on Numerical Integration.
Numerical integration
Quadrature
NUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULA
NUMERICAL METHOD'S
Numerical hhhhhhhhhhhhhhhhhIntegration.ppt
A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...
A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...
trapezoidal rule.pptx
A NEW STUDY OF TRAPEZOIDAL, SIMPSON’S1/3 AND SIMPSON’S 3/8 RULES OF NUMERICAL...
Study Material Numerical Differentiation and Integration

Recently uploaded (20)

PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Construction Project Organization Group 2.pptx
PPTX
Artificial Intelligence
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPTX
Current and future trends in Computer Vision.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
Sustainable Sites - Green Building Construction
PPT
Mechanical Engineering MATERIALS Selection
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Safety Seminar civil to be ensured for safe working.
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Construction Project Organization Group 2.pptx
Artificial Intelligence
Automation-in-Manufacturing-Chapter-Introduction.pdf
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Current and future trends in Computer Vision.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
Embodied AI: Ushering in the Next Era of Intelligent Systems
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Operating System & Kernel Study Guide-1 - converted.pdf
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Sustainable Sites - Green Building Construction
Mechanical Engineering MATERIALS Selection
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Safety Seminar civil to be ensured for safe working.

MATLAB : Numerical Differention and Integration

  • 1. AHSANULLAH UNIVERSITY OF SCIENCE AND TECHNOLOGY EEE 3110 NUMERICAL TECHNIQUE LABORATORY
  • 3. PRESENTED BY : AINUL ISLAM (ID 12-02-05-065) SHADMAN SAKIB AOYON (ID 12-02-05-060) MIRZA SHAMIM ARMAN (ID 12-02-05-072) TAUHIDUR RAHMAN AKIF (ID 12-02-05-062) KAZI WALIDA AFROZE (ID 12-02-05-079)
  • 4. CONTENTS: • INTRODUCTION TO NUMERICAL DIFFERENTIATION • FORWARD DIFFERENCE FORMULA • CENTRAL DIFFERENCE FORMULA • RICHARDSON’S EXTRAPOLATION • INTRODUCTION TO NUMERICAL INTEGRATION • TRAPEZOIDAL RULE • SIMPSON’S RULE
  • 5. Numerical Differentiation : Numerical differentiation deals with the following problem : we are given the function y = f (x) and wish to obtain one of its derivatives at the point x = xk. The term “given” means that we either have an algorithm for computing the function, or possess a set of discrete data points (xi , yi ), i = 1, 2, . . . , n. In either case, we have access to a finite number of (x, y) data pairs from which to compute the derivative. If you suspect by now that numerical differentiation is related to interpolation, you are right—one means of finding the derivative is to approximate the function locally by a polynomial and then differentiate it. An equally effective tool is the Taylor series expansion of f (x) about the point xk. The latter has the advantage of providing us with information about the error involved in the approximation. Numerical differentiation is not a particularly accurate process. It suffers from a conflict between round off errors (due to limited machine precision) and errors inherent in interpolation. For this reason, a derivative of a function can never be computed with the same precision as the function itself
  • 6. Taylor series expansion can be used to generate high- accuracy formulas for derivatives by using linear algebra to combine the expansion around several points. We will discuss three categories of formula: • Forward difference formula •Centered difference formula •Richardson Extrapolation formula
  • 9. EXAMPLE : Given that f(x)=(sin x) and h=.001 find the first derivative f’(x) using forward difference formula in MATLAB : Code :- clear all; close all; clc; h=.001; x=0:(.001):2*pi; f=inline(‘sin (x)’) q=f(x) d=f(x+h) a=((d-q)/h) plot(x,a) d a
  • 14. Richardson Extrapolation • As with integration, the Richardson extrapolation can be used to combine two lower-accuracy estimates of the derivative to produce a higher-accuracy estimate. • For the cases where there are two O(h2 ) estimates and the interval is halved (h2=h1/2), an improved O(h4 ) estimate may be formed using: • For the cases where there are two O(h4 ) estimates and the interval is halved (h2=h1/2), an improved O(h6 ) estimate may be formed using: D= 4 3 D(h2)− 1 3 D(h1) D= 16 15 D(h2)− 1 15 D(h1)
  • 15. Numerical integration, also known as quadrature, is intrinsically a much more accurate procedure than numerical differentiation. Quadrature approximates the definite Integral. Numerical integration is a widely encountered problem in economics. All rules of quadrature are derived from polynomial interpolation of the integrand. Therefore, they work best if f (x) can be approximated by a polynomial. Methods of numerical integration can be divided into two groups: 1.Newton–Cotes formulas (The Trapezoidal Rule and Simpson’s Rule) 2.Gaussian quadrature. Newton–Cotes formulas are characterized by equally spaced abscissas, and include well-known methods such as the trapezoidal rule and Simpson’s rule. They are most useful if f (x) has already been computed at equal intervals, or can be computed at low cost. Since Newton–Cotes formulas are based on local interpolation, they require only a piecewise fit to a polynomial INTRODUCTION TO NUMERICAL INTEGRATION :
  • 16. The trapezoidal rule uses trapezoids to approximate area, which usually is a much more accurate approximation, even with just a few subintervals. Notice that the height of the trapezoids will actually be Δx (horizontal) and bases will be the parallel f(xi) (vertical) on each side of the subinterval. ( )trapezoid 1 2 A = 2 b b h + × THE TRAPEZOIDAL RULE
  • 17. What is Trapezoidal Method ? 1
  • 18. Observe that the coefficients are 1, 2, 2, 2, 2, . . . 2, 1 TRAPEZOIDAL RULE
  • 19. 4
  • 20. The area of the first trapezoid would be 0 1( ) ( ) 2 f x f x b a n + −    × ÷     0 1 11 2( ) ( ) ( ) ( )( ) ( ) 2 2 2 n nf x f x f x f xf x f xb a n −+ ++−    + +×× × + ÷      Area = and then total area would be Letting the number of trapezoids n approach infinity, you improve the approximation to the exact answer. ( ) ( ) ( )0 1 1 2 1lim ( ) ( ) ( ) ( ) ( ) ( ) 2 n n n b a f x f x f x f x f x f x n − →∞ − + + + +×× × + +  
  • 21. There are many alternatives to the trapezoidal rule, but this method deserves attention because of : •Its ease of use •The trapezoidal rule has faster convergence. •Moreover, the trapezoidal rule tends to become extremely accurate than periodic functions •Powerful convergence properties •Straightforward analysis Advantages 7
  • 22. Thomas Simpson (1710-1761) used second-degree polynomials (a section of a quadratic) to approximate the graph for each subinterval. Before we get into Simpson’s Rule, we need to list a theorem for evaluating integrals of polynomials of degree 2 or less. THE SIMPSON’S RULE
  • 23. THE SIMPSON’S RULE Notice the coefficients are 1, 4, 2, 4, . . . 2, 4, 1
  • 24. EXAMPLE OF SIMPSON’S RULE : Given, f=(cos x); n=12; low value=-1; high value=2; Integrate the function over the values of x using Simpson’s 1/3 rule : clear all; close all; clc; h= -0.1; n=12; sum=0; f=inline(‘ cos (x)’); sum=sum + f(a) for i=2 : 2 :n ; x(i)=a + i*n; sum=sum+4*f(x(i)) end for i =3 : 2 : (n-1) ; x( i )=a + i *n; sum=sum+2*f(x(i)) end sum=sum + f(a +n * h) p=(sum*h)/3
  • 25. ERRORS : These two expressions tell how much of an error you can expect to get using either the Trapezoidal Rule or Simpson’s Rule.
  • 26.  http://en.wikipedia.org  www.google.com  http://slideshare.com  And various relevant websites References 15