牛顿-拉弗森迭代法的基本原理

牛顿-拉弗森迭代法是基于泰勒级数的第一项展开来寻找函数根的方法. 如果你有一个方程 $f(x)=0$ , 你想找到这个方程的根, 这个方法会从一个初始猜测值 (guess) 开始.

\begin{equation*}
\begin{tikzpicture}[scale=1.2]
		% 坐标轴
		\draw[->] (-2,0) -- (2,0) node[right] {$x$};
		\draw[->] (0,-2) -- (0,2) node[above] {$y$};
		% 函数 f(x) = 0.5*(x^2 - 1)
		\draw[domain=-2:2,smooth,variable=\x,blue,thick]
		plot ({\x},{0.5*(\x^2-1)});
		% 迭代点
		\coordinate (A) at (1.5,0);
		\coordinate (B) at (1.5,{0.5*(1.5^2-1)});
		\coordinate (C) at (1.1,0);
		% 切线
		\draw[dashed] (A) -- (B);
		\draw[red,thick] (B) -- (C);
		% 标记点和简短标签
		\fill (A) circle (1pt) node[below,font=\scriptsize] {$A$};
		\fill (B) circle (1pt) node[above right,font=\scriptsize] {$B$};
		\fill (C) circle (1pt) node[below,font=\scriptsize] {$C$};
	\end{tikzpicture}
\end{equation*}

然后通过下面的迭代公式来逼近方程的根:

\begin{equation*}
x_{new} = x_{old} - \frac{f(x_{old})}{f'(x_{old})}
\end{equation*}
1

其中 \(f'(x)\) 是函数 \(f(x)\) 的导数。这三点 \(A(x_{old},0)$,$B(x_{old},f(x_{old}))\) , \(C(x_{new},0)\) 构成直角三角形, 点 C 是 B 点的切线与 x 轴的交点.

求平方根的迭代公式:

对于求 $x$ 的平方根, 我们要解的方程是 $f(x)=x^2-C=0$,其中 $C$ 是我们要求平方根的数. 根据牛顿-拉弗森方法,我们将 $f(x)=x^2 - C$ 和其导数 $f'(x)=2x$ 代入公式 $(1)$ ,得到:

\[
guess_{new}=guess_{old} - \frac{guess_{old}^2 - C}{2\cdot guess_{old}} = \frac{1}{2}\times \left( guess_{old} - \frac{C}{guess_{old}} \right)
\]

求三次方根的迭代公式:

对于求 x 的三次方根,我们要解的方程是$f(x)=x^3 -C = 0$. 这时, $f'(x) = 3x^2$.

同样地代入牛顿-拉弗森公式,得到:

\[
guess_{new}=guess_{old} - \frac{guess_{old}^3 - C}{3\cdot guess_{old}^2} = \frac{1}{3}\times \left( 2\cdot guess_{old} + \frac{C}{guess^2_{old}} \right)
\]

迭代法对凸函数很好用, 但是不是大范围收敛, 最好是在解附近使用. 或者改进下迭代方法达到更快的收敛速度.