当前位置:网站首页>Function: find the root of the equation by Newton iterative method
Function: find the root of the equation by Newton iterative method
2022-07-06 14:35:00 【|Light|】
requirement
Find the root of the equation by Newton iterative method . The equation is ax3+bx2+cx+d=0, The coefficient is entered by the user , seek x stay 1 Nearby roots .
,
Code
#include<math.h>
#define EPSILON 1E-6
/* * function f(x)=a*x**3+b*x**2+c*x+d */
double f(double a,double b,double c, double d, double x)
{
double t;
t=a*x*x*x+b*x*x+c*x+d;
return t;
}
/* * function f(x)=a*x**3+b*x**2+c*x+d The derivative of */
double derivatives(double a,double b,double c, double d, double x)
{
double t;
t=3*a*x*x+2*b*x+c;
return t;
}
/* * In this function, the equation is solved by iterative method in 1 Nearby roots , You can call the above f Functions and f The derivative of */
double fun(double a,double b,double c,double d)
{
double x1,x=1;
do
{
x1=x;
x = x1 - f(a,b,c,d,x)/derivatives(a,b,c,d,x);
}
while(fabs(x1-x)>=1e-3);
return x;
}
test
Test input
10 5 -11 -3.28351
Output
Where is the equation 1 The root nearby is 0.97
边栏推荐
- Data mining - a discussion on sample imbalance in classification problems
- Circular queue (C language)
- 1.支付系统
- Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
- Intranet information collection of Intranet penetration (4)
- 内网渗透之内网信息收集(五)
- MySQL interview questions (4)
- MySQL中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?
- 2022华中杯数学建模思路
- Overview of LNMP architecture and construction of related services
猜你喜欢
Ucos-iii learning records (11) - task management
攻防世界MISC练习区(gif 掀桌子 ext3 )
数据库多表链接的查询方式
图书管理系统
Attack and defense world misc practice area (simplerar, base64stego, no matter how high your Kung Fu is, you are afraid of kitchen knives)
移植蜂鸟E203内核至达芬奇pro35T【集创芯来RISC-V杯】(一)
Based on authorized access, cross host, and permission allocation under sqlserver
Internet Management (Information Collection)
《统计学》第八版贾俊平第十一章一元线性回归知识点总结及课后习题答案
网络基础之路由详解
随机推荐
Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class
【指针】查找最大的字符串
【指针】八进制转换为十进制
Statistics, 8th Edition, Jia Junping, Chapter 11 summary of knowledge points of univariate linear regression and answers to exercises after class
Uibutton status exploration and customization
MySQL learning notes (stage 1)
Intranet information collection of Intranet penetration (2)
Detailed explanation of network foundation routing
Internet Management (Information Collection)
安全面试之XSS(跨站脚本攻击)
Attack and defense world misc practice area (GIF lift table ext3)
How to earn the first pot of gold in CSDN (we are all creators)
Circular queue (C language)
Wu Enda's latest interview! Data centric reasons
Solutions to common problems in database development such as MySQL
Pointeurs: maximum, minimum et moyenne
【指针】删除字符串s中的所有空格
WEB漏洞-文件操作之文件包含漏洞
DVWA (5th week)
《统计学》第八版贾俊平第十章方差分析知识点总结及课后习题答案