Top Banner
School of Mechanical Engineering Chung-Ang University Numerical Methods 2010-2 Numerical Integration Numerical Integration Formulas Formulas Prof. Prof. Hae Hae-Jin Choi Jin Choi [email protected] [email protected] Part 5 Part 5 Chapter 17 Chapter 17 1
30

Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

Jun 01, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Numerical Integration Numerical Integration FormulasFormulas

Prof. Prof. HaeHae--Jin ChoiJin Choi

[email protected]@cau.ac.kr

Part 5Part 5Chapter 17Chapter 17

1

Page 2: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Chapter ObjectivesChapter Objectives

2

l Recognizing that Newton-Cotes integration formulas are based on the strategy of replacing a complicated function or tabulated data with a polynomial that is easy to integrate.

l Knowing how to implement the following single application Newton-Cotes formulas:§ Trapezoidal rule§ Simpson’s 1/3 rule§ Simpson’s 3/8 rule

l Knowing how to implement the following composite Newton-Cotes formulas:§ Trapezoidal rule§ Simpson’s 3/8 rule

l Recognizing that even-segment-odd-point formulas like Simpson’s 1/3 rule achieve higher than expected accuracy.

l Knowing how to use the trapezoidal rule to integrate unequally spaced data.

l Understanding the difference between open and closed integration formulas.

Page 3: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

IntegrationIntegration

3

l Integration:

is the total value, or summation, of f(x) dx over the range from a to b:

l I represents the area under the curve f(x) between x= a and b.

I = f x( )a

bò dx

Page 4: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Integration in Engineering and ScienceIntegration in Engineering and Science

4

l This integral can be evaluated over a line, an area, or a volume.

l For example the total mass of gas contained in a volume is given as the product of the density and the volume. However, suppose that the density varies from location to location within a volume, it is necessary to sum the product

l For a continuous case, the integration is expressed by

l There is strong analogy between summation and integration

à Basis of numerical integration

1

n

i ii

mass Vr=

= Då

( , , )mass x y z dxdydzr= òòò ( )V

mass V dVr= òòò

Page 5: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

NewtonNewton--Cotes FormulasCotes Formulas

5

l The Newton-Cotes formulas are the most common numerical integration schemes.

l Generally, they are based on replacing a complicated function or tabulated data with a polynomial that is easy to integrate:

where fn(x) is an nth order interpolating polynomial.

I = f x( )a

bò dx @ fn x( )a

bò dx

nn

nnn xaxaxaaxf ++++= -

-1

110)( L

First-orderpolynomial(line)

Parabola

Page 6: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

The Trapezoidal RuleThe Trapezoidal Rule

6

l The integral can be approximated using a series of polynomials applied piecewise to the function or data over segments of constant length.

l For example, three straight line segments are used to approximate the integral. Higher-order polynomial can be used for the same purpose.

Page 7: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

The Trapezoidal RuleThe Trapezoidal Rule

7

l The trapezoidal rule is the first of the Newton-Cotes closed integration formulas; it uses a straight-line approximation for the function:

( )( ) ( ) ( )

( ) ( ) ( )

( )

( )(average height)2

b

na

b

a

I f x dx

f b f aI f a x a dx

b a

f a f bI b a I b a

=

é ù-= + -ê ú-ë û

+= - ® = -

ò

ò

Page 8: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Error of the Trapezoidal RuleError of the Trapezoidal Rule

8

l An estimate for the local truncation error of a single application of the trapezoidal rule is:

where x is somewhere between a and b.

l This formula indicates that the error is dependent upon the curvature of the actual function as well as the distance between the points.

l Error can thus be reduced by breaking the curve into parts.

Et = -1

12¢ ¢ f x( ) b - a( )3

Page 9: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Example 17.1 (1/2)Example 17.1 (1/2)

9

l Q. Use the trapezoidal rule to numerically integrate the following equation from a = 0 to b = 0.8. The true solution is 1.640533.

2 3 4 5( ) 0.2 2.5 200 675 900 400f x x x x x x= + - + - +

Sol.)

® Et = 1.640533 – 0.1728 = 1.467733 ® et = 89.5%

1728.02

