# 牛顿法

## 方法说明

${\displaystyle 0=(x-x_{0})\cdot f'(x_{0})+f(x_{0})}$

${\displaystyle x_{n+1}=x_{n}-{\frac {f(x_{n})}{f'(x_{n})}}}$

${\displaystyle f'(x)\neq 0}$ ; 对于所有${\displaystyle x\in I}$ ，其中${\displaystyle I}$ 为区间[αr, α + r]，且${\displaystyle x_{0}}$ 在区间其中${\displaystyle I}$ 内，即 ${\displaystyle r\geqslant \left|a-x_{0}\right|}$  的;

${\displaystyle x_{0}}$ 足够接近根 α

## 其它例子

### 第一个例子

${\displaystyle {\begin{matrix}x_{1}&=&x_{0}-{\frac {f(x_{0})}{f'(x_{0})}}&=&0.5-{\frac {\cos(0.5)-0.5^{3}}{-\sin(0.5)-3\times 0.5^{2}}}&=&1.112141637097\\x_{2}&=&x_{1}-{\frac {f(x_{1})}{f'(x_{1})}}&=&\vdots &=&{\underline {0.}}909672693736\\x_{3}&=&\vdots &=&\vdots &=&{\underline {0.86}}7263818209\\x_{4}&=&\vdots &=&\vdots &=&{\underline {0.86547}}7135298\\x_{5}&=&\vdots &=&\vdots &=&{\underline {0.8654740331}}11\\x_{6}&=&\vdots &=&\vdots &=&{\underline {0.865474033102}}\end{matrix}}}$

### 第二个例子

${\displaystyle a}$ ${\displaystyle m}$ 次方根。

${\displaystyle x^{m}-a=0}$

${\displaystyle f(x)=x^{m}-a}$ ${\displaystyle f'(x)=mx^{m-1}}$

${\displaystyle x_{n+1}=x_{n}-{\frac {f(x_{n})}{f'(x_{n})}}}$

${\displaystyle x_{n+1}=x_{n}-{\frac {x_{n}^{m}-a}{mx_{n}^{m-1}}}}$

${\displaystyle x_{n+1}=x_{n}-{\frac {x_{n}}{m}}(1-ax_{n}^{-m})}$

（或 ${\displaystyle x_{n+1}=x_{n}-{\frac {1}{m}}\left(x_{n}-a{\frac {x_{n}}{x_{n}^{m}}}\right)}$

## 應用

### 求解最值問題

${\displaystyle x_{n+1}=x_{n}-{\frac {f^{\prime }(x_{n})}{f^{\prime \prime }(x_{n})}}.}$

## 電腦程式

from math import pow
def f(x):
y = pow(x,3)-(10*x*x)+x+1
return y
def dx(x):
y = (3*x*x)-(20*x)+1
return y
x = 1
for i in range(1000):
x = x - (f(x)/dx(x))
print(x)


#include <stdio.h>
#include <math.h>
double x = 1.0;
double f(double x){
double y = pow(x,3)-(10*x*x)+x+1;
return y;}
double dx(double x){
double y = (3*x*x)-(20*x)+1;
return y;}
int main (){
for(int i=0;i<1000;i++){
x = x - (f(x)/dx(x));}
printf(" %f",x);
return 0;
}


## 註解

1. ^ 存档副本 (PDF). [2018-06-26]. （原始内容存档 (PDF)于2021-04-24）.
2. ^ 张宏伟，金光日，施吉林，董波 (编). 计算机科学计算 2013年第2版. 北京: 高等教育出版社. 2005: 138. ISBN 9787040365955.