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.

1<br />

0.9<br />

Function f<br />

1<br />

0.9<br />

Function f<br />

✬<br />

Lemma 9.5.3 (Properties of Bernstein polynomials).<br />

✩<br />

0.8<br />

0.8<br />

(i) t = 0 is a zero of order i of b i,n , t = 1 is a zero of order n − i of b i,n ,<br />

0.7<br />

0.6<br />

0.5<br />

0.7<br />

0.6<br />

0.5<br />

(ii)<br />

(iii)<br />

∑ n<br />

i=0 b i,n ≡ 1 (partition of unity),<br />

b i,n (t) = (1 − t) b i,n−1 + t b i−1,n−1 (t),<br />

0.4<br />

0.4<br />

(iv) b i,n (t) ≥ 0 ∀ 0 ≤ t ≤ 1.<br />

0.3<br />

0.3<br />

✫<br />

✪<br />

0.2<br />

0.2<br />

0.1<br />

0<br />

0 0.2 0.4 0.6 0.8 1<br />

t<br />

0.1<br />

0<br />

0 0.2 0.4 0.6 0.8 1<br />

t<br />

Bad approximation, but good “shape reproduction” by p n<br />

Quoted from [9, Sect. 6.3]: Monotonic and convex functions yield monotonic and convex approximants,<br />

respectively. In a work, the Bernstein approximants mimic the behavior of the function to a<br />

remarkable degree. There is a price that must be paid for these beautiful approximation properties:<br />

the convergence of Bernstein polynomials is very slow.<br />

Ôº¿ º<br />

f ′ (t) exists and does not vanish, p n (t) converges to f(t) precisely like C/n. This fact seems to<br />

It is far slower than what can be achieved by other means. If f is bounded, then at a point t where<br />

have precluded any numerical application of Bernstein polynomials from having been made (1975!).<br />

Perhaps they will find application when the properties of the approximant in the large are of more<br />

importance than closeness of the approximation.<br />

Definition 9.5.2 (Bernstein polynomials).<br />

Bernstein polynomials of degree n:<br />

( n<br />

b i,n (t) := t<br />

i)<br />

i (1 − t) n−i , i = 0, ...,n .<br />

(b i,n :≡ 0 for i < 0, i > n)<br />

Plot of Bernstein polynomials for n = 10<br />

➙<br />

b n<br />

(t)<br />

1<br />

0.9<br />

0.8<br />

0.7<br />

0.6<br />

0.5<br />

0.4<br />

0.3<br />

0.2<br />

0.1<br />

i=0<br />

i=2<br />

i=4<br />

i=6<br />

i=8<br />

i=10<br />

0<br />

0 0.2 0.4 0.6 0.8 1<br />

t<br />

Lemma 9.5.3 (iii) provides an<br />

efficient computation of b i,n (t)<br />

(recursion)<br />

Code 9.5.2: Bernstein polynomial<br />

1 function V = b e r n s t e i n ( n , x )<br />

2 V = [ ones ( 1 , length ( x ) ) ; . . .<br />

3 zeros ( n , length ( x ) ) ] ;<br />

4 for j =1:n<br />

5 for k= j +1:−1:2<br />

6 V( k , : ) = x .∗V( k −1 ,:) + (1−x ) .∗V( k , : ) ;<br />

7 end<br />

8 V ( 1 , : ) = (1−x ) .∗V ( 1 , : ) ;<br />

9 end<br />

MATLAB file: given the function f, plot Bernstein approximating polynomials of degrees from 2 to n in<br />

the interval [0, 1]<br />

1 function d b splot ( f , n )<br />

2 x=linspace (0 ,1 ,200) ;<br />

Code 9.5.3: Bernstein approximation<br />

3 figure ( ’Name ’ , ’ Bernstein approximation ’ ) ;<br />

4 plot ( x , feval ( f , x ) , ’ r−−’ , ’ l i n e w i d t h ’ ,2) ;<br />

5 legend ( ’ Function f ’ ) ; hold on ;<br />

6 X = [ ] ;<br />

7 for k =2:n ; X = [ X, bsapprox ( f , k , x ) ’ ] ; end ;<br />

8 plot ( x , X, ’− ’ ) ; xlabel ( ’ t ’ ) ; hold o f f ;<br />

9<br />

10 function v = bsapprox ( f , n , x ) ;<br />

11 f v = feval ( f , ( 0 : 1 / n : 1 ) ) ; % n+1 line vector<br />

12 V = b e r n s t e i n ( n , x ) ; % (n+1)*(length(x)) matrix<br />

13 v = f v ∗V ;<br />

Try:<br />

>> dbsplot(@(x) max(0,-(x-0.5).^2+0.08), 50);<br />

>> dbsplot(@(x) atan((x-0.5)*2*pi), 50);<br />

Ôº º<br />

Ôº º<br />

Ôº º

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

Saved successfully!

Ooh no, something went wrong!