數值方法 2008, Applied Mathematics NDHU 1 Numerical Integration

  • Published on
    05-Jan-2016

  • View
    217

  • Download
    5

Embed Size (px)

Transcript

  • 2008, Applied Mathematics NDHU*Numerical Integration

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Four 2-variate Gaussians

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Four 2-variate Gaussians

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Gaussian pdf

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Weight sum of Gaussian pdfs

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*myfx4.m

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Plot 4Gplot_4G.m

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Integration of 4Gdemo_int_4G.mDouble integration

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*exp(cos(x))plot_expcos.m

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Definite Integrationdemo_quad.m

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Symbolic integrationdemo_int.m

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Examplefunction of x:x.^2+2*x-5

    fx1 =

    Inline function: fx1(x) = 1./3.*x.^3+x.^2-5.*x

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Numerical integration - quadrature

    2008, Applied Mathematics NDHU

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

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*plot_sin13.m

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Numerical integrationdemo_quad2.m

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Mesh

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Lower and upper sum

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Lower sum : lower bound

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Upper sum : upper bound

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Composite Trapezoid rule

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Uniform mesh

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Associate error

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Partition size

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Procedure: Composite Trapezoid ruleGet ss, a and bSet fx to inline(ss); Set nh = (b-a)/n; result = 1/2*(fx(a)+fx(b)); for i=1:n Add fx(a+i*h) to resultReturn result*h

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Simpson rule for numerical integration

    2008, Applied Mathematics NDHU

  • 2008, Applied Mathematics NDHU*Exercise Due to 12/19Implement the composite Trapezoid rule for numerical integration, including flow chart and Matlab codesImplement the composite Sympson 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

    f(x)=exp(cos(x))

    2008, Applied Mathematics NDHU