Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


Math 104 A Numerical Analysis I

Winter 2022

Homework II


1.  (20 points)  1. Write a computer code to implement the Composite Trapezoidal Rule.

to approximate the definite integral

using the equally spaced points x0  = a, x1  = x0 +h, x2  = x0 +2h, . . . , xN  = x0 +Nh = b, where 

● Test your code with f (x) =  in [0,2] by computing the error |I(f) - Th (f)| for h =  ,  , , and verify that Th (f) has a convergence trend at the expected quadratic rate.

 Let f (x) = ′x in [0,1]. Compute T4(尸)    for N = 16, 32, 64, 128. Do you see a second

order convergence to the exact value of the integral? Explain.


2.  (50 points)  Consider the definite integral I(cos(x2 )) =   0′  cos x2 dx We cannot calcu- late its exact value but we can compute accurate approximations to it using Th (cos x2 ). Let

● Using your code, find a value of h for which q(h) is approximately equal to 4.

● Get an approximation of the error, I(cos x2 ) - Th (cos x2 ), for that particular value

of h.

● Use this error approximation to obtain the extrapolated, improved, approximation

● Explain why Sh (cos x2 ) is more accurate and converges faster to I(cos(x2 )) than Th (cos x2 )

 Let

Using your code, find a value of h for which q1 (h) is approximately equal to 16.

3.  (30 points)  Show that these assertions are not true.

● ex - 1 = 0(x2 ) as x - 0

● x−2  = 0(cot x) as x - 0

● cot x = o(x− 1 ) as x - 0