Numerical Integration

  • View
    96

  • Download
    0

Embed Size (px)

DESCRIPTION

Numerical Integration. Four 2-variate Gaussians. Four 2-variate Gaussians. Gaussian pdf. Weight sum of Gaussian pdfs. myfx4.m. Plot 4G. plot_4G.m. Integration of 4G. demo_int_4G.m. Double integration. Numeric calculus for double integrals. demo_ex2_4G.m. Example. - PowerPoint PPT Presentation

Transcript

2008, Applied Mathematics NDHU1Numerical Integration2008, Applied Mathematics NDHU2Four 2-variate Gaussians

2008, Applied Mathematics NDHU3Four 2-variate Gaussians

2008, Applied Mathematics NDHU4Gaussian pdf

2008, Applied Mathematics NDHU5Weight sum of Gaussian pdfs

2008, Applied Mathematics NDHU6

myfx4.m2008, Applied Mathematics NDHU7Plot 4G

plot_4G.m2008, Applied Mathematics NDHU8Integration of 4G

demo_int_4G.mDouble integration2008, Applied Mathematics NDHU9Numeric calculus for double integrals

2008, Applied Mathematics NDHU10

ExampleApprox. integral2.230985141404140True Integral2.230985141404130demo_ex2_4G.m2.230985172585607 by dblquard.mexp(cos(x))2008, Applied Mathematics NDHU11

plot_expcos.mDefinite Integration2008, Applied Mathematics NDHU12

demo_quad.m

Symbolic integration2008, Applied Mathematics NDHU13demo_int.mExample

2008, Applied Mathematics NDHU14function of x:x.^2+2*x-5

fx1 =

Inline function: fx1(x) = 1./3.*x.^3+x.^2-5.*x2008, Applied Mathematics NDHU15Numerical integration - quadrature

2008, Applied Mathematics NDHU16Counter example

>> demo_intfunction of x:(1-sin(x.^2)).^(1/3)Warning: Explicit integral could not be found.2008, Applied Mathematics NDHU17

2008, Applied Mathematics NDHU18

plot_sin13.m

2008, Applied Mathematics NDHU19Numerical integration

demo_quad2.m

2008, Applied Mathematics NDHU20Mesh

2008, Applied Mathematics NDHU21Lower and upper sum

2008, Applied Mathematics NDHU22Lower sum : lower bound

2008, Applied Mathematics NDHU23Upper sum : upper bound

2008, Applied Mathematics NDHU24Composite Trapezoid rule

2008, Applied Mathematics NDHU25Uniform mesh

2008, Applied Mathematics NDHU26Error Analysis

2008, Applied Mathematics NDHU27Partition size

Composite Trapezoid ruleinput s, a and bf = inline(s); Set nh = (b-a)/n; ans = 1/2*(f(a)+f(b))for i=1:n-1 add f(a+i*h) to ansans= ans*h 2008, Applied Mathematics NDHU28f = inline(s); Set nh = (b-a)/n; ans = 1/2*(f(a)+f(b))

Input s,a,bFlow Chart2008, Applied Mathematics NDHU29for i=1:n-1add f(a+i*h) to ansans= ans*hEXITSimpson rule for numerical integration

2008, Applied Mathematics NDHU30Exercise

Draw a flow chart to illustrate integration by the composite Trapezoid ruleImplement the composite Trapezoid rule for numerical integration, including flow chart and Matlab codesTest your matlab function with the following integration

* Test your matlab function with definite integration of the weight sum of four Gaussian pdfs* Compare your results with those obtained by using quad.m

2008, Applied Mathematics NDHU31f(x)=exp(cos(x))