Department of Mathematical Sciences Examination paper for TMA45 Matematikk 4N Academic contact during examination: Anne Kværnø a, Louis-Philippe Thibault b Phone: a 9 66 38 4, b 9 3 0 95 Examination date: May 3 08 Examination time (from to): 09:00 3:00 Permitted examination support material: Kode C: Bestemt, enkel kalkulator Rottmann: Matematisk formelsamling Other information: All answers have to be justified, and they should include enough details in order to see how they have been obtained. All sub-problems carry the same weight for grading. Good Luck! Language: English Number of pages: 9 Number of pages enclosed: Checked by: Informasjon om trykking av eksamensoppgave Originalen er: -sidig -sidig sort/hvit farger skal ha flervalgskjema Date Signature
TMA45 Matematikk 4N, May 3 08 Page of 9 Problem Let f(x) be defined as f(x) = x for x [0, 3]. a) Find the Fourier sine series of f(x). b) Use the result to compute the value of the series Hint: Use Parseval s identity. n. Solution: a) The Fourier sine series is of the form ( ) nπx b n sin, L where L = 3 is the half-range period, and b n = L We compute the coefficients b n : b n = 3 L 0 ( ) nπx f(x) sin dx. L 3 0 ( ) nπx x sin dx. 3 To compute this integral, we use integration by parts. We obtain b n = ( [ x 3 ( )] nπx 3 3 nπ cos + 3 3 ( ) ) nπx cos dx 3 0 nπ 0 3 = ( ) () n+ 9 + 0 = ()n+ 6. 3 nπ nπ Thus the Fourier sine series of f(x) is given by () n+ 6 nπ ( nπx sin 3 ). b) We use Parseval s identity: We have 36 π b n = L L 0 f(x) dx. n = 3 x dx = 6. 3 0
Page of 9 TMA45 Matematikk 4N, May 3 08 Thus n = π 6. Problem Let f(x) = 4 x + Show that the convolution and g(x) = (f g)(x) = π i x (x + ) for all real x. ωe ( +) ω e iωx dω. Solution: We first compute F(f g), the Fourier transform of the convolution. By the convolution theorem, we get Using the tables, we see that F(f g) = πf(f)f(g). F(f) = πe ω. We note that ( ) g(x) =. x + Using the properties of the tables, we obtain Thus, F(g) = iω π e ω. F(f g) = iπ πωe ( +) ω. Applying the inverse Fourier transform on both sides, we obtain (f g)(x) = πi ωe ( +) ω e iωx dω. Problem 3 Using Laplace transforms, solve the differential equation y + 3y 4t if 0 < t + y = 4 if t >, with initial conditions y(0) = 0 and y (0) = 0.
TMA45 Matematikk 4N, May 3 08 Page 3 of 9 Solution: We note that the differential equation can be written as y + 3y + y = 4t( u(t )) + 4u(t ) = 4t 4(t )u(t ). Applying the Laplace transform on both sides and isolating L(y), we obtain ( ) 4 L(y) = s (s + )(s + ) 4 e s. s (s + )(s + ) We write the rational fraction as partial sums: 4 s (s + )(s + ) = A s + B s + C s + + D s + and find A = 3, B =, C = 4 and D =. Applying the inverse Laplace transform, we obtain y(t) = ( 3 + t + 4e t e t ) ( 3 + (t ) + 4e (t) e (t) )u(t ). Problem 4 Consider the equation x = cos(x). a) Show that this equation has a unique solution in the interval (0, ). b) Compute iterations of Newton s method to approximate the solution, starting with x 0 = 0.5. Keep 5 digits in your answers. Solution: a) Apply the fixed point theorem on x = g(x) = cos(x). g (x) = sin(x) <. The function cos(x) is monotonically decreasing on the interval [0, ], thus g(x) (g(), g(0)) = (0.705, 0.5) (0, )
Page 4 of 9 TMA45 Matematikk 4N, May 3 08 so the two conditions of the fixed point theorem are fulfilled, and the fixed exist and is unique. b) Rewrite the equation to the form f(x) = x cos(x) = 0 and Newtons method becomes x k+ = x k x k cos(x k) + sin(x k) = x k sin(x k ) + cos(x k ). + sin(x k ) and the first iterations becomes x 0 = 0.50000, x = 0.45063, x =.4508. Problem 5 Given the differential equation y = xy, y() = 0.5. a) Compute the approximate solution y H y(.) by one step of the Heun method with step size h = 0.. b) Compute the approximate solution y E y(.) by one step of the Euler method with step size h = 0.. Use the result from point a) to find an estimate for the error y(.) y E. Given a user specified tolerance Tol = 0 3, will you accept y E accurate solution? as a sufficient Whether you accept the step or not, what should your next step size be? Use P = 0.8 as the pessimist factor in the step size selection algorithm. Hint: The Euler method is of order, the Heun method is of order. Solution: a) One step of Heuns method with h = 0. becomes y = y 0 + hx 0 y0 = 0.5 + 0. 0.5 = 0.55 y H = y 0 + h ( x0 y0 + x (y ) ) = 0.5 + 0.5 0. ( 0.5 +. 0.55 ) = 0.5766. b) One step of Eulers method: y E = y = 0.55.
TMA45 Matematikk 4N, May 3 08 Page 5 of 9 Error estimate: y(.) y E le = y H y E =.66 0 3. The step is not accepted, and will be repeated with the new stepsize h new = P ( ) Tol p+ 0 3 hold = 0.8 0. = 0.049. le.66 0 3 Here, p = is the order of the Euler method. Problem 6 a) For a given function f(t), give an expression for the polynomial of lowest possible degree interpolating the function in the nodes t 0 = /3 and t =. Use the result to find a quadrature rule Q[, ] = w 0 f(t 0 ) + w f(t ) as an approximation to the integral f(t)dt. Find the degree of precision of the quadrature rule. b) Transfer the quadrature rule Q[, ] to some arbitrary interval [a, b]. Use it to find an approximation of the integral x sin(πx/)dx. Solution: a) Using Lagrange interpolation, we get p (t) = f(t 0 ) t t + f(t ) t t 0 = 3 ( f(t0 )( t) + f(t )(t + t 0 t t t 0 4 3 )). The quadrature rule is found by integrating this polynomial: Q[, ] = p dt = 3 f(t 0) + f(t ). The quadrature Q has degree of precision d if Q[, ] = f(t)dt for all polynomials of degree d or less. That is, if this is true for all f = t l, l = 0,,..., d but not for l = d +.
Page 6 of 9 TMA45 Matematikk 4N, May 3 08 f = dt = Q[, ] = 3 + = f = t tdt = 0 Q[, ] = 3 ( ) + 3 = 0 f = t t dt = Q[, ] = 3 ( 3 ) + 3 = 3 f = t 3 t 3 dt = 0 Q[, ] = 3 ( ) 3 + 3 3 = 4 9 so the quadrature rule has degree of precision. (The rule will have at least degree of precision by construction, so to check for f = and f = t is superfluous. On the other hand, it is useful for checking that the previous result was correct.) b) Use the mapping x = b a t + b + a. Then b a f(x)dx = b a Using the nodes x i = b a t i + b + a f( b a t + b + a )dt. for i = 0,, we get that x 0 = a 3 + b 3, x = b and the quadrature formula becomes Q[a, b] = b a [ 3f 4 ( 3 a + b ) ] + f(b). 3 Applied to x sin(πx/)dx we get x 0 = 4/3 and x = and Q[, ] = [ ( ) 4 4 3 sin 3 ( π 4 ) ( ) ] π + sin 3 = 3 =.54700539. 3 (For comparision, the exact value of the integral is.9885070... ).
TMA45 Matematikk 4N, May 3 08 Page 7 of 9 Problem 7 Let u(x, t) be the deflection at time t and position x of a vibrating string of length 4. It satisfies the wave equation with initial conditions u t = u, 0 x 4, t 0, x u(x, 0) = 3 sin(πx) and u t (x, 0) = sin(4πx), 0 x 4, and boundary conditions u(0, t) = u(4, t) = 0, t 0. a) Find the solutions that are of the form u(x, t) = F (x)g(t) and satisfy the boundary conditions. b) Find the solution that satisfy the initial conditions. c) The aim is now to set up a numerical scheme for the equation. Use step sizes t and x in the t and x direction respectively with x = 4/M, where M is the number of intervals in the x direction. The gridpoints are then given by t n = n t, n = 0,,,... and x i = i x, i = 0,,..., M Let Ui n u(x i, t n ) be the numerical approximation in each gridpoint. Set up a finite difference scheme for the equation, based on central differences. The scheme will be explicit, in the sense that Ui n+ can be expressed in terms of the numerical solutions at time steps t n and t n for n. Use a central difference for u t (x, 0) and the idea of a false boundary to find a scheme for computing U i, i =,..., M. Let x = 0. and t = 0. and use your schemes to find U u(0., 0.). Solution: a) We plug u(x, t) = F (x)g(t) into the wave equation and obtain two ODEs F kf = 0 G kg = 0. We split into three cases k = 0, k > 0 and k < 0. The only non-trivial solution is for k = p < 0. The first equation then have solution F (x) = A cos px + B sin px.
Page 8 of 9 TMA45 Matematikk 4N, May 3 08 From the boundary conditions, we get F (0) = 0 and F (4) = 0, so A = 0 and sin 4p = 0, hence p = nπ 4, n =,,... We can set B =. We now solve the second equation with k = p = ( nπ 4 ). It has a solution of the form G n (t) = B n cos pt + B n sin pt. The solutions of the form F (x)g(t) are thus given by ( ( ) ( )) ( ) nπ nπ nπ u n (x, t) = B n cos 4 t + Bn sin 4 t sin 4 x b) To find a solution that satisfies the initial condition, we need to sum over those functions. We have ( ( ) ( )) ( ) nπ nπ nπ u(x, t) = B n cos 4 t + Bn sin 4 t sin 4 x. We thus have, using the initial condition, 3 sin(πx) = u(x, 0) = B n sin nπx 4. This is a Fourier sine series. Comparing the two Fourier series, we see that the coefficients B n are given by B 4 = 3, B n = 0, if n 4. To obtain the coefficients Bn, we take the derivative of the series with respect to t: ( ( ) ( )) ( ) nπ nπ u t (x, t) = B n 4 sin 4 t + Bn nπ nπ nπ 4 cos 4 t sin 4 x. Using the other initial condition: sin(4πx) = u t (x, 0) = nπ 4 Comparing again the two Fourier series, we have ( ) nπ Bn sin 4 x. B 6 = 4π, B n = 0, if n 6. Thus, the solution to the differential equation is u(x, t) = 3 cos(πt) sin(πx) + sin(4πt) sin(4πx). 4π
TMA45 Matematikk 4N, May 3 08 Page 9 of 9 c) The corresponding difference equations for the point (x i, t n ) using central differences becomes Ui n+ Ui n + Ui n = U i+ n Ui n + Ui n. t x Solve this with respect to Ui n+, set r = x/ t for simplicity (not required), and the algorithm becomes: For n =,,... : Ui n+ = r (Ui+ n + Ui) n + ( r )Ui n Ui n, i =,..., M, () U0 n+ = 0, UM n+ = 0. Extend the solution domain to t = t, and use a central difference formula to approximate the starting condition u t (x, 0) = sin(4πx). For n = 0 we have the following two equations: U i = r (Ui+ 0 + Ui) 0 + ( r )Ui 0 Ui, Ui Ui = sin(4πx i ) t Solve the last with respect to Ui and insert this into the first expressions gives the following expression for Ui : U i = r (U 0 i+ + U 0 i) + ( r )U 0 i + t sin(4πx i ), i =,..., M U 0 i = 3 sin(πx i ). () With x = t = 0. the pararmeter r = and thus r = 0. To find an approximation U u(0., 0.) we need in this particular case only to calculate U from () first, and then U from (). Use also the boundary condition U0 n = 0: So U = 3 (sin(0.π) + sin(0.3π)) + 0. sin(0.8π) =.735830, U = U U 0 = 3 ( (sin 0.3π) sin(0.π) ) + 0. sin(0.8π) = 0.808779. To compare, the exact solution is u(0., 0.) = 0.79449.
TMA45 Matematikk 4N, May 3 08 Page i of ii Fourier Transform f(x) = π ˆf(ω)e iωx dω ˆf(ω) = π f(x)e iωx dx f g(x) f (x) π ˆf(ω)ĝ(ω) iω ˆf(ω) e ax a e ω /4a e a x x + a f(x) = for x < a, 0 otherwise a π ω + a π e a ω a sin ωa π ω Laplace Transform f(t) F (s) = f (t) tf(t) 0 e st f(t) dt sf (s) f(0) F (s) e at f(t) F (s a) s cos(ωt) s + ω ω sin(ωt) s + ω t n n! s n+ e at s a f(t a)u(t a) e sa F (s) δ(t a) f g(t) e as F (s)g(s)
Page ii of ii TMA45 Matematikk 4N, May 3 08 Numerics Newton s method: x k+ = x k f(x k) f (x k ). Newton s method for system of equations: x k+ = x k JF ( x k ) F ( x k ), with JF = ( j f i ). Lagrange interpolation: p n (x) = n k=0 l k (x) l k (x k ) f k, with l k (x) = j k(x x j ). Interpolation error: ɛ n (x) = n k=0 (x x k ) f (n+) (t) (n+)!. Chebyshev points: x k = cos ( k+ n+ π), 0 k n. Newton s divided difference: f(x) f 0 + (x x 0 )f[x 0, x ]+ (x x 0 )(x x )f[x 0, x, x ]+ +(x x 0 )(x x ) (x x n )f[x 0,..., x n ], with f[x 0,..., x k ] = f[x,...x k ] f[x 0,...,x k ] x k x 0. Trapezoid rule: b a f(x) dx h [ f(a) + f + f + + f n + f(b)]. Error of the trapezoid rule: ɛ b a h max x [a,b] f (x). Simpson rule: b a f(x) dx h 3 [f 0 + 4f + f + 4f 3 + + f n + 4f n + f n ]. Error of the Simpson rule: ɛ b a 80 h4 max x [a,b] f (4) (x). Gauss Seidel iteration: x (m+) = b Lx (m+) Ux (m), with A = I+L+U. Jacobi iteration: x (m+) = b + (I A)x (m). Euler method: y n+ = y n + hf(x n, y n ). Improved Euler (Heun s) method: y n+ = y n + h[f(x n, y n ) + f(x n + h, y n+)], where y n+ = y n + hf(x n, y n ). Classical Runge Kutta method: k = hf(x n, y n ), k = hf(x n + h/, y n + k /), k 3 = hf(x n + h/, y n + k /), k 4 = hf(x n + h, y n + k 3 ), y n+ = y n + 6 k + 3 k + 3 k 3 + 6 k 4. Backward Euler method: y n+ = y n + hf(x n+, y n+ ). Finite differences: u u(x+h,y) u(x h,y) (x, y), u(x, y) u(x+h,y) u(x,y)+u(x h,y). x h x h Crank Nicolson method for the heat equation: r = k h, ( + r)u i,j+ r(u i+,j+ + u i,j+ ) = ( r)u ij + r(u i+,j + u i,j ).