0% found this document useful (0 votes)
16 views25 pages

Numerica Integration Cprogram

IOE NUMERICAL INTEGRATION LAB REPORT

Uploaded by

avigemgemini01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
16 views25 pages

Numerica Integration Cprogram

IOE NUMERICAL INTEGRATION LAB REPORT

Uploaded by

avigemgemini01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 25
Numeral Tnfeprahion (Rin chon ond Dataset) [Theony: ‘The press of evaluchng a definite int ral fom aset f tabuloted Velues of tre ingrend fin Gcstes eet integrase «The pres when pphed to @ funchon of a single variable 's known Gs quockahe- Newtons -Cote Quedalre Farmuloe’ Given acet af date pants (ai,yi) sis On1)2,- 0 of fonchon yf Lahece fA) it rob explicitly known: let TZ: [? —U et Ds [P yda © (An) where yf) tales the valves Ye hs gait — —- Yn for Ho, 1% —— An: Vet Dide the interval @.b) into 'n’ quel pore feet ‘hy Go that a: Ho, A 2Hoth Are Hoth ;AZsHotGh - - -- AT Hot Mh +b Sine, Hora and, An: Aotnh zb , the integral became, an | co J yaa | Ho roxio BY Newhn' fowerd Inkerpolohen formulae , a: [te Pages 2g) Bip 4 plazlle:2) ay « _- Jaa. a 0 “Since, 12 %orphy da shdp abort integrarhen beeemin: a Te | [ot pote Age Sipe 4 ele-ilo=22 O46 + - ~ |e 2 ch rit bp (3-4 )SH an +(gf-nb4m ) 4746 ‘dy? - -]® 1) Trapezeidal rule‘ Pathng qb in eq? (2) ond tedeen, Cure Hhrevgh (Rorsporond (hes Ge) as ase-line » higher thon int differences becemen zero. we get ec fan. Ro hl), dpe) FG Cyrgrye) hg he Yr)» Arcaaf haperivm: aun tb mpencd (A404) We get “gm Poe m ay) Weg a ‘f yan oth > W(Wi 5 O4r) ohy (ry tgr-gr) ahylyityr) \Simlerl for lowe interval (ati tn] we ger Th + ‘a For(n-Lh * De (Yn-1 449) Combining al there tome get . Ww +TitTa1- — --t In da = he [yotyo) # Myriga dar - - gan) ] This ts called lemparte hepezoded nile. — °oF 2)Sirrpsemi dy-rule Potnng n22in ent yond cee cuurre Horeigh (tor Yo), (An gr? ond (args) os porcibola iehigher then second orders beeamua tere sue get 1] yan to +h (Yo t Siar Se) 2h [yor yi-gpet Yldyr-OHe) J | * MT oys eyo-2yrt God ~ hy laeetgs ta] | ——o_«606§0§801§€ @& = 8= = = [Agen storaae waenal Tatar Fe) oe gel Tr , forse go Rot dh 2h (yprdynt YY) 2DhL tar (ys-Yo) el Os O49) ] = hy (645 eu -2g9 ty) HY »] tng [Capryp + 4 linn cf ocd vdrnates) 124 (um ef eeradinates 7 This iscalted Comparte Simpson “hivle 3) Simpson's “Yyvle- Pothng 023 neg as ape, namradef third order 14 zero" g ’ aie ah [yo 1 55401 %, Bye Eo] ay [a+ 94. + Syo aa] a2) onde Cunt thi Ro hr (AYA) Fes Ob 2F- ~ | ighe- than third dbffercnees beewris “|Simlorg, 45h f Fimdde = 3p [ys ynet Syst fe] and so ory ‘oth Adlng at.uch exproston fom to Hoth whec 7 amulnple $3 ob | eon | JFondn 2h [lwegn) + Blaiegee ter — = -AGna) 4 yseyer - tyr] Xo | This is coltedSimmpsan's 3p rule, ‘Algentom | Preudo cock + PT eapezordl mle |) Start D Define forchen fin) 3) Bnput 2 lower limit integrebon (a) Upper lien af integrabon (b) No-gf strips (9) 4) Giluulate step size! hz (b-a)/n 5) gum flere fb) 6) foriz b teak ”v sum ssumt ire neat t in dtg: hg sve ax flatiny «Simpsons Yy-rvle 1) Suet 2D) Deprne fanchon f () 3) Input’ lower innit of in) No-of ships (n) 4) Coluclote step size (h):6-a)/n 5) Sum «flo + ple) 6) for Fz bdlo-L) if Cimed)2=0 else end rf nexti \p Sig Joumashy, 8) Aiplog oe os result sep Simpson -Yynle- 1) Stork 2) Depne funchon fi) 3) Tnput No. shops (9) 4) Cludodte LITE ole 5) Gorn ~f (0) +f) lower limeg inte Upper host ad rohanla) Upper lirnit af inthe rer on | ») ) gum sum toxflarin) cums gum +4 x f lotih) chon (0) chon (b) ire Pel doo-k If fred 3 #0 Sum ssum 13eflotth) else Sum:sum 19% florih) endif Next 7) Tq 2 Sumy Shy Is) ‘Oupleg Ty Gs roult 9)Sap- [Prapermdal wle with dete set + N) Start 2) Tnpk a, a,b Input valves dota set -for7 20 ton-L Read-di next i a) he lb-a lin-4) | Sum: Yot4n 5) fois bank sum: samt 2gi next (6) Taity = bye |2) Duply P44 #) Sep Program UrdeUropernidel@utey ]* Numericad ategrchor* | fitinclude. Hein clude £Lemoh> Htinclude ; Qn yohon 2( NA )>surry porgiea Raq wied value ef Dnbegrohen ving return Ly qr; Tapegordad re rs = yaa Inteyehon 5 | Funchon is P= 1/40 Enter lower limit f Integrahor 20 Enter upper hmnit of mntesrahon 26 Numbe~ of shops 72 6 Wiel Hy of ship zL- 000000 Regured valve £ Intepahen nag Trapegsrclad rule f= 1410799 Nt em inects) ETayal (Ole (-necauel [OM 12 #include #include float f(float x) { return 1/(1+x*x); mae i int main() { a AL float a,b,h,sum, Integration; printf("Function is I=1/(1+x2)\n"); printf("\nEnter lower limit of integration="); scanf("%f",&a); printf("\nEnter upper limit of integration="); scanf("%f",&b); printf("\nNumber of strips?="); scanf("%d",&n); h=(b-a)/n; Yai aA NUCele nee] aa] et OAR MAO) sum=f(a)+f(b); for(i=1;i<=n-1;i++) { sum=sum+2*f(ati*h); } Integration=(h/2)*sum; printf ("\nRequired value of Integration using Trapezoidal rule is=%f", Integration); rcaae len getch(); i < Function is I=1/(1+x2) Te ee ea eee ist) CO eet See Go sto Laas Tey Cote ari et eee) ete Ghee mt Mate Tot ae eee SEL) [Program finished][l Function is I= x3 eC Ce Ue UCSC) cen ies eC ee aU Tete ToC] Tat Width of strip=0.200000 ot Cea Ce Cuma Ce CCM (Program finished] is=0. 260000 v v Pregrom Lede (Gimpuum -yrvte) [Dinumental Dnteg chor) Heinilude Hemclude fleet fl float) t | em titexany > 5 int main C) | Wreten Haman) | | int ny floor ay, hsum in rahon 5 i prottf (" Renchon 1s T= Wena do} Iprirefl" Finchon is D> 23\0""); Hate U\n Enter lower hit gintegrahen 2 2; Stonf "Af 2475, a partf U\n Enterupperlim it efintegre hm 2")5 Gonf ("FF 126); | prate("\n Number sf ships ? = "25 sangl" 1d 480), 2 (h-a)/n‘ eee af-ship «Lf \o"sh), | sum 2flore pl) | [ *Sinpsm 4/9-Rule | for (Tel iezn-L5 iF) a Sum = sume 2x flat ixh) 5 else Sum: Sum + 4xfla-rinh) 5 3 Tnteg cohon: (Np )asem : ne ("\ real val tL Ss Rule is 2 Zp VEnt per in Reqs value ff ategrechone using mpson ta Role is topo, Ve L' ) gern); Output Finchon is Bs Vortary Enter lower limit of integrahon 20 Enter upper limit integrenon 26 iNo. of strips 9:6 ili ef ship = L-000000 Requred valve fintgehen vse Simpson “Jy Rule i4-366174 c-3 fe eM aba fe de fe #include float (float x) { return 1/(1+x*x); i int main() { aH float a,b,h,sum, Integration; Pale Gaede a Eas kU printf("\nEnte er limit of integration="); Eye 1a i printf("\nEnter upper limit of integration="); scanf("%f",&b); printf("\nNumber of st scanf("%d",&n); h=(b-a)/n; printf("\nWidth of strip=% sum=f(a)+f(b); Ok (ee ean) { if(i%2==0) sum=sum+2*f(ati*h); else Up li Coal lal DH i Integration=(h/3)*sum; aaa CRY Mo miter using Simpson 1/3 ntegration odie elean 0H i Function is I=1/(1+x?) hae cee La Le ete et) Cia ae eC Ra ae te let) COL eee es tla eet eam! tt) Required value of Integration using Simpson 1/3- Rule is=1.366174 [Program finished]]J < Function is I= x? eC eS ee eucarieCin) ec eee etc te totic Tact ee) Width of strip=0.125000 Required value of Integration using Simpson 1/3- Rule is=0.250000 [Program finished] jj ' Program ide (Simpson Yg Rule) | [xNumerical Tr rohon el J |4rinclude 6 | wath of ip: $-000000 eget volue f integrohen wey Simpson Yy wle 13 = -70P) po hen +0 renee res #include #include #include t f(float x) i 1/(1+x*x); main() ti,n; float a,b,h,sum, Integration; printf("Function is l=1/(1+x2)\n"); printf("\nEnter lower limit of integration="); scanf("° nter upper limit of integration="); &b); Tan} o)=1 m0) 6-108 | 9 )-Yeod printf("\nWidth of strip=%f\n",h); sum=f(a)+f(b); for(i=1;i<=n-1,i++) { f(i%3!=0) sum=sum+3*f(ati*h); sum=sum+2* f(ati*h); i Integration=(3*h/8)*sum; printf ("\nRequired value of Integration using Rule is=%f", Integration); r Function is I=1/(1+x?) ee eee ee ae te Tet Te) Chet eee aU te Tsun) Peer st tre) RLM et ea eel) Required value of Integration using Simpson 3/8- Rule is=1.357081 tee ae eG) c4 Function is I= x? ae Ch eee a AUT ste a eee MU TsC oa Dae eC mee a RPL) Required value of Integration using Simpson 3/8- Rule is=0.239960 aay) | p, —— — - Tgrom IC Trepetadal nile we dota set) ya Nomerrcal Inbegrehon | Fndlide clot ccenionh> SS inclucte int ia: float ay bh Sum ig Cloos Tg 5 POOH" Entenno. dota sets(7) ey | Seanp(" 2d", 305, [Prattl” Enter lower ord upper vent: [Seong "Z$" Ba,8) 5 [Peetgl Ener vole fderaset! (forliz0 5 fe 2n-4; 144) | £ >: Seang ("% fp", BYCID hilb-or/a-L); sum or] Cod +gtas; for (tobi fest 5149) Sums sum t2ayli 5 3 Lig: (og ser 5 oo, poor!" \atasegral 274% 34) gerhos j Outpt: Enkr nef dota sets (nm) 710 Enterlowerand upper himit 10 G Enter valve 4 dom geek Pot egral = 15-733334 | 25 6 23 V6 TH ne 9 2 | ) i *Numerical Integrat #include #include #include void main() a Aa float a,b,h,sum, Itg,Y[100]; printf("Enter number of data Erte) HO Yer=] nae) printf("Enter lower and upper limit :"); scanf("%f %f",&a,&b); h=(b-a)/n; printf("Enter value of data set:"); OVC lO ted ee scanf("%f",&YLi]); } h=(b-a)/(n-1); for(i=O;i<=n-1;i++) { sum=sum+2*Y[i]; } Itg=(h/2)*sum; printf ("\nintegral=%f", Itg); getch(); 4 Enter number of data sets(n):10 Enter lower and upper limit :0 6 Enter value of data set:1 1.2 1.5 1.6 2.3 2.6 7.81.71.92 Integral=15 . 733334 [Program finished]]f ee ee |Core lasien | Discuss 107" Niuroberr l, a Preqrors were Written nC fom performing nume reo | chon (Of Meperotlal rele, Simp - 74 le Simpson 3pgrule + Valve of integrad wer ‘found for der dota cets fer using Troperorded rile - Lowerend Upp i ¢ the intggeainon woo prvided ae f and volve of iokeg ral wos Lemp bua

You might also like