232.02.0)08.0( =+

-=I

Page 10: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Example 17.1 (2/2)Example 17.1 (2/2)

10

Approximate error:32 000,8800,10050,4400)( xxxxf +-+-=¢¢

6008.0

)000,8800,10050,4400()(

8.0

032

-=-

+-+-=¢¢ ò dxxxx

xf

56.2)8.0)(60(121 3 =--=aE

note : this value is of the same order of magnitude and sign as the true error. Average second derivative is not an accurate approximation of f’’(ξ), so a discrepancy existsand Ea rather Et.

Page 11: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

fnabEa ¢¢-

-= 2

3

12)(

Composite Trapezoidal RuleComposite Trapezoidal Rule

11

l One way to improve the accuracy is to divide the integration interval from a to b into a number of segments and apply the method to each segment.

l Assuming n+1 data points are evenly spaced, there will be n intervals over which to integrate.

l The total integral can be calculated by integrating each subinterval and then adding them together:

( ) ( ) ( ) ( )

( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )

( ) ( ) ( )

1 2

0 0 1 1

0 1 1 2 11 0 2 1 1

1

011

01 Width

Average height

2 2 2

( ) 2 ( ) ( )2 ( )

2 2

n n

n

x x x x

n n n nx x x x

n nn n

n

i nni

i ni

I f x dx f x dx f x dx f x dx

f x f x f x f x f x f xI x x x x x x

f x f x f xhI f x f x f x I b a

n

-

--

-

-=

=

= = + + +

+ + += - + - + + -

+ +é ù

= + + ® = -ê úë û

ò ò ò ò

åå

L

L

123 14444244443

å=

¢¢--=

n

iit ξf

nabE

13

3

)(12

)(

fnξfn

ii ¢¢@¢¢å

=1)(

n

ξff

n

iiå

=

¢¢@¢¢ 1

)(

If the number of segments is doubled, the error will be quartered

If the number of segments is doubled, the error will be quartered

Page 12: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

MATLAB ProgramMATLAB Program

12

Page 13: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Example 17.2 (1/2)Example 17.2 (1/2)

13

l Q. Use the two-segment and composite trapezoidal rule to estimate the integral of the function from a = 0 to b = 0.8. The exact value is 1.640533.

2 3 4 5( ) 0.2 2.5 200 675 900 400f x x x x x x= + - + - +

232.0)8.0( 456.2)4.0( 2.0)0( === fff

0688.14

232.0)456.2(22.08.0 =++

=I

%9.34 57173.00688.1640533.1 ==-= tt εE

64.0)60()2(12

8.02

2=--=aE

Sol.For n = 2 (h = 0.4)

Page 14: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Example 17.2 (2/2)Example 17.2 (2/2)

14

<Results for the composite trapezoidal rule to estimate the integral of f(x) = 0.2 + 25x – 200x2 + 675x3 – 900x4

from x = 0 to 0.8. The exact value is 1.640533>à As the number of segments increases, the error decreases.

n h I et (%)23456789

10

0.40.2667

0.20.16

0.13330.1143

0.10.0889

0.08

1.06881.36951.48481.53991.57031.58871.60081.60911.6150

34.916.59.56.14.33.22.41.91.6

Page 15: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Simpson’s RulesSimpson’s Rules

15

l One drawback of the trapezoidal rule is that the error is related to the second derivative of the function.

l More complicated approximation formulas can improve the accuracy for curves - these include using (a) 2nd and (b) 3rd order polynomials.

l The formulas that result from taking the integrals under these polynomials are called Simpson’s rules.

Page 16: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Simpson’s 1/3 RuleSimpson’s 1/3 Rule

16

l Simpson’s 1/3 rule corresponds to using second-order polynomials. Using the Lagrange form for a quadratic fit of three points:

l Integration over the three points simplifies to:

( )

( ) ( ) ( )

2

0

0 1 20 1 2

( ) 4 ( ) ( )4 ( )3 6

x

nxI f x dx

f x f x f xhI f x f x f x I b a

=

+ +é ù= + + = = -ë û

ò�

fn x( )=x - x1( )x0 - x1( )

x - x2( )x0 - x2( )

f x0( )+x - x0( )x1 - x0( )

x - x2( )x1 - x2( )

f x1( )+x - x0( )x2 - x0( )

x - x1( )x2 - x1( )

f x2( )

Where, h = (b – a)/2, a = x0, b = x2, and x1 = (a + b)/2

Page 17: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Error of Simpson’s 1/3 RuleError of Simpson’s 1/3 Rule

17

l An estimate for the local truncation error of a single application of Simpson’s 1/3 rule is:

where again x is somewhere between a and b.l This formula indicates that the error is dependent upon the fourth-

derivative of the actual function as well as the distance between the points.

l Note that the error is dependent on the fifth power of the step size (rather than the third for the trapezoidal rule).

l Error can thus be reduced by breaking the curve into parts.

Et = -1

2880f 4( ) x( ) b - a( )5

Page 18: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Example 17.3Example 17.3

18

l Q. Use Simpson 1/3 rule to integrate the following equation from a = 0 to b = 0.8. Exact solution is 1.640533.

2 3 4 5( ) 0.2 2.5 200 675 900 400f x x x x x x= + - + - +

sol) for n = 2 (h = 0.4)에 대해서

® This shows improved results compared to the trapezoidal rule.

232.0)8.0( 456.2)4.0( 2.0)0( === fff

367467.16

232.0)456.2(42.08.0 =++

=I

%6.16 2730667.0367467.1640533.1 ==-= tt εE

2730667.0)2400(2880

8.0 5

=--=aE

Page 19: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Composite Simpson’s 1/3 RuleComposite Simpson’s 1/3 Rule

19

l For improved results, Simpson’s 1/3 rule can be used on a set of subintervals in much the same way the trapezoidal rule was, except there must be an odd number of points..

l Because of the heavy weighting of the internal points, the formula is a little more complicated than for the trapezoidal rule:

I = fn x( )x0

xnò dx = fn x( )x0

x2ò dx + fn x( )x2

x4ò dx +L+ fn x( )xn-2

xnò dx

I =h3

f x0( )+ 4 f x1( )+ f x2( )[ ]+h3

f x2( )+ 4 f x3( )+ f x4( )[ ]+L+h3

f xn-2( )+ 4 f xn-1( )+ f xn( )[ ]

I =h3

f x0( )+ 4 f xi( )i=1i, odd

n-1

å + 2 f xi( )j=2j , even

n-2

å + f xn( )é

ë

ê ê ê

ù

û

ú ú ú

)4(4

5

180)( f

nabEa

--=

Page 20: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Example 17.4Example 17.4

20

l Q. Use composite Simpson 1/3 rule to integrate the following equation from a = 0 to b = 0.8. Exact solution is 1.640533.

2 3 4 5( ) 0.2 2.5 200 675 900 400f x x x x x x= + - + - +

Sol.) for n = 4 (h = 0.2)

