当前位置:网站首页>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
边栏推荐
- “Hello IC World”
- 数字电路基础(五)算术运算电路
- msf生成payload大全
- MySQL learning notes (stage 1)
- Detailed explanation of network foundation
- 函数:求方程的根
- 《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
- How to understand the difference between technical thinking and business thinking in Bi?
- The most popular colloquial system explains the base of numbers
- High concurrency programming series: 6 steps of JVM performance tuning and detailed explanation of key tuning parameters
猜你喜欢

链队实现(C语言)

Statistics 8th Edition Jia Junping Chapter XIII Summary of knowledge points of time series analysis and prediction and answers to exercises after class

Hackmyvm target series (1) -webmaster

Low income from doing we media? 90% of people make mistakes in these three points

Ucos-iii learning records (11) - task management

网络基础详解

Record once, modify password logic vulnerability actual combat

servlet中 servlet context与 session与 request三个对象的常用方法和存放数据的作用域。

Interview Essentials: what is the mysterious framework asking?

Network layer - simple ARP disconnection
随机推荐
记一次api接口SQL注入实战
Binary search tree concept
网络基础详解
JDBC看这篇就够了
外网打点(信息收集)
《统计学》第八版贾俊平第十三章时间序列分析和预测知识点总结及课后习题答案
JVM memory model concept
Statistics 8th Edition Jia Junping Chapter 10 summary of knowledge points of analysis of variance and answers to exercises after class
循环队列(C语言)
sqqyw(淡然点图标系统)漏洞复现和74cms漏洞复现
JDBC transactions, batch processing, and connection pooling (super detailed)
Circular queue (C language)
SystemVerilog discusses loop loop structure and built-in loop variable I
An unhandled exception occurred when C connected to SQL Server: system Argumentexception: "keyword not supported:" integrated
JDBC事务、批处理以及连接池(超详细)
Captcha killer verification code identification plug-in
《统计学》第八版贾俊平第十章方差分析知识点总结及课后习题答案
Attack and defense world misc practice area (GIF lift table ext3)
C language file operation
Statistics 8th Edition Jia Junping Chapter 12 summary of knowledge points of multiple linear regression and answers to exercises after class