HW3 Solution
HW3 Solution
HW3 Solution
- No tags were found...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Solution</strong> to Computational Math IIAssignment 3Department of Applied MathematicsI. Section 7.117.Establish a formula of the formHere f n+i = f(x n + ih).f ′′n ≈ [Af n+3 + Bf n+2 + Cf n+1 + Df n ]/h 2<strong>Solution</strong> I:By Taylor expansion, we havef n+1 = f(x n ) + hf ′ (x n ) + h22 f ′′ (x n ) + h36 f ′′′ (x n ) + O(h 4 ) (0.1)f n+2 = f(x n ) + 2hf ′ (x n ) + 2h 2 f ′′ (x n ) + 4h33 f ′′′ (x n ) + O(h 4 ) (0.2)f n+3 = f(x n ) + 3hf ′ (x n ) + 9h22 f ′′ (x n ) + 9h32 f ′′′ (x n ) + O(h 4 ) (0.3)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 = 2Hence, we have the formf ′′n ≈ [−f n+3 + 4f n+2 − 5f n+1 + 2f n ]/h 2 .<strong>Solution</strong> II: Using equations 01-03, we havewhich impliesf n+1 + f n+2 − f n+3 − f n = −2f ′′ (x n )h 2 + O(h 2 ),f ′′ (x n ) ≈ f n+1 + f n+2 − f n+3 − f n−2h 2 .So, A = D = 1 2 and B = C = − 1 2 .II. Section 7.28. Find the formula ∫ 1f(x)dx ≈ A 0 f(0) + A 1 f(1)0
2that is exact for all functions of the form f(x) = ae x + b cos(πx/2).<strong>Solution</strong>:First, we integral the function on [0,1], then∫ 10f(x)dx =∫ 10[ae x + b cos(πx/2)]dx = ae x ∣ ∣∣∣10+ 2bπ sin(πx/2) ∣ ∣∣∣∣1And we have f(0) = a + b, f(1) = ae. Then we have the equationa(e − 1) + 2 π b = A 0(a + b) + A 1 ae = (A 0 + A 1 e)a + A 0 b.Then we got the linear system{{A 0 + A 1 e = e − 1 A 0 = 2A 0 = 2 ⇒ππA 1 = 1 − 1 e − 2 .eπ0= a(e − 1) + 2 π b.31. Determine the minimum number of subintervals need to approximate∫ 21(x + e −x2 )dxto an accuracy of at least 1 2 × 10−7 using the trapezoid rule.<strong>Solution</strong>:√f(x) = x + e −x2 ⇒ f ′′ (x) = 4x 2 e −x2 − 2e −x2 x ∈ [1, 2] ⇒ max f ′′ = f ′′ 6(x∈[1,2] 2 ) = 4e− 3 2 .By the accuracy of trapezoid rule, we know the the error is− f ′′ (ξ)(b − a)h212where b = 2, a = 1, ξ ∈ [1, 2]. As we want the accuracy of at least 1 2 × 10−7 , then| − f ′′ (ξ)12 (b − a)h2 | ≤ 1 2 × 10−7⇔ 1 12 4e− 3 2 · (2 − 1) · (2 − 1) 2n 2≤ 1 2 × 10−7⇔ n 2 ≥ 2 3 e− 3 2 · 10 7 ⇔ n ≥√23 e− 3 2 · 10 7 ≈ 1219.6Hence, the minimal number of subintervals is 1220.III. Section 7.216. We intend to use ∫ 10 p(x)dx as an estimated of ∫ 10f(x)dx, where p is a polynomial of degreen that interpolates f at nodes x 0 , x 1 , . . . , x n in [0, 1]. Assume that |f (n+1) (x)| < M on [0, 1] what
upper bound can be given for the error| ∫ 10 f(x)dx − ∫ 10p(x)dx| if nothing is known about the locationof the nodes? Can you find the best upper bound?3<strong>Solution</strong>:By Interpolation polynomial Error Theorem, we have the error term1n∏f(x) − p(x) =(n + 1)! f (n+1) (ξ x ) (x − x i ), ξ x ∈ [0, 1], x ∈ [0, 1].Hence the upper bound at least can be∫ 1 ∫ 1∣ ∣∣∣∣ ∫ []1∣ f(x)dx − p(x)dx∣ = 1n∏000 (n + 1)! f (n+1) (ξ x ) (x − x i ) dx∣i=0∫ 11∣≤∣f (n+1) n∏(ξ x ) ∣(x − x(n + 1)!∣i )∣ dx0i=0≤M(n + 1)!= M(n + 1)! .∫ 10i=01dx (as|x − x i | ≤ 1)Now, we want to have the best upper bound, then we can choose Chebyshev points to interpolatef(x). Then we use interval change, x = 1 2 + 1 2 t, t ∈ [−1, 1] and let x i = 1 2 + 1 2 t i, i = 0, 1, . . . , N, wheret i are Chebyshev points. Then we have x − x(i) = 1 2 (t − t(i)), and we know that | n∏(t − t i )| = 1Hence, the best bound can be∫ 1∣ f(x)dx −0∫ 1IV. Section 7.37. a) Find a formula of the form0∣ ∣∣∣∣ ∫ []1p(x)dx∣ = 1n∏0 (n + 1)! f (n+1) (ξ x ) (x − x i ) dx∣i=0∫ []11n∏=∣ (n + 1)! f (n+1) (t − t i )(ξ x )dx2 ∣∫ 100M 1≤2 n+1 (n + 1)!M=2 2n+1 (n + 1)!xf(x)dx ≈2 nn∑A i f(x i )i=0with n = 1 that is exact for all polynomials of degree 3.i=0i=02 n .<strong>Solution</strong>:We want to the formula is exact for all polynomials of degree 3, by the theorem of Gaussian
Quadratue let q(x) = x 2 + bx + c, q 0 (x) = 1, q 1 (x) = x desperately, we need to q(x) is w-orthogonalq 0 , q 1 where w(x) = x from the problem. Hence ,we obtain that∫ 10∫ 10q(x)p 0 (x)w(x)dx =q(x)p 1 (x)w(x)dx =∫ 10∫ 10(x 2 + bx + c) · 1 · xdx = 1 4 x4 + b 3 x3 + c ∣ ∣∣∣12 x2 = 1 4 + b 3 + c 2 = 0,(x 2 + bx + c) · x · xdx = 1 5 x5 + b 4 x4 + c ∣ ∣∣∣13 x3 = 1 5 + b 4 + c 3 = 0.Solve that we have b = − 6 5 and c = 310 . Substitute to q(x) = x2 + bx + c = x 2 − 6/5x + 3/10 = 0.Solve that, we obtain the roots x 0 = 6−√ 610and x 1 = 6+√ 610 . Now we want to solve A 0 and A 1 Letf 0 (x) = 1 and f 1 (x) = x. Then we have{A 0 + A 1 = 1 2Hence, the formula is∫ 106− √ 610 A 0 + 6+√ 610 A 1 = 1 3xf(x)dx ≈ A 0 f(x 0 ) + A 1 f(x 1 ) = 9 − √ 6f36⇒({A 0 = 9−√ 636A 1 = 9+√ 6366 − √ )61000+ 9 + √ (6f366 + √ )6.104V. Section 7.322. Show how the Gaussian quadrature rule√35)∫ 1−1f(x)dx ≈ 5 9 f (−can be used for ∫ baf(x)dx. Apply this result to evaluate(b) ∫ 4 sin t0 tdt<strong>Solution</strong>:Using change of intervals, we haveThen we have∫ 40VII. Section 3.2∫sin t 1dt =t= 2+ 8 9 f(0) + 5 9 f (√35t = 4 − 02 x + 0 + 4 = 2x + 2 where x ∈ [−1, 1].2sin 2x + 2−1 2x + 22dx[ ( ( √539 · f 2 · −5)+ 2≈ 2 × (0.5369 + 0.4041 − 0.062)≈ 1.758)+ 8 9 · f(2) + 5 9 · f ()2 ×√35 + 2 )]
523Perform two iterations of Newton’s method on these systems:(a) Starting with (0,1) {4x 2 1 − x2 2 = 04x 1 x 2 2 − x 1 = 1<strong>Solution</strong>:First, we have f 1 (x) = 4x 2 1 − x2 2 , f 2(x) = 4x 1 x 2 2 − x 1 − 1, then we derive Jacobian matrix()8x 1 −2x 2J =4x 2 2 − 1 8x 1x 2As 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) ).( ) ( ) ( )(0 −2 11 1h = ⇒ h =33 0 1− 1 ⇒ x (1) = x (0) + h (0) =3122)Then we have( ) ( )83−1 − 74h =36031⇒ h =( )5243⇒ x (2) = x (1) + h (1) =4(132454)VIII. Section 3.214. { Use Newton method to solve the nonlinear system.a)4y 2 + 4y + 52x = 19169x 2 + 3y 2 + 111x − 10y = 10<strong>Solution</strong>:The Jacobian matrix is()J =52 8y + 4338x + 111 6y − 10Use the Matlab code, we have the solution at tolerance τ = 1e − 9:{x = 0.1342y = 1.3043
6Appendixcode for 14.a)clear a l l ;clc ;% d e f i n e i n i t i a l p o i n t .x0 = [ 0 ; 1 ] ;N=100;x=x0 ;% d e f i n e t o l e r e n c e ;tao=1e −9;for i =1:N;J=[52 8∗x ( 2 ) ; 338∗x(1)+111 6∗x (2) −10];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) −10];h=J\ f ;xs=x+h ;i f norm( xs−x)