MIDTERM 2 Problem 1 Consider (again) the following equation x00 + 4x = 0 (1) with x(0) = 0, x0 (0) = 1. This equation describes the motion of an undamped 2 springmass system. The system possesses energy conservation property, i.e., the sum of kinetic (0.5x0 (t)2 ) and potential (2x2 ) energies are constant 1 1 E(t) = x(t)02 + 2x(t)2 = x(0)02 + 2x(0)2 . 2 2 (2) (2) can be obtained multiplying (1) by x0 (t) and integrating the resulting equation. In the following problem we would like to see how various numerical methods conserve the energy. Write (1) in the following form: x0 = y y 0 = f (x, y) (3) where f (x, y) = −4x, x(0) = 0, y(0) = x0 (0) = 1. a) Find an exact solution of (3) b) Write a program for solving (3) using backward Euler. c) Write a program for solving (3) using the following “conservative” method yn+1 = yn + f (xn , yn ) ∗ h xn+1 = xn + yn+1 ∗ h (4) d) Write a program for solving (3) using the following “conservative” method yn+1 s = yn + 0.5hf (xn , yn ) xn+1 = xn + hs = s + 0.5hf (xn+1 , yn+1 ) (5) Note that this method is explicit, because f is only function of x. Do the followings: 1) Plot and compare E(t) for a), b), c), d) using dt(= h) = 0.1, N = 5000. Here N is the number of time steps. 3) To understand why E(t) in the cases c) and d) does not drift away from E = const write the discrete equation in the form: (xn+1 , yn+1 )T = A(xn , yn )T , where A is 2 × 2 matrix. Compute the determinant of A in each case b),c) and d). The determinant can be understood as the area change in the phase space (x, y). If the determinant is 1 the method preserves the area (it is called a symplectic method). Report the values of the determinant and how the energy behaves for the cases det(A) = 1. 1 Problem 2 1) Derive second order Adams Bashforth formula 1 3 xi+1 = xi + h( fi − fi−1 ). 2 2 2) Derive the above formula using Taylor expansion (Hint: use xi+1 = xi + hfi + 0 O(h3 ) and approximate fi using Taylor expansion. 3) Find the region of absolute stability. h2 0 f 2 i + Problem 3 Derive third order Adams-Moulton formula xn+1 = xn + h [Afn+1 + Bfn + Cfn−1 ] 24 and find the region of absolute stability. Problem 4 Are the following multistep methods convergent? If so find the global truncation error. a) xn − xn−2 = 2hfn−1 b) xn − xn−2 = h( 73 fn−1 − 23 fn−2 + 31 fn−3 ) c) xn − xn−2 = h(fn − 3fn−1 + 2fn−2 . d) xn − xn−1 − xn−2 = h(fn − fn−1 ) 2