{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# chw4 - solution Is it possible to get higher accuracy by...

This preview shows page 1. Sign up to view the full content.

Math 128a, fall 2011, Chorin, computer homework 4 (This computer homework focuses on things that do NOT work. Why they do not work has not yet been discussed. I want you to see that things do not work unless one does the right thing). 1. Write a computer program that solves the equation y 0 = f ( x,y ) ,y (0) = a , ( a is a given number), by the centered scheme u 0 = a,u 1 = u 0 + hf (0 ,u 0 ) , and for i > 1, u i +1 = u i - 1 + 2 hf ( x i ,u i ), where h is the mesh size and x i = ih . Use it to solve the equations y 0 = - 2 y,y 0 = 2 y , in both cases with the condition y (0) = 1. Follow the solution up to x = 2, with h = 0 . 1 and h = 0 . 5. In each of the 4 cases, plot the error (numerical solution minus exact solution) and the relative error (error divided by the exact
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: solution). Is it possible to get higher accuracy by extrapolation? 2. Check that y = ( y i +1 + (3 / 2) y i-3 y i-1 + (1 / 2) y i-2 ) / (3 h ) + O ( h 3 ) , where y i = y ( x i ). Write a program that implements the resulting scheme for solving y = f ( x,y ) ,y (0) = 1: u = 1 ,u 1 = u + hf (0 , 1) ,u 2 = u + 2 hf ( h,u 1 ) , and for i > 2, u i +1 =-(3 / 2) u i +3 u i-1-(1 / 2) u i-2 +3 f ( x i ,u i ). Use it to solve y =-y,y (0) = 1, for 0 < x ≤ 2, with h = . 1 ,h = . 2. Comment on what you observe. 1...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online