Documente Academic
Documente Profesional
Documente Cultură
A NumFys Module
http://www.numfys.net
Fall 2012
A NumFys Module
Module 2.1: Numerical Integration - Part 1
http://www.numfys.net
Slides
p.1
Matlab Module
First Step:
Save the corresponding Matlab code onto your computer and
open it in Matlab.
A NumFys Module
Module 2.1: Numerical Integration - Part 1
http://www.numfys.net
Slides
p.2
(1)
http://www.numfys.net
Slides
p.3
(4)
Lets plot
the integrand
f (x) = x 5 + e5x for
x [0, 1].
A NumFys Module
Module 2.1: Numerical Integration - Part 1
http://www.numfys.net
Slides
p.4
(6)
http://www.numfys.net
Slides
p.5
http://www.numfys.net
Slides
p.6
A NumFys Module
Module 2.1: Numerical Integration - Part 1
http://www.numfys.net
Slides
p.7
http://www.numfys.net
Slides
p.8
A NumFys Module
Module 2.1: Numerical Integration - Part 1
http://www.numfys.net
Slides
p.9
(9)
and so
f2 + f3
f3 + f4
fN1 + fN
f1 + f2
+h
+h
+ ...h
.
2
2
2
2
Factoring out h and rearranging terms gives
1
1
f1 + f2 + f3 + ... + fN1 + fN .
A=h
2
2
A=h
(10)
(11)
http://www.numfys.net
Slides
p.10
A NumFys Module
Module 2.1: Numerical Integration - Part 1
http://www.numfys.net
Slides
p.11
(b a)3 ,
1
and
N2
the (maximum) magnitude of the second derivative of f (x)
over the respective interval.
http://www.numfys.net
Slides
p.12
http://www.numfys.net
Slides
p.13
(15)
http://www.numfys.net
Slides
p.14
http://www.numfys.net
Slides
p.15
A NumFys Module
Module 2.1: Numerical Integration - Part 1
http://www.numfys.net
Slides
p.16
A NumFys Module
Module 2.1: Numerical Integration - Part 1
http://www.numfys.net
Slides
p.17
http://www.numfys.net
Slides
p.18
f (x) dx
a
h
[f (x1 ) + 4f (x2 ) + 2f (x3 ) + 4f (x4 ) + ... + 4f (xN1 ) + f (xN )]
3
(19)
f (x) dx
a
h
[f1 + 4f2 + 2f3 + 4f4 + ... + 4fN1 + fN ] .
3
(20)
Let us use Matlab again to compute the same integral as for the
trapezoidal rule, only this time we use Simpsons rule.
Simply uncomment the corresponding lines in the enclosed
Matlab script!
A NumFys Module
Module 2.1: Numerical Integration - Part 1
http://www.numfys.net
Slides
p.19
Try it yourself!
Choose N = 3, 5, 7, 9, 11, 13, 15.
Does it converge faster than before?
A NumFys Module
Module 2.1: Numerical Integration - Part 1
http://www.numfys.net
Slides
p.20
(b a)5 ,
1
N4
and
A NumFys Module
Module 2.1: Numerical Integration - Part 1
http://www.numfys.net