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.

10<br />

9<br />

Remark 9.3.9 (Non-linear interpolation).<br />

8<br />

Harmonic mean =<br />

“smoothed min(·, ·)-function”.<br />

7<br />

6<br />

The monotonicity preserving cubic Hermite interpolation is non-linear !<br />

Contour plot of the harmonic mean of a and b ➙<br />

(w a = w b = 1/2).<br />

b<br />

5<br />

4<br />

3<br />

Terminology: An interpolation operator I : R n+1 ↦→ C 0 ([t 0 , t n ]) on the given nodes t 0 < t 1 <<br />

· · · < t n is called linear, if<br />

2<br />

1<br />

I(αy + βz) = αI(y) + βI(z) ∀y,z ∈ R n+1 , α, β ∈ R .<br />

Concrete choice of the weights:<br />

1 2 3 4 5 6 7 8 9 10<br />

a<br />

△<br />

w a = 2h i+1 + h i<br />

3(h i+1 + h i ) , w b = h i+1 + 2h i<br />

3(h i+1 + h i ) ,<br />

⎧<br />

∆ 1 , if i = 0 ,<br />

⎪⎨ 3(h i+1 +h i )<br />

→ c i = 2h i+1 +h i<br />

∆ + 2h i +h , for i ∈ {1, ...,n − 1} ,<br />

i+1<br />

i ∆ i+1 ⎪⎩<br />

∆ n , if i = n ,<br />

Example 9.3.8 (Monotonicity preserving piecewise cubic polynomial interpolation).<br />

, h i := t i − t i−1 . (9.3.5)<br />

Ôº½ º¿<br />

Calculation of the c i in pchip (details in [15]):<br />

Code 9.3.10: Monotonicity preserving slopes in pchip<br />

1 % PCHIPSLOPES Slopes for shape-preserving Hermite cubic<br />

2 % pchipslopes(x,y) computes c(k) = P’(x(k)).<br />

3 %<br />

Ôº½ º¿<br />

4 % Slopes at interior points<br />

5 % delta = diff(y)./diff(x).<br />

6 % c(k) = 0 if delta(k-1) and delta(k) have opposite signs or either is zero.<br />

Data from ex. 9.1.1<br />

MATLAB-function:<br />

v = pchip(t,y,x);<br />

t: Sampling points<br />

y: Sampling values<br />

x: Evaluation points<br />

v: Vector s(x i )<br />

Local interpolation operator<br />

! Non linear interpolation operator<br />

✬<br />

✫<br />

s(t)<br />

1<br />

0.8<br />

0.6<br />

0.4<br />

0.2<br />

0<br />

Data points<br />

Piecew. cubic interpolation polynomial<br />

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1<br />

t<br />

Theorem 9.3.1 (Monotonicity preservation of limited cubic Hermite interpolation).<br />

The cubic Hermite interpolation polynomial with slopes as in (9.3.5) provides a local<br />

monotonicity-preserving C 1 -interpolant.<br />

Proof. See F. FRITSCH UND R. CARLSON, Monotone piecewise cubic interpolation, SIAM J. Numer.<br />

Anal., 17 (1980), S. 238–246.<br />

✸<br />

✩<br />

✪<br />

Ôº½ º¿<br />

7 % c(k) = weighted harmonic mean of delta(k-1) and delta(k) if they have the same sign.<br />

8<br />

9 function c = pchipslopes ( x , y )<br />

10 n = length ( x ) ; h = d i f f ( x ) ; d e l t a = d i f f ( y ) . / h ;<br />

11 c = zeros ( size ( h ) ) ;<br />

12 k = find ( sign ( d e l t a ( 1 : n−2) ) .∗ sign ( d e l t a ( 2 : n−1) ) >0) +1;<br />

13 w1 = 2∗h ( k ) +h ( k−1) ;<br />

14 w2 = h ( k ) +2∗h ( k−1) ;<br />

15 c ( k ) = (w1+w2) . / ( w1 . / d e l t a ( k−1) + w2 . / d e l t a ( k ) ) ;<br />

16<br />

17 % Slopes at endpoints<br />

18 c ( 1 ) = pchipend ( h ( 1 ) , h ( 2 ) , d e l t a ( 1 ) , d e l t a ( 2 ) ) ;<br />

19 c ( n ) = pchipend ( h ( n−1) , h ( n−2) , d e l t a ( n−1) , d e l t a ( n−2) ) ;<br />

20<br />

21 % ——————————————————-<br />

22<br />

23 function d = pchipend ( h1 , h2 , del1 , del2 )<br />

24 % Noncentered, shape-preserving, three-point formula.<br />

25 d = ( ( 2∗h1+h2 ) ∗del1 − h1∗del2 ) / ( h1+h2 ) ;<br />

26 i f sign ( d ) ~= sign ( del1 ) , d = 0 ;<br />

27 e l s e i f ( sign ( del1 ) ~=sign ( del2 ) ) (abs(d)>abs(3*del1))d = 3*del1;end<br />

Ôº¾¼ º

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

Saved successfully!

Ooh no, something went wrong!