MATH 373: Homework 10 “Integration III and Differentiation” Fall 2013

advertisement
Assigned: Thursday Dec. 5, 2013
Due Date: Thursday Dec. 12, 2013
MATH 373: Homework 10
“Integration III and Differentiation”
Fall 2013
NOTE: For each homework assignment observe the following guidelines:
• Include a cover page.
• Always clearly label all plots (title, x-label, y-label, and legend).
• Use the subplot command from MATLAB when comparing 2 or more plots to make
comparisons easier and to save paper.
1. Consider the three-point Gauss-Hermite quadrature rule:
Z ∞
2
e−x f (x) dx ≈ c1 f (x1 ) + c2 f (x2 ) + c3 f (x3 ).
−∞
(a) Using the theorem discussed in class, find the quadrature points. Use the fact
that the Hermite polynomials, Hn (x), are orthogonal in the corresponding inner
product:
Z
∞
(f, g) =
2
e−x f (x) g(x) dx
−∞
and H3 (x) =
8x3
− 12x. Clearly explain your reasoning.
(b) Using the theorem discussed in class, find the quadrature weights. Use the
following integrals to help you:
√
Z ∞
Z ∞
Z ∞
√
π
−x2
−x2
2 −x2
e
dx = π,
.
xe
dx = 0,
x e
dx =
2
−∞
−∞
−∞
(c) Use your result to approximate the following integral
Z
∞
I=
−∞
2
e−x
dx.
1 + x2
The exact answer to 20 digits of accuracy is I = 1.3432934216467351705. How
accurate is your approximation?
2. Consider the three-point Gaussian quadrature rule:
Z 1
f (x) dx = c1 f (x1 ) + c2 f (x2 ) + c3 f (x3 ) +
−1
1
f (6) (ξ),
15750
for some a < ξ < b.
(a) Using the theorem discussed in class, find all of the quadrature points and
weights in the above formula
(b) Convert the above quadrature rule (including the error term) to the interval
[xj−1 , xj ].
1
Assigned: Thursday Dec. 5, 2013
Due Date: Thursday Dec. 12, 2013
(c) Using the above results, derive the composite three-point Gaussian quadrature
rule:
Z b
n Z xj
n
X
X
f (x) dx =
f (x) dx =
[. . . Formula from Part (b) . . .] ,
a
j=1
xj−1
j=1
where xj = a + jh for j = 0, 1, 2, . . . , n are equally spaced points with h =
(b − a)/n. Show that the above composite rule has a convergence rate of O(h6 ).
3. SOURCE CODE:
Write the following functions:
• R = Romberg(f,a,b,n):
Romberg integration approximation to
zoidal Rule values.
Rb
a
f (x) dx using n Composite Trape-
• I = CompGaussQuad3(f,a,b,n):
Composite 3-point Gaussian quadrature rule for approximating
n subintervals each of length h = (b − a)/n.
Rb
a
f (x) dx using
4. Consider the integral
Z
I=
√
2 π
sin x2 dx = 0.48624702331211065533.
0
(a) Approximate this integral with your Romberg code. Increase n until your final
approximation, Rnn , is accurate to an absolute error of 10−14 . For this value
of n, create a table showing the errors for all the entries of R.
(b) Approximate this integral with the composite 3-point Gaussian Quadrature
code. Create a table for n = 1, 2, 4, 8, 16, . . . showing the approximation, the
absolute errors, and error ratios. Keep doubling n until the approximation is
accurate to an absolute error of 10−14 .
5. (a) Derive the optimal difference formula for the second derivative of the form:
f 00 (x0 ) ≈ af (x0 − h) + bf (x0 ) + cf (x0 + h) + df (x0 + 2h).
(b) What is the error term associated with this formula?
(c) Numerically verify the order of accuracy using f (x) = ex and x0 = 0.
(d) Apply the difference formula with f (x) = ex and x0 = 0 for smaller and smaller
values of h. How small can you make h before round-off error starts to dominate? Provide a plot to justify your answer.
2
Download