0% found this document useful (0 votes)
23 views

Midterm Cheat Sheet - 230417 - 004726

Uploaded by

Girie Yum
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)
23 views

Midterm Cheat Sheet - 230417 - 004726

Uploaded by

Girie Yum
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/ 4
Lineve elergelaton gE mentemse WARY ch a, Todd Ge FC catinnas on C9,53 ), there entsls some 26 (a6) sah Mer fory be ang yellor.fin) relue Hrearéon eve seb -WVW3 22 ew seh CCery—seh, ew) EAA tehun (ow-sel) Hed Q q Newhen ¢ bisection i Tiaeor ilerpelati Neeaslon's note? Newton's meted? | 3%! D chatleaying b get o” onaly fea | och (1: kage Yaesel) , aS Cyaseh- met) | pessice Yor Tg derivative oF f on terrore @ terrors PA si, oy fm pean © x slicing Horee of f femme eee race Mel amen EN Eee errevnleed—7 Newton Xwork ferrort Sten 7 1b, 2 \abele if sang @sencitive bo tai all guers say % Q: Rewrite a R-code for Simpson's rule by directly solving nc Peemeeet, | (21, 22,25) in R. R Code for Simpson's rule ‘Simps = function(f, a, bs m, TRUED{ fun on(x){x"3/3 - x°2 tf a MH 2 t= OL ats, 100, - ravern(-chocee an even integer 21") aco . resulti = sapply(n_set, Trapezoidal, f=func_y 1 x0 = min(a, xm = nax(a,b) FAl Bs Ga ~ 300/n (int_tunc_y(2) ~ int_fune_y(1)) result2 = sapply(n_set, Simps: 1]) + ae Ge eeqliva]) + £¢x_ve9{48)))) re TRUE) n gives", sntegral))? ncogral) (int_tunc_y(2) - int_fune_y(1)) 2) $value ~ Ai] BE ee : r ; ‘i \ Cm ais seneacde = (Lexar th eas) t £(Kusd) Appendix x value = 209(2, 50, by=1) R Gauss_quadrature = function(f, Code for 2-point Gauss quadrature rule b, m2, print = TRUED{ af @> 2 fone y = function(x, Leng) factorial (2)"é+(Leng”(2ex*1))/((2ex01) torial (24x)"3)) retura("How vo use n <= 2")} At Comet xt 0; wt = Sa ae cae Amtegral = ut + £((b-a)+x1/2 + (avb)/2) plot(x value, y.value, type = *p*, ab = “at, Antogral = integral + (b-a)/2} win” Pict(ctoriahia) ae (a)"Caene) aes Genet) + (factorial (oen))°3), : a = Berens aay , cortab = 2) Amtegal = wi + £((bra)ex1/2 + (atb)/2) + Siapeon rutectimey. 4, 2, 10009 90 (2) “Biapoon gives 3.s2szazs0000090" } Sonee qunaracurecrumey. 1. 2) i, Example (cont.) Riis SEGAL aeteeenant on semetes-aeppiy GG), Onan qunaratore, Sofone 7, Approximation error + Again cr te Tei math 00% Sava stiiy- f'n Saeed frame (a fo) ten Pe) =e pte et fr at egal oh Wy + ary cy et f(s) >), Tg me rina he. + em tna acetone) coree(a,0)) (2) ca 3/8 sstegral = 0 fort in 120 seg haga» > Se (print = TaD Print (pecte("Trapesoidal give, datepeal))) FoturaCistegral = Sstepral) > int_func_y = function(x){x"3/3 - x"2 + 4ex} + 140 + ( Da) n.set = seq(5, 100, by = 5) result1 = sapply(n_set, Trapezoidal, f-func_y, a= 1, b= 2, print = FALSE) - (Gnt_func_y(2) - int_tunc_y(1)) resulti

You might also like