First Semester in Numerical Analysis with Julia, 2020a
First Semester in Numerical Analysis with Julia, 2020a
First Semester in Numerical Analysis with Julia, 2020a
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
CHAPTER 4. NUMERICAL QUADRATURE AND DIFFERENTIATION 158<br />
In [1]: function gauss(f::Function)<br />
0.2369268851*f(-0.9061798459)+<br />
0.2369268851*f(0.9061798459)+<br />
0.5688888889*f(0)+<br />
0.4786286705*f(0.5384693101)+<br />
0.4786286705*f(-0.5384693101)<br />
end<br />
Out[1]: gauss (generic function <strong>with</strong> 1 method)<br />
Now we compute 1 4<br />
∫ 1<br />
−1<br />
( t+3<br />
) t+3<br />
4<br />
dt us<strong>in</strong>g the code:<br />
4<br />
In [2]: 0.25*gauss(t->(t/4+3/4)^(t/4+3/4))<br />
Out[2]: 0.41081564812239885<br />
The next theorem is about the error of the Gauss-Legendre rule. Its proof can be found <strong>in</strong><br />
Atk<strong>in</strong>son [3]. The theorem shows, <strong>in</strong> particular, that the degree of accuracy of the quadrature<br />
rule, us<strong>in</strong>g n nodes, is 2n − 1.<br />
Theorem 80. Let f ∈ C 2n [−1, 1]. The error of Gauss-Legendre rule satisfies<br />
∫ b<br />
a<br />
f(x)dx −<br />
n∑<br />
w i f(x i )=<br />
i=1<br />
2 2n+1 (n!) 4 f (2n) (ξ)<br />
(2n +1)[(2n)!] 2 (2n)!<br />
for some ξ ∈ (−1, 1).<br />
Us<strong>in</strong>g Stirl<strong>in</strong>g’s formula n! ∼ e −n n n (2πn) 1/2 , where the symbol ∼ means the ratio of the<br />
two sides converges to 1 as n →∞, it can be shown that<br />
2 2n+1 (n!) 4<br />
(2n +1)[(2n)!] 2 ∼ π 4 n .<br />
This means the error of Gauss-Legendre rule decays at an exponential rate of 1/4 n as opposed<br />
to, for example, the polynomial rate of 1/n 4 for composite Simpson’s rule.<br />
Exercise 4.3-1: Prove that the sum of the weights <strong>in</strong> Gauss-Legendre quadrature is 2,<br />
for any n.