21.06.2014 Views

Numerical Methods Contents - SAM

Numerical Methods Contents - SAM

Numerical Methods Contents - SAM

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

For fixed local n-point quadrature rule: O(mn) f-evaluations for composite quadrature (“total cost”)<br />

➣ If mesh equidistant (|x j −x j−1 | = h for all j), then total cost for composite numerical quadrature<br />

= O(h −1 ).<br />

✬<br />

Theorem 10.3.1 (Convergence of composite quadrature formulas).<br />

For a composite quadrature formula Q based on a local quadrature formula of order p ∈ N<br />

holds<br />

✫<br />

∃C > 0:<br />

∫<br />

∥ ∣ f(t) dt − Q(f) ∣ ≤ Ch p ∥ ∥f<br />

(p) ∥L<br />

I<br />

∞ (I)<br />

Proof. Apply interpolation error estimate (9.2.1).<br />

∀f ∈ C p (I), ∀M .<br />

✩<br />

✪<br />

✷<br />

7 res = [ ] ;<br />

8 for n = N<br />

9 h = ( b−a ) / n ;<br />

10 x = ( a : h / 2 : b ) ;<br />

11 f v = feval ( f n c t , x ) ;<br />

12 v a l = sum( h∗( f v ( 1 : 2 : end−2)+4∗ f v ( 2 : 2 : end−1)+ f v ( 3 : 2 : end ) ) ) / 6 ;<br />

13 res = [ res ; h , v a l ] ;<br />

14 end<br />

Note: fnct is supposed to accept vector arguments and return the function value for each vector<br />

component!<br />

Example 10.3.3 (Quadrature errors for composite quadrature rules).<br />

Ôº ½¼º¿<br />

Composite quadrature rules based on<br />

• trapezoidal rule (11.4.2) ➣ local order 2 (exact for linear functions),<br />

• Simpson rule (10.2.4) ➣ local order 3 (exact for quadratic polynomials)<br />

on equidistant mesh M := {jh} n j=0 , h = 1/n, n ∈ N.<br />

numerical quadrature of function 1/(1+(5t) 2 )<br />

10 0 trapezoidal rule<br />

Simpson rule<br />

O(h 2 )<br />

O(h 4 )<br />

numerical quadrature of function sqrt(t)<br />

10 0 trapezoidal rule<br />

Simpson rule<br />

10 −1 O(h 1.5 )<br />

Ôº ½¼º¿<br />

Code 10.3.4: composite trapezoidal rule (10.3.2)<br />

1 function res = t r a p e z o i d a l ( f n c t , a , b ,N)<br />

2 % <strong>Numerical</strong> quadrature based on trapezoidal rule<br />

3 % fnct handle to y = f(x)<br />

4 % a,b bounds of integration interval<br />

5 % N+1 = number of equidistant integration points (can be a vector)<br />

6 res = [ ] ;<br />

7 for n = N<br />

8 h = ( b−a ) / n ; x = ( a : h : b ) ; w = [ 0 . 5 ones ( 1 , n−1) 0 . 5 ] ;<br />

9 res = [ res ; h , h∗dot (w, feval ( f n c t , x ) ) ] ;<br />

10 end<br />

Code 10.3.5: composite Simpson rule (10.3.3)<br />

1 function res = simpson ( f n c t , a , b ,N)<br />

2 % <strong>Numerical</strong> quadrature based on Simpson rule<br />

3 % fnct handle to y = f(x)<br />

4 % a,b bounds of integration interval<br />

5 % N+1 = number of equidistant integration points (can be a vector)<br />

6<br />

Ôº ½¼º¿<br />

|quadrature error|<br />

10 −5<br />

10 −10<br />

10 −15<br />

10 −2 10 −1 10 0<br />

meshwidth<br />

2 on [0, 1] quadrature error, f 1 (t) := 1<br />

1+(5t) quadrature error, f 2 (t) := √ t on [0, 1]<br />

10 −2 10 −1 10 0<br />

meshwidth<br />

Asymptotic behavior of quadrature error E(n) := ∣ ∫ 1<br />

0 f(t) dt − Q n (f) ∣ for meshwidth "‘h → 0”<br />

☛<br />

algebraic convergence E(n) = O(h α ) of order α > 0, n = h −1<br />

|quadrature error|<br />

10 −2<br />

10 −3<br />

10 −4<br />

10 −5<br />

10 −6<br />

10 −7<br />

Ôº¼ ½¼º¿<br />

➣ Sufficiently smooth integrand f 1 : trapezoidal rule → α = 2, Simpson rule → α = 4 !?

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

Saved successfully!

Ooh no, something went wrong!