# 2021W-NA-Midterm-Solution-Highlights.pdf - Numerical...

• 2

This preview shows page 1 - 2 out of 2 pages.

Numerical Analysis ( Midterm - Solution Highlights ) Winter 2021 Q1, Q2, Q3, Q4: 9, 16, 6 and 4 marks, respectively. Total: 35 marks Question 1 Gaussian quadratures have algebraic accuracy 2 n - 1 . Hence, in this case we should use the formula for n = 2. We convert the integral into one whose integrand has [ - 1 , 1] as its domain: Z 1 0 x 2 e - x dx = 1 2 Z 1 - 1 t + 1 2 ! 2 e - ( t +1) / 2 dt. Using the roots and weights given in Table 1 for n = 2 we have: Z 1 0 x 2 e - x dx 1 2 ( - 0 . 5773503 + 1 2 ) 2 e - ( - 0 . 5773503+1) / 2 +( 0 . 5773503 + 1 2 ) 2 e - (0 . 5773503+1) / 2 0 . 1594104 Remark: The linear transformation t = 2 x - a - b b - a ⇐⇒ x = 1 2 [( b - a ) t + a + b ] changes the interval [ a, b ] into [-1,1] and Z b a f ( x ) dx = Z 1 - 1 f ( ( b - a ) t + ( b + a ) 2 ) ( b - a ) 2 dt. Question 2 With the midpoint for h = 0 . 2 , t 0 = 1 . 0 , w 0 = 0 , we have w i +1 = w i + h [ f ( t i + h 2 , w i + h 2 f ( t i , w i ))] , and for i = 0 : w 1 = 0 . 0 + 0 . 2[ f (1 . 1 , 0 . 0 + 0 . 1 f (1 . 0 , 0 . 0)) = 0 . 2(1 . 099173554) = 0 . 2198347 The 4 th order RK is w i +1 = w i + 1 6 ( k 1 + 2 k 2 + 2 k 3 + k 4 ) , 1
where k 1 = hf ( t i , w i ) , k 2 = hf ( t i + 1 2 h, w i + 1 2 k 1 ) , k 3 = hf ( t i + 1 2 h, w i + 1 2 k 2 ) , k 4 = hf ( t i + h, w i + k 3 ) , and with the above values for i = 0 we have : k 1 = 0 . 2 f (1 . 0 , 0 . 0) = 0 . 2(1 . 0) = 0 . 2 , k 2 = 0 . 2 f (1 . 0 + 1 2 (0 . 2) , 0 . 0 + 1 2 (0 . 2)) = 0 . 2(1 . 0991736) = 0 . 2198347 , k 3 = 0 . 2 f (1 . 0 + 1 2 (0 . 2) , 0 . 0 + 1 2 (0 . 2198347) = 0 . 2(1 . 1099098) = 0 . 2219820 , k 4 = 0 . 2 f (1 . 2 , 0 . 0 + 0 . 2219820) = 0 . 2(1 . 2192044) = 0 . 2438409 , and, therefore: w 1 = w 0 + 1 6 ( k 1 + 2 k 2 + 2 k 3 + k 4 ) = 0 . 0 + 1 6 (0 . 2 + 2(0 . 2198347) + 2(0 . 2219820) + 0 . 2438409) = 0 . 2212457. Comparisons: Theoratically, the