Solution to Computational Math II Assignment 3 Department of Applied Mathematics I. Section 7.1 17.Establish a formula of the form 00 fn ≈ [Afn+3 + Bfn+2 + Cfn+1 + Dfn ]/h2 Here fn+i = f (xn + ih). Solution I: By Taylor expansion, we have h2 00 h3 000 f (xn ) + f (xn ) + O(h4 ) 2 6 4h3 000 0 00 f (xn ) + O(h4 ) fn+2 = f (xn ) + 2hf (xn ) + 2h2 f (xn ) + 3 9h2 00 9h3 000 0 fn+3 = f (xn ) + 3hf (xn ) + f (xn ) + f (xn ) + O(h4 ) 2 2 From the problem, we have the following linear system: A+B+C +D =0 A = −1 3A + 2B + C = 0 B=4 ⇒ 9A + 4B + C = 2 C = −5 27A + 8B + C = 0 D=2 0 fn+1 = f (xn ) + hf (xn ) + Hence, we have the form 00 fn ≈ [−fn+3 + 4fn+2 − 5fn+1 + 2fn ]/h2 . Solution II: Using equations 01-03, we have fn+1 + fn+2 − fn+3 − fn = −2f 00 (xn )h2 + O(h2 ), which implies f 00 (xn ) ≈ So, A = D = 12 and B = C = − 12 . II. Section 7.2 8. Find the formula Z fn+1 + fn+2 − fn+3 − fn . −2h2 1 f (x)dx ≈ A0 f (0) + A1 f (1) 0 (0.1) (0.2) (0.3) 2 that is exact for all functions of the form f (x) = aex + b cos(πx/2). Solution: First, we integral the function on [0,1], then Z 1 Z 1 f (x)dx = 0 0 1 1 2b 2 [aex + b cos(πx/2)]dx = aex + sin(πx/2) = a(e − 1) + b. π π 0 0 And we have f (0) = a + b, f (1) = ae. Then we have the equation a(e − 1) + 2 b = A0 (a + b) + A1 ae = (A0 + A1 e)a + A0 b. π Then we got the linear system ( ( A0 = π2 A0 + A1 e = e − 1 ⇒ A1 = 1 − A0 = π2 1 e − 2 . eπ 31. Determine the minimum number of subintervals need to approximate Z 2 2 (x + e−x )dx 1 to an accuracy of at least 1 2 × 10−7 using the trapezoid rule. Solution: f (x) = x + e √ −x2 00 2 −x2 ⇒ f (x) = 4x e − 2e −x2 00 00 x ∈ [1, 2] ⇒ max f = f ( x∈[1,2] 3 6 ) = 4e− 2 . 2 By the accuracy of trapezoid rule, we know the the error is 00 − f (ξ) (b − a)h2 12 where b = 2, a = 1, ξ ∈ [1, 2]. As we want the accuracy of at least 1 2 × 10−7 , then 00 f (ξ) 1 (b − a)h2 | ≤ × 10−7 12 2 1 −3 (2 − 1)2 1 ⇔ 4e 2 · (2 − 1) · ≤ × 10−7 2 12 n 2 r 2 3 2 −3 ⇔ n2 ≥ e− 2 · 107 ⇔ n ≥ e 2 · 107 ≈ 1219.6 3 3 |− Hence, the minimal number of subintervals is 1220. III. Section 7.2 R1 R1 16. We intend to use 0 p(x)dx as an estimated of 0 f (x)dx, where p is a polynomial of degree n that interpolates f at nodes x0 , x1 , . . . , xn in [0, 1]. Assume that |f (n+1) (x)| < M on [0, 1] what 3 R1 R1 upper bound can be given for the error| 0 f (x)dx − 0 p(x)dx| if nothing is known about the location of the nodes? Can you find the best upper bound? Solution: By Interpolation polynomial Error Theorem, we have the error term n f (x) − p(x) = Y 1 f (n+1) (ξx ) (x − xi ), ξx ∈ [0, 1], x ∈ [0, 1]. (n + 1)! i=0 Hence the upper bound at least can be # Z 1 " Z 1 Z 1 n Y 1 (n+1) = p(x)dx f (ξ ) f (x)dx − (x − x ) dx x i (n + 1)! 0 0 0 i=0 Z 1 n Y 1 (n+1) f (ξ ) (x − x ) ≤ x i dx (n + 1)! 0 i=0 Z 1 M 1dx (as|x − xi | ≤ 1) ≤ (n + 1)! 0 M = . (n + 1)! Now, we want to have the best upper bound, then we can choose Chebyshev points to interpolate f (x). Then we use interval change, x = 12 + 12 t, t ∈ [−1, 1] and let xi = 12 + 12 ti , i = 0, 1, . . . , N, where n Q ti are Chebyshev points. Then we have x − x(i) = 21 (t − t(i)), and we know that | (t − ti )| = 21n . i=0 Hence, the best bound can be Z 1 Z f (x)dx − 0 0 1 # Z 1 " n Y 1 (n+1) f (ξx ) (x − xi ) dx p(x)dx = 0 (n + 1)! i=0 Z " # n 1 Y 1 (t − ti ) = f (n+1) (ξx ) dx 0 (n + 1)! 2 i=0 1 M 2n+1 (n + 1)! 2n M = 2n+1 2 (n + 1)! ≤ IV. Section 7.3 7. a) Find a formula of the form Z 1 xf (x)dx ≈ 0 n X Ai f (xi ) i=0 with n = 1 that is exact for all polynomials of degree 3. Solution: We want to the formula is exact for all polynomials of degree 3, by the theorem of Gaussian 4 Quadratue let q(x) = x2 + bx + c, q0 (x) = 1, q1 (x) = x desperately, we need to q(x) is w-orthogonal q0 , q1 where w(x) = x from the problem. Hence ,we obtain that Z 1 Z 1 1 4 b 3 c 2 1 1 b c 2 (x + bx + c) · 1 · xdx = x + x + x = + + = 0, q(x)p0 (x)w(x)dx = 4 3 2 0 4 3 2 0 0 Z 1 1 Z (x2 + bx + c) · x · xdx = q(x)p1 (x)w(x)dx = 0 0 − 65 Solve that we have b = and c = 3 . Substitute to q(x) 10 √ √ 6− 6 and x1 = 6+10 6 . 10 Solve that, we obtain the roots x0 = f0 (x) = 1 and f1 (x) = x. Then we have ( A0 + A1√= √ 6− 6 10 A0 1 5 b 4 c 3 1 1 b c x + x + x = + + = 0. 5 4 3 0 5 4 3 + 1 2 6+ 6 10 A1 = 1 3 ⇒ = x2 + bx + c = x2 − 6/5x + 3/10 = 0. Now we want to solve A0 and A1 Let ( A0 = A1 = √ 9− 6 36 √ 9+ 6 36 Hence, the formula is Z 0 1 √ 9− 6 f xf (x)dx ≈ A0 f (x0 ) + A1 f (x1 ) = 36 √ ! √ 6− 6 9+ 6 f + 10 36 V. Section 7.3 22. Show how the Gaussian quadrature rule r ! Z 1 5 8 5 3 f (x)dx ≈ f − + f (0) + f 9 5 9 9 −1 √ ! 6+ 6 . 10 r ! 3 5 Rb can be used for a f (x)dx. Apply this result to evaluate R4 (b) 0 sint t dt Solution: Using change of intervals, we have t= Then we have Z 4 0 sin t dt = t Z 4−0 0+4 x+ = 2x + 2 where x ∈ [−1, 1]. 2 2 1 sin 2x + 2 2dx −1 2x + 2 " ! r ! 5 3 8 5 =2 ·f 2· − + 2 + · f (2) + · f 9 5 9 9 ≈ 2 × (0.5369 + 0.4041 − 0.062) ≈ 1.758 VII. Section 3.2 r 2× 3 +2 5 !# 5 23Perform two iterations of Newton’s method on these systems: (a) Starting with (0,1) ( 4x21 − x22 = 0 4x1 x22 − x1 = 1 Solution: First, we have f1 (x) = 4x21 − x22 , f2 (x) = 4x1 x22 − x1 − 1, then we derive Jacobian matrix ! 8x1 −2x2 J= 4x22 − 1 8x1 x2 As x(0) = (0, 1)T , we have f (x(0) ) = (−1, −1)T . Then we need to solve J(x(0) )h(0) = −f (x(0) ). ! ! ! ! 1 1 0 −2 1 3 h= ⇒h= ⇒ x(1) = x(0) + h(0) = 31 3 0 1 − 12 2 Then we have 8 3 0 ! −1 4 3 h= 7 − 36 1 ! ⇒h= 5 24 3 4 ! ⇒ x(2) = x(1) + h(1) = VIII. Section 3.2 14. ( Use Newton method to solve the nonlinear system. 4y 2 + 4y + 52x = 19 a) 169x2 + 3y 2 + 111x − 10y = 10 Solution: The Jacobian matrix is ! 52 8y + 4 J= 338x + 111 6y − 10 Use the Matlab code, we have the solution at tolerance τ = 1e − 9: ( x = 0.1342 y = 1.3043 13 24 5 4 ! 6 Appendix code for 14.a) clear a l l ; clc ; % define i n i t i a l point . x0 = [ 0 ; 1 ] ; N=100; x=x0 ; % define tolerence ; t a o=1e −9; for i =1:N; J =[52 8∗ x ( 2 ) ; 338∗ x (1)+111 6∗ x ( 2 ) − 1 0 ] ; f =−[4∗x (2)ˆ2+4∗ x (2)+52∗ x (1) −19; 169∗ x (1)ˆ2+3∗ x (2)ˆ2+111∗ x (1) −10∗ x ( 2 ) − 1 0 ] ; h=J\ f ; xs=x+h ; i f norm( xs−x)<1e −8; break ; else x=xs ; end ; end ;
© Copyright 2025 Paperzz