advertisement

Course 161/2S3, Tutorial, Hilary Term, 2006 • Use Simpson’s rule to evaluate Z 5 5x5 dx − with n = 4. Solution n = 4 ⇒ h = (1 − 0)/4 = 0.25. h (f (a) + 4f (a + h) + 2f (a + 2h) + 4f (a + 3h) + f (b)) 3 0.25 5 ∗ 05 + 4 ∗ 5 ∗ 0.255 + 2 ∗ 5 ∗ 0.55 + 4 ∗ 5 ∗ 0.755 + 5 ∗ 15 = 3 = 0.83984375 S = The analytic result is 5/6. What value of n is needed to solve this problem to an accuracy of 10−12 (approx machine precision). (b − a)5 1 max(f 0000 )x=0,1 < 10−12 180 N 4 1 1 53024 < 10−12 180 N 4 N 4 > 55.05 N = 56 will give the answer with error < 10−12. 1 • Given the first-order differential equation dy = −y(x) dx and initial condition y(0) = 1. Determine y(x), x = 2 for a step size h = 0.5 using the Euler method. yn+1 = yn + hf (x, y) = yn + h(−y(x)) For y0 = 1, h = 0.5 y1 y2 y3 y4 = = = = 0.5 0.25 0.125 0.0625 At x = 2 we have y = 0.0625 Note the analytic solution to this equation is y(x) = e−x . See how your answer compares to the analytic solution. At x = 3, e−3 = 0.1353. 2