当前位置:网站首页>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
边栏推荐
- 《统计学》第八版贾俊平第八章假设检验知识点总结及课后习题答案
- 《统计学》第八版贾俊平第十一章一元线性回归知识点总结及课后习题答案
- 《统计学》第八版贾俊平第五章概率与概率分布
- 《统计学》第八版贾俊平第三章课后习题及答案总结
- 循环队列(C语言)
- 安全面试之XSS(跨站脚本攻击)
- Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class
- {1,2,3,2,5}查重问题
- 《统计学》第八版贾俊平第一章课后习题及答案总结
- 浙大版《C语言程序设计实验与习题指导(第3版)》题目集
猜你喜欢
Realize applet payment function with applet cloud development (including source code)
《統計學》第八版賈俊平第七章知識點總結及課後習題答案
Web vulnerability - File Inclusion Vulnerability of file operation
Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
Statistics, 8th Edition, Jia Junping, Chapter 6 Summary of knowledge points of statistics and sampling distribution and answers to exercises after class
《统计学》第八版贾俊平第十二章多元线性回归知识点总结及课后习题答案
《统计学》第八版贾俊平第四章总结及课后习题答案
图书管理系统
[paper reproduction] cyclegan (based on pytorch framework) {unfinished}
How to turn wechat applet into uniapp
随机推荐
JDBC transactions, batch processing, and connection pooling (super detailed)
函数:字符串反序存放
Build domain environment (win)
msf生成payload大全
Attack and defense world misc practice area (simplerar, base64stego, no matter how high your Kung Fu is, you are afraid of kitchen knives)
New version of postman flows [introductory teaching chapter 01 send request]
链队实现(C语言)
Hackmyvm target series (2) -warrior
High concurrency programming series: 6 steps of JVM performance tuning and detailed explanation of key tuning parameters
JDBC read this article is enough
Sword finger offer 23 - print binary tree from top to bottom
[issue 18] share a Netease go experience
2022华中杯数学建模思路
XSS之冷门事件
Markdown font color editing teaching
《统计学》第八版贾俊平第十章方差分析知识点总结及课后习题答案
Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
Statistics 8th Edition Jia Junping Chapter 14 summary of index knowledge points and answers to exercises after class
Intranet information collection of Intranet penetration (5)