Istitutt for matematiske fag Eksamesoppgave i TMA432 Itroduksjo til viteskapelige beregiger Faglig kotakt uder eksame: Ato Evgrafov Tlf: 453 163 Eksamesdato: 6. jui 216 Eksamestid (fra til): 9: 13: Hjelpemiddelkode/Tillatte hjelpemidler: B: Spesifiserte trykte og hådskreve hjelpemidler tillatt: K. Rottma: Matematisk formelsamlig Bestemt, ekel kalkulator tillatt. Målform/språk: bokmål Atall sider: 7 Atall sider vedlegg: Kotrollert av: Dato Sig Merk! Studeter fier sesur i Studetweb. Har du spørsmål om di sesur må du kotakte istituttet ditt. Eksameskotoret vil ikke kue svare på slike spørsmål.
TMA32 Itroduksjo til viteskapelige beregiger 6. jui 216 Side 1 av 7 Oppgave 1 Vi ser på likige hvor y > er gitt, og x R er ukjet. e x y =, a) Formuler Newtos metode for å løse dee likige. Gjør to iterasjoer for håd for y = e. Start med x =. Solutio: direct computatio. The Newto s iteratio for the equatio f(x) = is x k+1 = x k f(x k )/f (x k ), which i our case simplifies to x k+1 = x k (e x k y)/e x k = x k 1 + ye x k. Thus x =, x 1 1.71828182845945, x 2 1.2587112717836 Oppgave 2 a) Fi det polyomet p(x) av lavest mulig grad som iterpolerer fuksjoe f(x) = x i puktee x 1 =, x 2 = 4, x 3 = 9. Solutio: direct computatio. For example usig Lagrage s form of the iterpolatio polyomial we get (x 4)(x 9) L 1 (x) = ( 4)( 9) = x2 13x + 36 36 (x )(x 9) L 2 (x) = (4 )(4 9) = 9x x2 2 (x )(x 4) L 3 (x) = (9 )(9 4) = x2 4x 45 P (x) = L 1 (x) + 4L 2 (x) + 9L 3 (x) = x2 9x 1 = 3x2 + 27x + 2x 2 8x 3 = x2 + 19x 3 + x2 4x 15
Side 2 av 7 TMA32 Itroduksjo til viteskapelige beregiger 6. jui 216 4 f(x) = x p(x) = ( x 2 + 19x)/3 y 2 2 4 6 8 1 x Vi bruker samme otasjo for f(x) og p(x) som i a) i reste av oppgave. b) Fuksjoe F (x) = x er lik med (f(x)) 2 for x. Derfor iterpolerer P (x) = (p(x)) 2 fuksjoe F (x) i puktee x 1 =, x 2 = 4 og x 3 = 9. Forklar hvorfor formele for estimatet av iterpolasjosfeile, gitt av F (x) P (x) = (x x 1)(x x 2 )(x x 3 ) F (c), 3! med c [mi{x, x 1 }, max{x, x 3 }], ikke holder i dee situasjoe. Solutio: The short aswer here is that the error estimate is valid oly for the iterpolatio polyomials of miimal degree, whereas P (x) = (p(x)) 2 is ot a iterpolatio polyomial of miimal degree. (Ideed, it has degree 4, whereas for 3 iterpolatio odes we should have degree 2 or less. I fact i the preset situatio the iterpolatio polyomial is F (x) = x, ad thus has degree 1.) Oe could see that the error estimate predicts that the iterpolatio error should be zero (as F (x) = (x) = ) ad it is for the iterpolatio polyomial of miimal degree, that is x, but clearly ot for our iterpolatio polyomial P (x). Why is the error estimate F (x) P (x) = (x x 1)(x x 2 )... (x x ) F () (c),! oly valid for polyomials of miimal degree? Suppose we remove the miimal degree requiremet. The we have iterpolatio poits ad we look at
TMA32 Itroduksjo til viteskapelige beregiger 6. jui 216 Side 3 av 7 iterpolatig polyomials P of degree at least. With polyomials of this degree we ca iterpolate through + 1 poits. Thus we ca chose + 1-st iterpolatio ode x +1 arbitrarily ad place the correspodig y = P (x +1 )- value as far from F (x +1 ) as we like. The the left had side of the estimate, F (x +1 ) P (x +1 ) ca be made arbitrarily large, whereas the right had side of the estimate is determied by the positio of the odes x 1,..., x, x +1 ad the -th derivative of F. 1 8 6 F (x) = x P (x) = ( x 2 + 19x) 2 /3 2 y 4 2 2 4 6 8 1 x Oppgave 3 a) Approksimer itegralet 1 l(x) dx ved å bruke midtpuktskvadraturer med = 1 og = 2 delitervaller. 1 Solutio: Direct computatio. With 1 pael we have: 1 l(x) dx 1 l(.5).693147185599453 With 2 paels we have: 1 l(x) dx.5[l(.25) + l(.75)].8369882167858358. b) Hvis vi atar at f er kotiuerlig på itervallet [a, b], er feilestimatet for midtpuktskvadraturet Q [a,b] f gitt av b 1 delitervaller = paels i boke a f(x) dx = Q [a,b] f + h3 24 f (c),
Side 4 av 7 TMA32 Itroduksjo til viteskapelige beregiger 6. jui 216 der c er et pukt mellom a og b, og h = b a. Bruk å adaptive kvadraturer til å estimere forskjelle 1 l(x) dx Q [,1] l. (Igorer det at l på itervallet [, 1] ikke oppfyller deriverbarhetskravet i feilestimatet.) Du ka gjebruke de umeriske beregigee fra a). Solutio: We have: = Q [,1] l (Q [,.5] l +Q [.5,1] l) + 13 24 l (c 1 ).53 24 l (c 2 ).53 24 l (c 3 ). We assume that l (c 1 ) l (c 2 ) l (c 3 ) (this is the stadard assumptio i adaptive quadratures) ad thus get.75 24 l (c 1 ) = (Q [,.5] l +Q [.5,1] l) Q [,1] l.8369882167858358 (.693147185599453).14384136225895. Thus the error estimate is 1 l(x) dx Q [,1] l = 1 24 l (c 1 ) 4/3 (.14384136225895) Oppgave 4.191788483118734. 2 Vi skal å se på et iitialverdiproblem: y (t) = (y(t)) 2, y() = 1. Løsige av differesiallikige er y(t) = (t + 1) 1. a) Reg ut to steg av y umerisk ved hjelp av de eksplisitte Eulermetode. Bruk steglegde h = 1. Solutio: Direct computatio. Explicit Eulers method for this IVP is w = y() = 1. Thus we get: 2 Note that the exact error is 1 w i+1 = w i hw 2 i = w i (1 hw i ), w 1 = w (1 hw ) = 1(1 1 1) =, w 2 = w 1 (1 hw 1 ) =. l(x) dx Q [,1] l 1 (.693147185599453).3685281944547.
TMA32 Itroduksjo til viteskapelige beregiger 6. jui 216 Side 5 av 7 b) Formuler de implisitte Eulermetode (med tilfeldig h i = t i+1 t i > ) for problemet. Vis at adregradslikige som framkommer i metode har to reelle røtter for approksimasjoe w i+1 y(t i+1 ) gitt av w i y(t i ) og h i, gitt at h i er lite ok. Fi de eksplisitte utrykkee for røttee og forklar hvilke av dem som bør velges i metode. Solutio: Implicit Eulers method for this IVP is w i+1 = w i h i w 2 i+1. w = y() = 1. Thus at every iteratio we eed to sovle the quadratic equatio h i wi+1 2 + w i+1 w i =. We solve this equatio: D = 1 + 4h i w i, w ± i+1 = 1 ± 1 + 4h i w i 2h i. I particular, if w i, or if w i < ad h i < 1/(4w i ) the D > ad the quadratic equatio has two real roots. Which root should we choose? There are several ways i which oe could argue here. For example, for small h we ca use a first order Taylor series expasio 1 + 4h i w i 1+2h i w i, ad therefore w i+1 ± 1/(2h i )±(1/(2h i )+w i ). Sice we expect that for small h we have w i+1 w i, we should select w i+1 w i+1 + based o this iformatio. Aother way of makig this decisio is to require that w i+1 behaves as much as the solutio y(t); for example, that it is positive. Ideed we kow that w >, ad if w i > the 1 + 4h i w i > 1 ad as a result w i+1 < < w + i+1. Therefore we should choose w + i+1. Oppgave 5 a) Bereg de diskrete Fouriertrasformasjoe av x = [1, 2, 3] T. Solutio: direct computatio. y = 1 3 1 x j exp{ i2πj/3} = 6 3.4641 3 3 j=
Side 6 av 7 TMA32 Itroduksjo til viteskapelige beregiger 6. jui 216 y 1 = 1 3 1 x j exp{ i2πj1/3} = 1 [1 exp{} + 2 exp{ i2π/3} + 3 exp{ i4π/3}] 3 3 j= = 1 3 [1 + 2{ 1/2 i 3/2} + 3{ 1/2 + i 3/2}] = 1 3 [ 3/2 + i 3/2] = 3/2 + i/2. Because x R 3 we have y 3 = ȳ 2 = 3/2 i/2. b) La y = [y, y 1,..., y 1 ] T C være de diskrete Fouriertrasformasjoe av vektore x = [x, x 1,..., x 1 ] T C. Nå kostruerer vi vektore ˆx = [x, x 1, x 2,..., x 1 ] T. Vis at de har e diskret Fouriertrasformasjo gitt som ŷ = [y, y 1, y 2,..., y 1 ] T. Solutio: Per defiitio of DFT: ad ŷ k = 1 1 j= ˆx j exp{ i2πjk/} = 1 ] [ˆx + ˆx 1 exp{ i2π1k/} + + ˆx 1 exp{ i2π( 1)k/} = 1 ] [x + x 1 exp{ i2π1k/} + + x 1 exp{ i2π( 1)k/} = 1 ] [x + x 1 exp{ i2π( 1)k/} + + x 1 exp{ i2π1k/}, y k = 1 1 x j exp{ i2πj( k)/} j= = 1 ] [x + x 1 exp{ i2π1( k)/} + + x 1 exp{ i2π( 1)( k)/}. Direct compariso shows that ŷ = y (the all exp{ } = exp{} = 1). To coclude the proof we eed to show that the coefficiets i frot of x j i two formulas agree. Ideed, the coefficiet i frot of x j i the formula for ŷ k is exp{ i2π( j)k/} = exp{ i2πk} exp{i2πjk/} = exp{i2πjk/}, }{{} =1
TMA32 Itroduksjo til viteskapelige beregiger 6. jui 216 Side 7 av 7 ad similarly, the coefficiet i frot of x j i the formula for y k is: exp{ i2πj( k)/} = exp{ i2πj} exp{i2πjk/} = exp{i2πjk/}, }{{} =1 where we used the face that exp{ i2πj} = exp{ i2πk} = 1 for all itegers j, k. Thus the proof is cocluded. c) La = 2 p, p N, og t j = c + j(d c)/, j =,..., 1 være e samlig av uiformt distribuerte pukter på itervallet [c, d]. Vi vil fie e kurve som passerer gjeom(iterpolerer) puktee i datasettet (t, x ),..., (t 1, x 1 ). I dette kurset har vi sett på to mulige metoder for å gjøre dette: polyomiterpolasjo, (her vist i Newtos form) P (t) = f[t ] + f[t, t 1 ](t t ) + + f[t,..., t 1 ](t t ) (t t 2 ), og trigoometrisk iterpolasjo: Q(t j ) = 1 1 y k exp{i2πkj/} = k= 1 k= { } i2πk(tj c) y k exp /. d c Gi et overslag på atallet av elemetære operasjoer 3 som tregs til å berege: alle Newtos differaser 4 f[t ], f[t, t 1 ],..., f[t,..., t 1 ]; alle trigoometriske iterpolasjoskoeffisietee y,..., y 1 ved hjælp av FFT algoritme. Sammelig to vurderigee og bestem, hva er raskest for store. Solutio: The coefficiets y,..., y 1 are efficietly computed usig FFT, which requires O( log ) operatios. Computig each Newto s divided differece requires oe divisio ad two subtractios. There are 1 divided differeces f[t, t 1 ],..., f[t 2, t 1 ]; 2 divided differeces f[t, t 1, t 2 ],..., f[t 3, t 2, t 1 ],..., ad fially 1 differece f[t, t 1,..., t 1 ]. Therefore, computig all Newto s divided differeces requires ( 1) + ( 2) + + 1 = O( 2 ) subtractios ad divisios. For large we have > log ad therefore computig the trigoometric expasio coefficiets is faster. 3 Elemetære operasjoer addisjo, subtraksjo, multiplikasjo, divisjo 4 Newto s divided differeces