關於 sum 1/i 複雜度寬鬆估算的顯然證明

zsxuan發表於2024-03-21

前提
\(\frac{\mathrm{d} \ln x}{\mathrm{d} x} = \frac{1}{x}\)\(\ln x\)\(x > 0\) 遞增。
\(\frac{\mathrm{d} 1/x}{\mathrm{d} x} = -\frac{1}{x^2}\)\(\ln x\)\(x > 0\) 的斜率變化率遞減。


\[\frac{\ln (n + 1) - \ln n}{n + 1 - n} < lim_{\Delta \to 0} \frac{\ln (n + \Delta x) - ln n}{\Delta} = \frac{1}{n} \]

算兩遍思想

\[\begin{aligned} \ln (n + 1) - \ln n &< \frac{1}{n} \\ \ln n - \ln (n - 1) &< \frac{1}{n - 1} \\ \ln (n - 1) - \ln (n - 2) &< \frac{1}{n - 2} \\ \cdots \\ \ln 2 - \ln 1 &< \frac{1}{1} \\ \textbf{兩邊求和} \\ \ln (n + 1) < \sum_{i = 1}^{n} \frac{1}{i} \end{aligned} \]

\[\frac{\ln n - \ln (n-1)}{n - (n - 1)} > lim_{\Delta x \to 0} \frac{\ln (n - \Delta x) - \ln n}{\Delta} = \frac{1}{n} \]

繼續基於算兩遍思想差分

\[\begin{aligned} \ln n - \ln (n - 1) &> \frac{1}{n} \\ \ln (n - 1) - \ln (n - 2) &> \frac{1}{n - 1} \\ \ln (n - 2) - \ln (n - 3) &> \frac{1}{n - 2} \\ \cdots \\ \ln 2 - \ln 1 &> \frac{1}{2} \\ \textbf{兩邊求和} \\ \ln n + 1 &> \sum_{i = 1}^{n} \frac{1}{i} \end{aligned} \]

\[\ln (n + 1) < \sum_{i = 1}^{n} \frac{1}{i} < \ln n + 1 \]

於是 \(T(\sum_{i = 1}^{n} \frac{1}{i}) = O(\ln n)\)

相關文章