chapter5.page09

# chapter5.page09 - 3 = hf t i-1 1 2 h,x i-1 1 2 k 2 Set k 4...

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

3. RUNGE-KUTTA METHOD 9 x 4 : k 1 = hf ( t 3 ,x 3 ) = 0 . 25 * f (0 . 75 , 0 . 568891) = - 0 . 641483 k 2 = hf ( t 3 + 1 2 h,x 3 + 1 2 k 1 ) = f (0 . 875 , 0 . 568891 + 0 . 5( - 0 . 641483)) = - 0 . 485628 k 3 = hf ( t 3 + 1 2 h,x 3 + 1 2 k 2 ) = 0 . 25 f (0 . 875 , 0 . 568891 + 0 . 5( - 0 . 485628)) = - 0 . 510243 k 4 = hf ( t 3 + h,x 3 + k 3 ) = 0 . 25 f (1 , 0 . 568891 - 0 . 510243) = - 0 . 308297 x 4 = x 3 + 1 6 ( k 1 + 2 k 2 + 2 k 3 + k 4 ) = 0 . 568891 + 1 6 ( - 0 . 641483 + 2 * ( - 0 . 485628) + 2 * ( - 0 . 510243) - 0 . 308297) = 0 . 446327 t 4 = t 3 + h = 0 . 75 + 0 . 25 = 1 . 0 So the approximation to x (1) is x (1) x 4 = 0 . 446327 . a 3.2. Mathcad implementation. First, we have the following sim- ple algorithm for the Euler’s method, Input f , a , b , x 0 n. Output: the approximate solution to x 0 = f ( t,x ) with initial guess x 0 over interval [a, b]. Step One: Initialization Set h = b - a n Set x 0 = x 0 Set t 0 = a Step Two: For i=1 to n do Step Three Step Three: Set k 1 = hf ( t i - 1 ,x i - 1 ) Set k 2 = hf ( t i - 1 + 1 2 h,x i - 1 + 1 2 k 1 ) Set k
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 3 = hf ( t i-1 + 1 2 h,x i-1 + 1 2 k 2 ) Set k 4 = hf ( t i-1 + h,x i-1 + k 3 ) Set x i = x i + 1 6 ( k 1 + 2 k 2 + 2 k 3 + k 4 ) Set t i = t i-1 + h • Step Four return x. This algorithm returns an array of values, the ith element of the return array is an approximations of x ( t ) at t = a + ih. The following screen shot shows Mathcad code for implementing the algorithm. Again notice the line to line corresponding between the Mathcad and the algorithm....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online