Download - Numerical Integration
![Page 1: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/1.jpg)
數值方法 2008, Applied Mathematics NDHU 1
Numerical Integration
![Page 2: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/2.jpg)
數值方法 2008, Applied Mathematics NDHU 2
Four 2-variate GaussiansFour 2-variate Gaussians
![Page 3: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/3.jpg)
數值方法 2008, Applied Mathematics NDHU 3
Four 2-variate GaussiansFour 2-variate Gaussians
![Page 4: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/4.jpg)
數值方法 2008, Applied Mathematics NDHU 4
Gaussian pdfGaussian pdf
![Page 5: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/5.jpg)
數值方法 2008, Applied Mathematics NDHU 5
Weight sum of Gaussian pdfsWeight sum of Gaussian pdfs
![Page 6: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/6.jpg)
數值方法 2008, Applied Mathematics NDHU 6
myfx4.m
![Page 7: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/7.jpg)
數值方法 2008, Applied Mathematics NDHU 7
Plot 4GPlot 4Gplot_4G.m
![Page 8: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/8.jpg)
數值方法 2008, Applied Mathematics NDHU 8
Integration of 4GIntegration of 4Gdemo_int_4G.m
Double integration
![Page 9: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/9.jpg)
數值方法 2008, Applied Mathematics NDHU 9
exp(cos(x))exp(cos(x))plot_expcos.m
![Page 10: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/10.jpg)
數值方法 2008, Applied Mathematics NDHU 10
Definite IntegrationDefinite Integrationdemo_quad.m
![Page 11: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/11.jpg)
數值方法 2008, Applied Mathematics NDHU 11
Symbolic integrationSymbolic integration
demo_int.m
![Page 12: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/12.jpg)
數值方法 2008, Applied Mathematics NDHU 12
ExampleExample
function of x:x.^2+2*x-5
fx1 =
Inline function: fx1(x) = 1./3.*x.^3+x.^2-5.*x
-5 -4 -3 -2 -1 0 1 2 3 4 5-10
0
10
20
30
40
50
![Page 13: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/13.jpg)
數值方法 2008, Applied Mathematics NDHU 13
Numerical integration - Numerical integration - quadrature quadrature
![Page 14: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/14.jpg)
數值方法 2008, Applied Mathematics NDHU 14
Counter example Counter example
>> demo_intfunction of x:(1-sin(x.^2)).^(1/3)Warning: Explicit integral could not be found.
![Page 15: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/15.jpg)
數值方法 2008, Applied Mathematics NDHU 15
-5 -4 -3 -2 -1 0 1 2 3 4 50
0.2
0.4
0.6
0.8
1
1.2
1.4
![Page 16: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/16.jpg)
數值方法 2008, Applied Mathematics NDHU 16
plot_sin13.m
![Page 17: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/17.jpg)
數值方法 2008, Applied Mathematics NDHU 17
Numerical integrationNumerical integration
demo_quad2.m
![Page 18: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/18.jpg)
數值方法 2008, Applied Mathematics NDHU 18
MeshMesh
![Page 19: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/19.jpg)
數值方法 2008, Applied Mathematics NDHU 19
Lower and upper sumLower and upper sum
![Page 20: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/20.jpg)
數值方法 2008, Applied Mathematics NDHU 20
Lower sum : lower boundLower sum : lower bound
![Page 21: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/21.jpg)
數值方法 2008, Applied Mathematics NDHU 21
Upper sum : upper boundUpper sum : upper bound
![Page 22: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/22.jpg)
數值方法 2008, Applied Mathematics NDHU 22
Composite Trapezoid ruleComposite Trapezoid rule
![Page 23: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/23.jpg)
數值方法 2008, Applied Mathematics NDHU 23
Uniform meshUniform mesh
![Page 24: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/24.jpg)
數值方法 2008, Applied Mathematics NDHU 24
Associate errorAssociate error
![Page 25: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/25.jpg)
數值方法 2008, Applied Mathematics NDHU 25
Partition sizePartition size
![Page 26: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/26.jpg)
數值方法 2008, Applied Mathematics NDHU 26
Procedure: Composite Trapezoid Procedure: Composite Trapezoid rulerule
1.1. Get ss, a and bGet ss, a and b
2.2. Set fx to inline(ss); Set nSet fx to inline(ss); Set n
3.3. h = (b-a)/n; result = 1/2*(fx(a)h = (b-a)/n; result = 1/2*(fx(a)+fx(b)); for i=1:n+fx(b)); for i=1:n
Add fx(a+i*h) to resultAdd fx(a+i*h) to result
4.4. Return result*hReturn result*h
![Page 27: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/27.jpg)
數值方法 2008, Applied Mathematics NDHU 27
Simpson rule for numerical Simpson rule for numerical integrationintegration
![Page 28: Numerical Integration](https://reader036.vdocuments.mx/reader036/viewer/2022081416/56815425550346895dc2266b/html5/thumbnails/28.jpg)
數值方法 2008, Applied Mathematics NDHU 28
Exercise Exercise Due to 12/19Due to 12/19
► Implement the composite Trapezoid rule for numerical Implement the composite Trapezoid rule for numerical integration, including flow chart and Matlab codesintegration, including flow chart and Matlab codes
► Implement the composite Sympson rule for numerical Implement the composite Sympson rule for numerical integration, including flow chart and Matlab codesintegration, including flow chart and Matlab codes
► Test your matlab function with the following integrationTest your matlab function with the following integration
► * Test your matlab function with definite integration of * Test your matlab function with definite integration of the weight sum of four Gaussian pdfsthe weight sum of four Gaussian pdfs
► * Compare your results with those obtained by using * Compare your results with those obtained by using quad.mquad.m
f(x)=exp(cos(x))