当前位置:网站首页>Newton-Raphson迭代法
Newton-Raphson迭代法
2022-07-27 10:59:00 【char~lie】
历史
牛顿法最初由艾萨克·牛顿在《流数法》(Method of Fluxions,1671年完成,在牛顿死后的1736年公开发表)。约瑟夫·拉弗森也曾于1690年在Analysis Aequationum中提出此方法。
算法
比如要计算a的大于0的平方根(a>0),可以先定义 f ( x ) = x 2 − 5 f(x) = x^2-5 f(x)=x2−5
先取一个接近真实解的值比如2,记为x0然后就一直按照下面的递推公式计算xn: x n + 1 = x n − f ( x n ) f ′ ( x n ) x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)} xn+1=xn−f′(xn)f(xn)
比如用C语言可以这样写:
double eps=1e-10;
double x1=2,x0=2;
do{
x1 = x0-(pow(x0,2)-5)/(2*x0);
x0=x1;
}while((x0-sqrt(5))>eps||(x0-sqrt(5))<(-eps));//这里不能用abs函数,因为abs返回的是整形
printf("x=%.10f",x0-sqrt(5);
结果如下:
限制条件
并不是所有函数都可以用这个方法求解,也不是所有x0都能作为初值,只有牛顿法收敛的函数才能使用。
边栏推荐
- The C programming language 2nd -- Notes -- 6.7
- Tensorflow tensor operation function set
- 求组合数 AcWing 888. 求组合数 IV
- pytorch和tensorflow一样展示summary
- LeetCode 01: T1. 两数之和 ; T1108. IP 地址无效化 ; T344. 反转字符串
- Error while unzipping file in win10: unable to create symbolic link. You may need to run WinRAR with administrator privileges. The client does not have the required privileges
- Maker Hongmeng application development training 04
- USB 网卡驱动数据流
- 高斯消元 AcWing 883. 高斯消元解线性方程组
- LAN SDN technology hard core insider 12 cloud CP's daily love - hardware vxlan forwarding plane
猜你喜欢

博弈论 AcWing 891. Nim游戏

Memory search acwing 901. Skiing

Kepserver configuration

Find the combination number acwing 887. find the combination number III

Could not load dynamic library ‘libcudnn.so.8‘;

Find the combination number acwing 888. find the combination number IV

Digital triangle model acwing 1015. Picking flowers

Maker Hongmeng application development training 04

TapNet: Multivariate Time Series Classification with Attentional Prototypical Network

Error encountered in adding quick open option to right-click menu:
随机推荐
WGet warning: unable to verify
Solutions to errors in tensorflow operation
Redis simple to use
origin如何作一张图中多张子图是柱状图(或其他图)
Summary of C language knowledge involved in learning STM32F103 (link only)
求组合数 AcWing 888. 求组合数 IV
局域网SDN技术硬核内幕 11 云网融合CP的关键——层次化端口绑定
C custom set
Stack acwing 3302. Expression evaluation
Maker harmony OS application development training notes 01
Local virtual machine initialization script
剑指 Offer 笔记: T39. 数组中出现次数超过一半的数字
C programming language (2nd Edition) -- Reading Notes -- 1.4
Codeforces round #664C
局域网SDN硬核技术内幕 23 展望未来——RDMA(上)
Japan Fukushima waste dump safety monitoring agreement will recognize the "safety" of the sea discharge plan
剑指 Offer 笔记: T53 - II. 0~n-1 中缺失的数字
Tree DP acwing 285. dance without boss
Open source Flink has datastream connector written with holo or Flink SQL Conn
Digital triangle model acwing 1027. Grid retrieval