03.03.2014 Views

Numerical Methods Course Notes Version 0.1 (UCSD Math 174, Fall ...

Numerical Methods Course Notes Version 0.1 (UCSD Math 174, Fall ...

Numerical Methods Course Notes Version 0.1 (UCSD Math 174, Fall ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

112 CHAPTER 8. INTEGRALS AND QUADRATURE<br />

(8.10) Determine a “quadrature” rule of the form<br />

∫ 1<br />

−1<br />

f(x) dx ≈ Af(0) + Bf ′ (−1) + Cf ′ (1)<br />

that is exact for polynomials of highest possible degree. What is the highest degree polynomial<br />

for which this rule is exact? (Since this rule uses derivatives of f, it does not exactly fit our<br />

definition of a quadrature rule, but it may be applicable in some situations.)<br />

(8.11) Determine a “quadrature” rule of the form<br />

∫ 1<br />

0<br />

f(x) dx ≈ Af(0) + Bf ′ (0) + Cf(1)<br />

that is exact for polynomials of highest possible degree. What is the highest degree polynomial<br />

for which this rule is exact?<br />

(8.12) Consider the so-called order n Chebyshev Quadrature rule:<br />

∫ 1<br />

−1<br />

f(x) dx ≈ c n<br />

n∑<br />

f(x i )<br />

Find the weighting c n and nodes x i for the case n = 2 and the case n = 3. For what order<br />

polynomials are these rules exact?<br />

(8.13) Find the Gaussian Quadrature rule with 2 nodes for the interval [1, 5], i.e., find a rule<br />

∫ 5<br />

1<br />

i=0<br />

f(x) dx ≈ Af(x 0 ) + Bf(x 1 )<br />

Before you solve the problem, consider the following questions: do you expect the nodes to<br />

be the endpoints 1 and 5? do you expect the nodes to be arranged symmetrically around the<br />

midpoint of the interval?<br />

(8.14) Find the Gaussian Quadrature rule with 3 nodes for the interval [−1, 1], i.e., find a rule<br />

∫ 1<br />

−1<br />

f(x) dx ≈ Af(x 0 ) + Bf(x 1 ) + Cf(x 2 )<br />

To find the nodes x 0 , x 1 , x 2 you will have to find the zeroes of a cubic equation, which could be<br />

difficult. However, you may use the simplifying assumption that the nodes are symmetrically<br />

placed in the interval [−1, 1].<br />

(8.15) Write code to approximate the integral of a f on [a, b] by the composite trapezoidal rule on<br />

n equal subintervals. Your m-file should have header line like:<br />

function iappx = trapezoidal(f,a,b,n)<br />

You may wish to use the code:<br />

x = a .+ (b-a) .* (0:n) ./ n;<br />

If f is defined to work on vectors element-wise, you can probably speed up your computation<br />

by using<br />

bigsum = 0.5 * ( f(x(1)) + f(x(n+1)) ) + sum( f(x(2:(n))) );<br />

(8.16) Write code to implement the Gaussian Quadrature rule for n = 2 to integrate f on the<br />

interval [a, b]. Your m-file should have header line like:<br />

function iappx = gauss2(f,a,b)<br />

(8.17) Write code to implement composite Gaussian Quadrature based on code from the previous<br />

problem. Something like the following probably works:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!