Solution Oblig 2

# Solution Oblig 2 - Spring 2009 MAT260 â€“ 2 Suggested...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Spring 2009 MAT260 â€“ BEREGNINGSALGORITMER 2 Suggested solution Obligatory Exercise 2 Problem 1 Given x â€² ( t ) = x (1- x ) â‰¡ f ( t, x ) , Put x = 0 . 5. Step 1 is an Euler step, while step 2 , 3 , and 4 are Leap-frog a) steps. Use h = 1 / 2 in all steps. The Leap-frog method x n = x n âˆ’ 2 + 2 hf n âˆ’ 1 , n = 2 , 3 , . . ., giving x 1 = x + h Ã— f = 0 . 625 x 2 = x + 2 h Ã— f 1 = 0 . 734375 x 3 = x 1 + 2 h Ã— f 2 = 0 . 820068359375 x 4 = x 2 + 2 h Ã— f 3 = 0 . 881931245326996 The approximation with stepsize h in 2 is x h (2) â‰ˆ . 88193 . Using eight b) steps gives x h/ 2 (2) â‰ˆ . 88110. The method is second order implying that x h (2)- exact â‰ˆ C Ã— h 2 and x h/ 2 (2)- exact â‰ˆ C Ã— ( h/ 2) 2 . Taking the diffe- rence we get x h (2)- x h/ 2 (2) â‰ˆ 3 C Ã— ( h/ 2) 2 implying that the error in the best approximation is C Ã— ( h/ 2) 2 â‰ˆ ( x h (2)- x h/ 2 (2)) / 3 â‰ˆ . 00083 / 3 â‰ˆ 3 Ã— 10 âˆ’ 4 which turns out to be a quite good estimate of this error. The analysis is based on the assumption that h is small enough such that the second order approximation is valid. 1 Solution Problem 1c): function [t,x]=Leap_frog(f,ts,te,xs,N) %define the step-length h=(te-ts)/N; x(1)=xs; t=linspace(ts,te,N+1); %Evaluate f(t,x) fs=feval(f,ts,xs); %Take an Euler-step x(2)=xs+h*fs; %Then N-1 Leap-Frog steps for i=2:N ft=feval(f,t(i),x(i)); x(i+1)=x(i-1)+2*h*ft; end The method d) x n- (1 + Î¼ ) x n âˆ’ 1 + Î¼x n âˆ’ 2 = h ( 3- Î¼ 2 f n âˆ’ 1- 1 + Î¼ 2 f n âˆ’ 2 ) , n = 2 , 3 , . . . . is explicit and twostep. Two polynomials are associated with this method: p ( z ) = z 2- (1 + Î¼ ) z + Î¼ and q ( z ) = 3 âˆ’ Î¼ 2 z- 1+ Î¼ 2 . Consistency implies that p (1) = 0 which is obviously satisfied. Furthermore we need to have(1) = 0 which is obviously satisfied....
View Full Document

{[ snackBarMessage ]}

### Page1 / 5

Solution Oblig 2 - Spring 2009 MAT260 â€“ 2 Suggested...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online