The Usage Of Difference Table

 

SO,What's that



$A\ Polynomial\ can\ be\ expressed\ like\ this:\\ (suggest\ that\ k<< n)\\ \\ $
$F_k(x)=c_kC_{x}^{k}+c_{k-1}C_{x}^{k-1}+...+c_1C_{x}^{1}+c_0\\ \\$

$We\ define\ \Delta{}f(x)=f(x+1)-f(x)\\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \Delta^2{}f(x)=\Delta{}f(x+1)-\Delta{}f(x)\\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ...\\ \\ $

$It\ is\ proved\ that
:\\c_0=f(0) \\ \ c_1=\Delta^1{}f(0)\\ \ c_2=\Delta^2{}f(0)\\ \ \ ...\\ \ c_k=\Delta^k{}f(0)$
$\\
\\$

 

$So\ this\ is\ the\ table: \\ $
$f(0)\ \ \ \ f(1)\ \ \ \ f(2)\ \ \ \ f(3)\ \ \ ... \ \ \ \ f(k)\\ $
$\ \ \ \ \ \Delta^2{}f(0)\ \ \ \ \Delta^2{}f(1)\ \ \ \ \Delta^2{}f(2)\ \ ... \ \ \Delta^2{}f(k)\ \ \ \\ $
$\ \ \ \ \ \ \ \ \ \ \ \ \ \Delta^3{}f(0)\ \ \ \ \Delta^3{}f(1)\ \ \ \ \Delta^3{}f(2)\ \ ... \ \ \Delta^3{}f(k)\ \ \ \\ $

$\\ \\ $
$So\ we\ use\ O(k^2)\ to\ get\ the\ table$
$And\ we\ use\ the\ formula\ \\ $$C_{n}^{i}=\frac{C_{\ n\ }^{\ i-1\ }\ *\ (\ n-i+1\ )}{i}$$ \\ to\ calculate\ the\ polynomial\ in\ O(k)$

 


 

$Now\ let's\ apply\ it\ to\ an\ example:\\ \\ $
$CALCULATE:f(n)=\sum_{i=1}^{n}i^k\ \ (n<=10^9)\\$
$we'll\ get\ f(0)\ \ f(1)\ \ ...\ f(k)\ in\ O(k*log_{2}{k});\\$
$we'll\ get\ the\ table\ \ in\ O(k^2);\\$
$then\ we\ can\ get\ f(n)\ in\ O(k)\\$
$we're\ done.$

 

posted @ 2018-06-29 20:20  Captain_fcj  阅读(107)  评论(0编辑  收藏  举报