232.0)8.0(464.3)6.0( 456.2)4.0(288.1)2.0( 2.0)0(

=====

fffff

623467.112

232.0)456.2(2)464.3288.1(42.08.0 =++++

=I

%04.1 017067.0623467.1640533.1 ==-= tt εE

017067.0)2400()4(180

8.04

5

=--=aEEstimated error:

Page 21: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Example 17.4Example 17.4

21

l The composite version of Simpson 1/3 rule is superior to the trapezoidal rule for most applications.

l It is limited to cases where the values are equispaced.,even number of segments, and odd number of points.

l Odd segment and even point formula is known as Simpson 3/8 formula.

Page 22: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2 22

Simpson’s 3/8 RuleSimpson’s 3/8 Rulel Simpson’s 3/8 rule corresponds to

using third-order polynomials to fit four points. Integration over the four points simplifies to:

l Simpson’s 3/8 rule is generally used in concert with Simpson’s 1/3 rule when the number of segments is odd.

I = fn x( )x0

x3ò dx

I =3h8

f x0( )+ 3 f x1( )+ 3 f x2( )+ f x3( )[ ]

Page 23: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

HigherHigher--Order FormulasOrder Formulas

23

l Higher-order Newton-Cotes formulas may also be used - in general, the higher the order of the polynomial used, the higher the derivative of the function in the error estimate and the higher the power of the step size.

l As in Simpson’s 1/3 and 3/8 rule, the even-segment-odd-point formulas have truncation errors that are the same order as formulas adding one more point. For this reason, the even-segment-odd-point formulas are usually the methods of preference.

Page 24: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Example 17.5 (1/2)Example 17.5 (1/2)

24

l Q. (a) Use Simpson 3/8 to integrate from a = 0 to b = 0.8. (b) Use it in conjunction with Simpson 1/3 for five segment integration.

2 3 4 5( ) 0.2 2.5 200 675 900 400f x x x x x x= + - + - +

Sol.) (a) For n = 3 (h = 0.2667)

