Homework 3 – Math 104B, Spring 20201 Due on Saturday, April 25th, 2020 Instructor: Carlos J. Garc ́ıa Cervera
1. (10 points) Prove that the composite Simpson’s rule is O(h4) when applied to functions with sufficient derivatives.
2. (10 points) Consider a numerical integration rule of the form 1 3 3
f(x)dx≈Af − 5 +Bf(0)+Cf 5 . −1
(a) (5 points) What is the linear system that muist be solved in the method of undetermined coefficients for finding A, B, C? Solve for A, B, C.
(b) (5 points) What three integrals must be evaluated to determine A, B, C in a Newton-Cotes formula? Solve for A, B, C.
3. (10 points) Show how the Gaussian quadrature rule
1 53 8 53
f(x)dx≈9f − 5 +9f(0)+9f − 5 −1
can be used for
b
f (x) dx.
a
0
4 sin t dt. 0t
Apply this result to evaluate (a) (3 points)
(b) (4 points)
1All course materials (class lectures and discussions, handouts, homework assignments, examinations, web materials, etc) and the intellectual content of the course itself are protected by United States Federal Copyright Law, and the California Civil Code. The UC Policy 102.23 expressly prohibits students (and all other persons) from recording lectures or discussions and from distributing or selling lecture notes and all other course materials without the prior written permission of the instructor.
1
π/2
x dx.
2
√x dx. (1)
Using the Python command quad from scipy.integrate,
quad(lambda x: cos(x)/sqrt(x), 0, 1,epsabs=1.e-12,epsrel=1.e-12) we obtain the value 1.8090484758005458.
(a) (5 points) Write a program to approximate the integral using the Trapezoidal rule. Note that the function is singular at x = 0, so in the Trapezoidal sum you need to omit that value. Taking the analytic value of the integral to be 1.8090484758005458, show numerically that the order of accuracy is 1/2 in this case.
(b) (5 points) Repeat the above problem with Simpson’s rule. What order of accuracy do you get?
(c) (5 points) We can evaluate the integral with higher accuracy sim- ply by rewriting the integral as
4. (25 points) We want to approximate the integral
I =
1 cosx
0
1cos(x)−1 1 1 1cos(x)−1
√x dx + 2. Write a program to approximate the integral using the Trape-
zoidal rule. What order of accuracy do you get?
(d) Another way to approximate the integral is a modification of the procedure we used to construct the Newton-Cotes quadrature rules. Consider an integral of the form
I = √x dx + √x dx = 000
I =
f(x) √x dx.
b f(x)
I =
where f is a smooth function. Divide the interval using n + 1 equispacedpoints: xi =a+ih, i=0,…,n,withh=(b−a)/n.
√x dx,
Then
n−1 x i+1
i=0 xi
a
In each interval, approximate the function f by the linear in- terpolation polynomial, so that in each interval one obtains an integral of the form
xi+1 αi+βix
√x dx. xi
3
These integrals can be evaluated exactly, which leads to a quadra- ture rule of the form
n
I(f) = ωifi.
i=0
i. (5 points) Prove that this approach provides a quadrature that is second order accurate.
ii. (5 points) Write a program that uses this approach to ap- proximate (1), and verify the order of accuracy numerically.