Homework 8 Problem 1 1) The function f (x) has been measured at the points x = h, 2h, 3h. Find a formula for R 4h 1 f (x)dx) as a linear combinations of the measured the mean value of f (x) over [0, 4h] ( 4h 0 values such that the approximation is exact for all polynomials of degree 2 (i.e. find A, B, C that Z 4h 1 1 f (x)dx ≈ (Af (h) + Bf (2h) + Cf (3h)) 4h 0 4 is exact for all polynomials of degree at most 2.) 2) How can you use this approximation to find the solution of x0 (t) = f (x, t) at the time instant t = 4h if x(0), x(h), x(2h), x(3h) are known? Use your formula to find x(4h) if x(0) = 0, x(h) = h, x(2h) = 4h2 , x(3h) = 9h2 and f (x, t) = 2x/t. Note that the value of x(4h) you have found should coincide with the value of the solution 0 x (t) = f (x, t) = 2x/t (with previously specified initial conditions) at x = 4h. Problem 2 Find a formula of the form Z 2π f (x)dx = A1 f (0) + A2 f (π) 0 that is exact for any function of the form f (x) = a + b cos(x). Show that the resulting formula is exact for any function of the form f (x) = n X (ak cos(2k + 1)x + bk sin(kx)) k=0 Problem 3 R b R d(x) Write a program for the calculation of a c(x) f (x, y)dydx using Simpson’s rule. 1) R1R1 i) Test the convergence rate for 0 0 x3 y 4 dydx by choosing (n, m) = (9, 9) and (n, m) = (17, 17), where n and m are the number of points in each direction (including end points). ii) How does the method converge if you increase the number of points only in one direction, for example, (n, m) = (9, 9) and (n, m) = (9, 17) R 1 R 2x 2) Calculate 0 x x3 y 4 dydx Problem 4 R3 Calculate 0 x2 dx using standard Monte-Carlo quadrature with N = 2000, 4000 and report the errors by comparing MC value of the integral with the exact value of the integral. 1