232.0)8.0( 487177.3)5333.0(432724.1)2667.0( 2.0)0(

====

ffff

51970.18

232.0)487177.3432724.1(32.08.0 =+++

=I

(b) For n = 5 (h = 0.16)

232.0)80.0( 181929.3)64.0(186015.3)48.0( 743393.1)32.0(296919.1)16.0( 2.0)0(

======

ffffff

Page 25: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Example 17.5 (2/2)Example 17.5 (2/2)

25

The integral for the first two segments using Simpson 1/3

3803237.06

743393.1)296919.1(42.032.0 =++

=I

For the last three segments, the Simpson 3/8

264754.18

232.0)181929.3186015.3(3743393.148.0 =+++

=I

The total integral is by summing the two results.

645077.1264754.13803237.0 =+=I

Page 26: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

SummarySummary

26

n points name 공 식 절단오차

1 2 Trapezoidal rull

2 3 Simpson 1/3

3 4 Simpson 3/8

4 5 Boole’s rull

5 6

<Newton-Cotes integration: h = (b – a)/n>

2)()(

)( 10 xfxfab

+- ( ) )(12/1 3 x¢¢- fh

6)()(4)(

)( 210 xfxfxfab

++- ( ) )(90/1 )4(5 x- fh

8)()(3)(3)(

)( 3210 xfxfxfxfab

+++- ( ) )(80/3 )4(5 x- fh

90)(7)(32)(12)(32)(7

)( 43210 xfxfxfxfxfab ++++- ( ) )(945/8 )6(7 x- fh

288)(19)(75)(50)(50)(75)(19)( 543210 xfxfxfxfxfxfab +++++

- ( ) )(096,12/275 )6(7 x- fh

Page 27: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Integration with Unequal SegmentsIntegration with Unequal Segments

27

l Previous formulas were simplified based on equispaced data points - though this is not always the case.

l The trapezoidal rule may be used with data containing unequal segments:

I = fn x( )x0

xnò dx = fn x( )x0

x1ò dx + fn x( )x1

x2ò dx +L+ fn x( )xn-1

xnò dx

I = x1 - x0( ) f x0( )+ f x1( )2

+ x2 - x1( ) f x1( )+ f x2( )2

+L+ xn - xn-1( ) f xn-1( )+ f xn( )2

Page 28: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Integration Code for Unequal Integration Code for Unequal SegmentsSegments

28

Page 29: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

MATLAB Functions (option)MATLAB Functions (option)

29

l MATLAB has built-in functions to evaluate integrals based on the trapezoidal rule

l z = trapz(y)z = trapz(x, y)produces the integral of y with respect to x. If x is omitted, the program assumes h=1.

>> x = [0 .12 .22 .32 .36 .4 .44 .54 .64 .7 .8];

>> y = 0.2 + 25*x - 200*x.^2 + 675*x.^3 - 900*x.^4 + 400*x.^5;

>> trapz(x,y)

ans =

1.5948

Page 30: Part 5 Chapter 17 - CAUisdl.cau.ac.kr/.../numerical.analysis/Lecture15.pdfPart 5 Chapter 17 1 School of Mechanical Engineering Chung-AngUniversity Numerical Methods 2010-2 Chapter

School of Mechanical EngineeringChung-Ang UniversityNumerical Methods 2010-2

Multiple IntegralsMultiple Integrals

30

• Multiple integrals can be determined numerically by first integrating in one dimension, then a second, and so on for all dimensions of the problem.