当前位置:网站首页>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都能作为初值,只有牛顿法收敛的函数才能使用。
边栏推荐
- Markdown editor syntax - setting of text color, size, font and background color (Reprint)
- The difference between extern and static
- ZABBIX custom monitoring items
- C programming language (2nd Edition) -- Reading Notes -- 1.3
- Caused by:org.gradle.api.internal. plugins . PluginApplicationException: Failed to apply plugin
- Longest ascending subsequence model acwing 272. longest common ascending subsequence
- Bus error problem of MMAP and its solution
- LeetCode-SQL练习题总结(MySQL实现)
- 1. Introduction and basic use of flume
- PAT(乙级)2022年夏季考试
猜你喜欢

求组合数 AcWing 889. 满足条件的01序列

N ¨UWA: Visual Synthesis Pre-training for Neural visUal World creAtionChenfei

Game theory acwing 891. Nim game

Moveit2 - 4. robot model and robot state

Properties file

Chinese remainder theorem acwing 204. strange way of expressing integers

When std:: bind meets this

Maker harmony OS application development training notes 01

日本福岛废堆安全监视协议会认可排海计划“安全”

The C programming language (2nd) -- Notes -- 1.6
随机推荐
求组合数 AcWing 886. 求组合数 II
Win10 vscode code code format setting and remote breakpoint debugging
Game theory acwing 894. Split Nim game
CTF crypto RSA getting started
Several banks adjusted the redemption rules of cash management financial products: the confirmation time limit of redemption changed from "t+0" to "t+1"
局域网SDN硬核技术内幕 23 展望未来——RDMA(上)
VSCode复制代码时去掉样式/语法高亮/代码高亮/黑色背景
开源flink有写holo的Datastream connector或者flink sql conn
Remember an experience of using canvas to make the banner streamer effect of Tencent cloud homepage
What is private traffic?
LAN SDN technology hard core insider 13 from LAN to Internet
记忆化搜索 AcWing 901. 滑雪
Could not load dynamic library ‘libcudnn.so.8‘;
容斥原理 AcWing 890. 能被整除的数
ZABBIX custom monitoring items
Maker Hongmeng application development training 04
第12章 泛型
LAN SDN hard core technology insider 23 looking forward to the future - RDMA (Part 1)
Chinese remainder theorem acwing 204. strange way of expressing integers
本地虚拟机初始化脚本