Interpolacja Hermite’a – interpolacja umożliwiająca znalezienie wielomianu przybliżającego według wartości
y 1 = f ( x 1 ) , y 2 = f ( x 2 ) , … , y n = f ( x n ) {\displaystyle y_{1}=f(x_{1}),y_{2}=f(x_{2}),\dots ,y_{n}=f(x_{n})} na n {\displaystyle n} danych węzłach x 1 , x 2 , … , x n , {\displaystyle x_{1},x_{2},\dots ,x_{n},} oraz na wartościach pochodnych na wybranych węzłach
f ′ ( x 1 ) , f ″ ( x 1 ) , … , f ( k 1 ) ( x 1 ) , … , f ′ ( x n ) , … , f ( k n ) ( x n ) . {\displaystyle f'(x_{1}),f''(x_{1}),\dots ,f^{(k_{1})}(x_{1}),\dots ,f'(x_{n}),\dots ,f^{(k_{n})}(x_{n}).} Węzeł zadany bez pochodnej jest węzłem pojedynczym , a węzeł z danymi pochodnymi 1 , 2 , … , k {\displaystyle 1,2,\dots ,k} jest węzłem k + 1 {\displaystyle k+1} -krotnym.
Funkcja f ( x ) = sin ( x ) + cos ( x ) {\displaystyle f(x)=\sin(x)+\cos(x)} (czarny) i jej wielomian interpolacyjny (czerwony) obliczony na podstawie 5 danych węzłów podwójnych w przedziale [ 1 , 4 ] , {\displaystyle [1,4],} wygenerowany dzięki programowi Mathematica
Algorytm Algorytm jest podobny jak przy interpolacji Newtona . Kolumnę wypełnia się wszystkimi wartościami węzłów (jeżeli węzeł jest k {\displaystyle k} -krotny, to umieszczamy go w tabeli k {\displaystyle k} razy).
x i {\displaystyle x_{i}} f ( x i ) {\displaystyle f(x_{i})} x 0 {\displaystyle x_{0}} f ( x 0 ) {\displaystyle f(x_{0})} x 1 {\displaystyle x_{1}} f ( x 1 ) {\displaystyle f(x_{1})} x 2 {\displaystyle x_{2}} f ( x 2 ) {\displaystyle f(x_{2})} ⋮ {\displaystyle \vdots } ⋮ {\displaystyle \vdots } x n {\displaystyle x_{n}} f ( x n ) {\displaystyle f(x_{n})}
Następnie dopisuje się do każdej kolumny kolejne różnice dzielone , z tym wyjątkiem, że przy węzłach k {\displaystyle k} -krotnych, k > 1 , {\displaystyle k>1,} gdzie, de facto, nie można obliczyć różnicy dzielonej, podstawia się wartości kolejnych pochodnych na węzłach podzielone przez silnię ze stopnia pochodnej. (W tabeli przedstawiony jest 3 {\displaystyle 3} -krotny węzeł x 1 {\displaystyle x_{1}} ).
x i {\displaystyle x_{i}} f ( x i ) {\displaystyle f(x_{i})} f [ x i − 1 , x i ] {\displaystyle f[x_{i-1},x_{i}]} f [ x i − 2 , x i − 1 , x i ] {\displaystyle f[x_{i-2},x_{i-1},x_{i}]} x 0 {\displaystyle x_{0}} f ( x 0 ) {\displaystyle f(x_{0})} x 1 {\displaystyle x_{1}} f ( x 1 ) {\displaystyle f(x_{1})} f [ x 0 , x 1 ] {\displaystyle f[x_{0},x_{1}]} x 1 {\displaystyle x_{1}} f ( x 1 ) {\displaystyle f(x_{1})} f ′ ( x 1 ) {\displaystyle f'(x_{1})} f [ x 0 , x 1 , x 1 ] {\displaystyle f[x_{0},x_{1},x_{1}]} x 1 {\displaystyle x_{1}} f ( x 1 ) {\displaystyle f(x_{1})} f ′ ( x 1 ) {\displaystyle f'(x_{1})} f ″ ( x 1 ) 2 ! {\displaystyle {\frac {f''(x_{1})}{2!}}} x 2 {\displaystyle x_{2}} f ( x 2 ) {\displaystyle f(x_{2})} f [ x 1 , x 2 ] {\displaystyle f[x_{1},x_{2}]} f [ x 1 , x 1 , x 2 ] {\displaystyle f[x_{1},x_{1},x_{2}]} ⋮ {\displaystyle \vdots } ⋮ {\displaystyle \vdots } ⋮ {\displaystyle \vdots } x n {\displaystyle x_{n}} f ( x n ) {\displaystyle f(x_{n})} f [ x n − 1 , x n ] {\displaystyle f[x_{n-1},x_{n}]} f [ x n − 2 , x n − 1 , x n ] {\displaystyle f[x_{n-2},x_{n-1},x_{n}]}
Tabelę uzupełnia się do końca jak przy interpolacji Newtona, uznając ciągłe pochodne na węzłach wielokrotnych jako różnice dzielone rzędu drugiego.
x i {\displaystyle x_{i}} f ( x i ) {\displaystyle f(x_{i})} f [ x i − 1 , x i ] {\displaystyle f[x_{i-1},x_{i}]} f [ x i − 2 , x i − 1 , x i ] {\displaystyle f[x_{i-2},x_{i-1},x_{i}]} f [ x i − 3 , x i − 2 , x i − 1 , x i ] {\displaystyle f[x_{i-3},x_{i-2},x_{i-1},x_{i}]} ⋯ {\displaystyle \cdots } f [ x i − n , … , x i ] {\displaystyle f[x_{i-n},\dots ,x_{i}]} x 0 {\displaystyle x_{0}} f ( x 0 ) {\displaystyle f(x_{0})} x 1 {\displaystyle x_{1}} f ( x 1 ) {\displaystyle f(x_{1})} f [ x 0 , x 1 ] {\displaystyle f[x_{0},x_{1}]} x 1 {\displaystyle x_{1}} f ( x 1 ) {\displaystyle f(x_{1})} f ′ ( x 1 ) {\displaystyle f'(x_{1})} f [ x 0 , x 1 , x 1 ] {\displaystyle f[x_{0},x_{1},x_{1}]} x 1 {\displaystyle x_{1}} f ( x 1 ) {\displaystyle f(x_{1})} f ′ ( x 1 ) {\displaystyle f'(x_{1})} f ″ ( x 1 ) 2 ! {\displaystyle {\frac {f''(x_{1})}{2!}}} f [ x 0 , x 1 , x 1 , x 1 ] {\displaystyle f[x_{0},x_{1},x_{1},x_{1}]} ⋮ {\displaystyle \vdots } ⋮ {\displaystyle \vdots } ⋮ {\displaystyle \vdots } ⋮ {\displaystyle \vdots } ⋮ {\displaystyle \vdots } ⋱ {\displaystyle \ddots } x n {\displaystyle x_{n}} f ( x n ) {\displaystyle f(x_{n})} f [ x n − 1 , x n ] {\displaystyle f[x_{n-1},x_{n}]} f [ x n − 2 , x n − 1 , x n ] {\displaystyle f[x_{n-2},x_{n-1},x_{n}]} f [ x n − 3 , x n − 2 , x n − 1 , x n ] {\displaystyle f[x_{n-3},x_{n-2},x_{n-1},x_{n}]} ⋯ {\displaystyle \cdots } f [ x 0 , … , x n ] {\displaystyle f[x_{0},\dots ,x_{n}]}
Definiując a i {\displaystyle a_{i}} jako wartości na przekątnej, i = 1 , 2 , 3 , … , m , {\displaystyle i=1,2,3,\dots ,m,} gdzie m {\displaystyle m} to suma krotności węzłów, otrzymuje się wielomian:
w ( x ) = ∑ i = 0 m a i ∏ j = 0 i − 1 ( x − x ¯ j ) , {\displaystyle w(x)=\sum _{i=0}^{m}a_{i}\prod _{j=0}^{i-1}(x-{\bar {x}}_{j}),} gdzie x ¯ i = x 1 , x 1 , … , x 1 , x 2 , x 2 , … , x 2 , … , x n , {\displaystyle {\bar {x}}_{i}={x_{1},x_{1},\dots ,x_{1},x_{2},x_{2},\dots ,x_{2},\dots ,x_{n}},} przy czym każdy k {\displaystyle k} -krotny węzeł występuje k {\displaystyle k} razy.
Przykład Należy znaleźć wielomian interpolacyjny, przybliżający funkcję o zadanych węzłach dwukrotnych:
x 1 = 1 , x 2 = 3 f ( x 1 ) = 3 , f ( x 2 ) = 5 f ′ ( x 1 ) = 2 , f ′ ( x 2 ) = 6 {\displaystyle {\begin{array}{lcl}x_{1}=1&,&x_{2}=3\\f(x_{1})=3&,&f(x_{2})=5\\f'(x_{1})=2&,&f'(x_{2})=6\end{array}}} Zapisuje się wartości w tabeli:
x i {\displaystyle x_{i}} f ( x i ) {\displaystyle f(x_{i})} 1 {\displaystyle 1} 3 {\displaystyle 3} 1 {\displaystyle 1} 3 {\displaystyle 3} 3 {\displaystyle 3} 5 {\displaystyle 5} 3 {\displaystyle 3} 5 {\displaystyle 5}
Następnie w miejsce powtarzającego się węzła wstawia się wartości pochodnej, a w pozostałe miejsca (w tym przypadku jedno) wstawia się odpowiednią różnicę dzieloną:
x i {\displaystyle x_{i}} f ( x i ) {\displaystyle f(x_{i})} R 2 ( x i ) {\displaystyle R_{2}(x_{i})} 1 {\displaystyle 1} 3 {\displaystyle 3} – 1 {\displaystyle 1} 3 {\displaystyle 3} 2 {\displaystyle 2} 3 {\displaystyle 3} 5 {\displaystyle 5} 1 {\displaystyle 1} 3 {\displaystyle 3} 5 {\displaystyle 5} 6 {\displaystyle 6}
Następnie uzupełnia się do końca tabelę:
x i {\displaystyle x_{i}} f ( x i ) {\displaystyle f(x_{i})} R 2 ( x i ) {\displaystyle R_{2}(x_{i})} R 3 ( x i ) {\displaystyle R_{3}(x_{i})} R 4 ( x i ) {\displaystyle R_{4}(x_{i})} 1 {\displaystyle 1} 3 {\displaystyle 3} – – – 1 {\displaystyle 1} 3 {\displaystyle 3} 2 {\displaystyle 2} – – 3 {\displaystyle 3} 5 {\displaystyle 5} 1 {\displaystyle 1} − 1 2 {\displaystyle -{\frac {1}{2}}} – 3 {\displaystyle 3} 5 {\displaystyle 5} 6 {\displaystyle 6} 5 2 {\displaystyle {\frac {5}{2}}} 3 2 {\displaystyle {\frac {3}{2}}}
Zatem otrzymuje się wielomian:
w ( x ) = 3 + 2 ( x − 1 ) − 1 2 ( x − 1 ) 2 + 3 2 ( x − 1 ) 2 ( x − 3 ) = 3 2 x 3 − 8 x 2 + 27 2 x − 4. {\displaystyle w(x)=3+2(x-1)-{\frac {1}{2}}(x-1)^{2}+{\frac {3}{2}}(x-1)^{2}(x-3)={\frac {3}{2}}x^{3}-8x^{2}+{\frac {27}{2}}x-4.} Łatwo sprawdzić, że interpoluje on dane punkty:
w ( 1 ) = 3 2 − 8 + 27 2 − 4 = 3 {\displaystyle w(1)={\frac {3}{2}}-8+{\frac {27}{2}}-4=3} w ′ ( 1 ) = 9 2 − 16 + 27 2 = 2 {\displaystyle w'(1)={\frac {9}{2}}-16+{\frac {27}{2}}=2} w ( 3 ) = 3 2 ⋅ 27 − 8 ⋅ 9 + 27 2 ⋅ 3 − 4 = 5 {\displaystyle w(3)={\frac {3}{2}}\cdot 27-8\cdot 9+{\frac {27}{2}}\cdot 3-4=5} w ′ ( 3 ) = 9 2 ⋅ 9 − 16 ⋅ 3 + 27 2 = 6. {\displaystyle w'(3)={\frac {9}{2}}\cdot 9-16\cdot 3+{\frac {27}{2}}=6.}
Zobacz też
Bibliografia Rafał Witkowski: Metody numeryczne, ćwiczenie 5. [dostęp 2012-11-10]. [zarchiwizowane z tego adresu (2012-12-30)]. (pol. ) .