You are on page 1of 5

University of Santo Tomas Faculty of Engineering Department of Electronics and Communications Engineering

Numerical Integration using Trapezoidal and Simpsons Rule


A Project for Numerical Methods for ECE (Math421)

By Aguilar, Patrick Baloaloa, Ep raim Casa!ar, Est er Ec ica, "uigi Boy Pytingco, #olly $u, Brion %ECE&B

Engr' Edison (o)as

*arc +, ,-./

I. BACKGROUN

0umerical integration is t e appro)imate computation of integral using numerical met ods' T e numerical computation of an integral is sometimes called 1uadrature' Ueberhuber 2.33+, p' +.4 uses t e 5ord 61uadrature6 to mean numerical computation of a univariate integral, and 6cu!ature6 to mean numerical computation of a multiple integral' T e most straig tfor5ard numerical integration tec ni1ue uses t e 0e5ton&Cotes formulas 2also called 1uadrature formulas4, 5 ic appro)imate a function ta!ulated at a se1uence of regularly spaced intervals !y various degree polynomials' 7f t e endpoints are ta!ulated, t en t e ,& and /&point formulas are called t e trapezoidal rule and Simpson!s rule, respectively' Simpson8s rule and trape9oidal rules are simple and effective tec ni1ues for numerically evaluating integrals' :o5ever, practical implementation re1uires more t an is often presented in introductions to t e met od' T is pro;ect implements t e said algorit ms in #ava programming language and 5ill discuss t e preparation integrals for evaluation'

II. INTRO UCTION and T"#OR$

T is study used t5o 5ays to solve t e input e1uations numerically' First, T%e Simpsons Rule, given an interval <a, b= and an even num!er n, Simpson8s rule appro)imates t e integral

!y

5 ere h > 2b & a4?n and

> a @ ih'

!i"ure 1# $he %im&son's (ule for A&&ro imatin" a )efinite *nte"ral

A ile t at is a correct description of t e algorit m, it leaves t5o related 1uestions unans5eredB .' ,' :o5 good is t e appro)imationC :o5 s ould 7 c oose nC

7n practice, users seldom kno5 !efore to start o5 large n needs to !e in order to meet t e accuracy re1uirements' 7f it can estimate t e error at runtime, it can !e used to estimate and determine n' A common approac is to repeatedly apply Simpson8s rule, dou!ling t e num!er of integration points at eac stage' T e difference !et5een t5o

successive stages gives an estimate of t e error, so you continue dou!ling t e stages until t e error estimate is !elo5 your tolerance' T ere are a couple practical matters to implementing t is approac ' First, if naively implemented, t e met od 5ill re&evaluate t e integrand at t e same points multiple times' At eac ne5 stage, alf of t e integration points are t e same as t ey 5ere at t e previous stage' A little alge!ra makes it possi!le to reuse t e integral estimate from t e previous stage and only evaluate t e integrand at t e ne5 integration points' T e second practical implementation matter is to not c eck t e stopping criterion too soon' 7f you c eck t e stopping criterion after eac stage, it is possi!le in t e early stages t at t e integration points miss regions of varia!ility in t e integrand and are led to !elieve t e met od as converged 5 en it as not'

T e ot er met od used in t is study is t e Trapezoid Rule' 7n t is met od appro)imations of f D<a,!= using t e endpoints of t e interval <a+ b= as our interpolation' T e polynomial interpolant 5ill t us !e a linear polynomial 25it degree at most .4 passing t roug f 2a4 and f 2b4, as s o5n in Figure E and 5e can calculate its area *$ simply, using

0ote t at t e t5o 5eig ts ,- , ,. in t is case are eac .-, . 2b / a4' T e sum of t e 5eig ts 5ill al,a0s e1ual t e 5idt of t e interval 2b / a4'

!i"ure 2# $he $ra&e1oid (ule for A&&ro imatin" a )efinite *nte"ral

7t can summari9e t e trape9oid rule !y t e notation Fa, !G' T is notation means t at t e trape9oid rule appro)imates t e integral integrating t is polynomial' !y evaluating

f at a and b, finding t e polynomial 5 ic interpolates t ese t5o points, and

III. SCO&# AN I). A'GORIT"( ). SI(U'ATION )I. R#SU'TS )II.

'I(ITATIONS

T e c ecking of convergence using t e eit er met od 5ill depend on t e user8s input' T e num!er of iteration allo5ed is limited to one undred 2.--4 iterations only'

CONC'USION R#*#R#NC#S

ttpB??mat 5orld'5olfram'com?0umerical7ntegration' tml ttpB??en'5iki!ooks'org?5iki?0umericalH*et ods?0umericalH7ntegration

You might also like