Question: Example 3.36. Consider the IVP (3.88) y' =y y(0) =1 We know that the exact solution is y(x) = e. Let us run Euler's method,


![Euler's method, say on the interval [0, 1]: (3.89) Un+1 = Un](https://s3.amazonaws.com/si.experts.images/answers/2024/06/6667de64a6fce_1726667de649691f.jpg)


















![1] and plot the approximate solutions for h = 1/10, h =](https://s3.amazonaws.com/si.experts.images/answers/2024/06/6667de6b0d941_1786667de6adf143.jpg)


Example 3.36. Consider the IVP (3.88) y' =y y(0) =1 We know that the exact solution is y(x) = e". Let us run Euler's method, say on the interval [0, 1]: (3.89) Un+1 = Un + hF(In, y(x.)) (3.90) Un+1 = yn + hyn (3.91) = (1 + h)yn. Iterating this relation we obtain Un = (1 + h)yn-1 = (1+ h) yn-2= ... = (1+ h)"yo- Since yo = 1, we conclude (3.92) Un = (1 + h)" (n =1, 2, ...) This simple example allows us to express the approximation error in the nth step explicitly: (3.93) En = lyn - y(In)| = (1+h)" _ ehnj (Recall we want that the global approximation error max,=0....,N |Un - y(T,)| converges to zero.) In particular, if we recall that h = N, (3.94) EN = 1(1 + N-1 )N - el The statement of Theorem 3.34 thus in particular shows that the global approximation error does converge to zero, in particular ex - 0, so we have recovered the familiar formula (3.95) lim (1 + ) =e N-+00 as a special case of the convergence of Euler's method. Remark 3.37 (*). If you haven't done it before, it is a good exercise to show by explicit calculation using the binomial theorem that (1 + )~converges to e = = Exercise 3.38. Consider the IVP (3.96) y's 2y + 1 y(0) = 1 The exact solution is y(@) = ;ex - (i) Implement Euler's method for this IVP on the interval [0, 1] and plot the approximate solutions for h = 1/10, h = 1/20, h = 1/50, h = 1/100; also plot the exact solution for comparison. (ii) Plot the approximation error EN = lyn - y(IN)| against h as h tends to 0. (iii*) Calculate yN explicitly and show that EN - 0 as N + co(without using a generalLet us introduce some abbreviations for the rest of this computation: (3.139) T= In, y = y(on), y' = y'(a.), y" = y"(x.), F = F(In, Un) (whenever we use arguments evaluated at ~ = 2,, then arguments are omitted from nota- tion) Then substituting the definition of d, (3.140) Th = y'+ thy"-bF - byF(x + ch,y + ahF) + 0(h?) To analyze this further we notice that by the ODE, (3.141) y =F and by the chain rule, (3.142) y" = OF + y'd,F = OF + Fa, F. For a smooth function F of two variables we have by the two-dimensional Taylor formula: (3.143) F(x + Ax, y + Ay) = F(x, y) + AxOF(x, y) + Ayay F(x, y) + O(h2), whenever [Ax| + |Ay) 0. (iv*) Make your implementation from (i) more general so that solves a general IVP y' = F(x, y), y(ro) = yo on an interval [To, To + a] (i.e. you should write a function/method whose inputs are the function F, and values co, yo, a, as well as the parameter N for the number of steps). The output should be the list of computed approximations yn. You can also write routines for plotting and testing against a given exact solution. Test it on various examples of IVPs seen in class. Hint 1: In implementations, it is more practical to make N the independent parameter rather than h. One can then use h = Hint 2: You can use Python 3 with numpy for vectorization and matplotlib for plotting. (Alternatively, Matlab or Octave.) Solution to (iii*). Euler's method reads (3.97) Un+1 = Un + h(2yn + 1) = (1 +2h)yn + h. This is a linear recurrence relation and we want to solve for y,. There is a systematic way of doing this. Note that if the term +h would not be there, then y. would be (1 + 24)". This motivates the substitution (3.98) an = Un(1+ 2h)-". The recurrence becomes (3.99) Entl = anth(1+2h)-(+1) Subtract 2, and sum over n = 0, . . ., N - 1: N-1 N-1 (3.100) [( anti - an) = [h(1 + 2h) -(n+1) 71=0 n=0 On the left we have a telescoping sum, where only the last and the first terms survive: N-1 (3.101) 2N - 20 = h(1+ 2h )-(r+1) n=0 Substitute back and simplify (recall 20 = yo = 1): N-1 (3.102) UN = (1+2h) +h > (1+ 2h ) N-n-1 71=0 Reindexing by replacing n with (N - 1) - n we get N-1 (3.103) yN = (1+24) ~ +h > (1+2h)" 1=0Summing the geometric sum, (3.104} \"in +2h)\" = W. Plugging this back in, we get chFinal answer (3.105} ya; = {1 + 211)\" + till + 2h)\" _ 1) = go + H" . Recalling that lim,-.'r_,m[1 + %}'V = ei, we have (3.106} Ems. = as = you. III Euler's method is rarely used in practice, because much more accurate methods are available. We will look in more detail at two classes of such methods: onestep methods and linear multistep methods. Euler's method is a special case of both. 3.4. One-step methods. Recall that we are trying to solve IVPs of the form if = Fix, 1;), 3.10? l l { Bil-T0] = so- with F smooth. We assume that a unique solution 3; = y{:r]l exists on an interval [3.1], xnIe] .6 Denition 3.39. A general onestep method takes the form {3-108} yn+l : yrs + h(D{-Inayn1 h]! where n = U,...,N, at,, = rn+nh and h 2: U, N = (ll. The map (D denes what happens from one step to the next. In principle, (D could be any function, but the method is only useful if it actually gives an approximate solution to the IVP [3.1'07}. Thus, 'I! should involve the function F. For simplicity, we'll always assume that ii is smooth in all variables. Intuitiv'ely, if y = y[::r:} is assumed to be the exact solution, then @[13 y, h) represents an estimator for the value of the derivative of the solution y across the interval [3,513 + h]. Example 3.40 (Euler's method]. If @[I,y,h) = F{;r,y], then we recover Euler's method. FI[:.r._y]I is the value of the derivative of y at the left endpoint of the interval [33,1 + h] this may be an underestimate, or overestimate, depending on whether the derivative will increase or decrease (Le. depending on the second derivative of y]. Example 3.41 {Heun's method}. The one-step method given by (3-109) so. y. m = am, y) + Fir + h. y + we. ym is called Heart's method. Here the idea is to take an average of derivatives at the left- and right endpoints of the interval [33,1' + h]. At the left endpoint, we use F[3,y} (which (*] \"'0 also make a silent technical assumption: we x a compact set K containing the solution curve (2', M23\". Constants throughout may depend on K. equals y'{s'j if y is exact} and at the right endpoint we use F[:t: + lay + hF{.c,y)) as an approximation of 3411? + h] {using one step of Euler's method to estimate the value of y(:e + h) ). Emmpie 3.42 {Midpoint method). The onestep method given by {3.110} on, y, 3:} = Fe. + is. y + %hF(s, y}} is called midpoint method. 'We can interpret this as an estimate of the value of (3.111} y'[:c+h,t2}=F{I+h,'2.y{.r+h,f2}}, which is the derivative of y at the midpoint of the interval [1,1 4 11]. One step of Euler's method is used to estimate the value of y(;:: | iii/2). As we will see, Heun's method and the midpoint method are both more accurate than Euler's method. In order to analyze one-step methods, it is again helpful to consider the error made by the method in onestep assuming the solution was exact up to that point. Like in our analysis of Euler's method (see Theorem 3.34 above), this leads to the denition of the truncation error 313 1 _ In. (3112} Tn = W _ @(xn,y[xn},h}, which again can be viewed as i "v N times the error made in the {n + ljth step, assuming the solution was exact up to the nth step. Remark 3.43. Some authors prefer to dene the (local) truncation error Without the fac L tor h' Denition 3.44. we say that a one-step method given by (D is consistent if the maximal truncation error max,l |Tn| converges to zero as h } D. A bit of calculus shows that it is not diH'icult to determine when a onestep method is consistent. Fact 3.45 (Consistencyr criterion}. A onestep method given by i is consistent if and onty tf@[3,y.j = F[:t:._ y} on sotntion curves {any} = [I,y[1'}}. Why is this true? This is because as h. } I]. (3.113} w @(I,y(1'),hj converges to (3.114} in) animal (since
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
