当前位置:网站首页>Find the root of the following equation by chord cutting method, f (x) =x^3-5x^2+16x-80=0
Find the root of the following equation by chord cutting method, f (x) =x^3-5x^2+16x-80=0
2022-07-05 15:54:00 【Lin Yi Lin Yi】
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
double f(double); // Represents the abscissa of the intersection x Function of
double xpoint(double,double); // seek (x1,f(x1)),(x2,f(x2)) The connection between x The intersection of the axes (x,0) Coordinates of
double root(double,double); // Find interval (x1,x2) The real root of
// perform root To be called xpoint function , perform xpoint To be called f function
int main()
{
double x1,x2,f1,f2,x;
do{
cout<<" Please enter the variable x1,x2 Value :";
cin>>x1>>x2;
f1=f(x1);
f2=f(x2);
}while(f1*f2>=0); // When x1 and x2 The cycle of different signs ends
x=root(x1,x2); // Root of solving equation
cout<<setiosflags(ios::fixed)<<setprecision(7); // Specify the output 7 Decimal place
cout<<" The root of the equation :"<<x<<endl;
return 0;
}
double f(double x) // Calculation f(x)
{
double y;
y=x*x*x-5*x*x+16*x-80;
return y;
}
double xpoint(double x1,double x2)
{
double y;
y=(x1*f(x2)-x2*f(x1))/(f(x2)-f(x1)); // call f function
return y;
}
double root(double x1,double x2)
{
double x,y,y1;
y1=f(x1);
do{
x=xpoint(x1,x2);
y=f(x);
if(y*y1>0){
y1=y;
x1=x;
}
else
x2=x;
}while(fabs(y)>=0.00001);
return x;
}
边栏推荐
- Example project: simple hexapod Walker
- vant popup+其他组件的组合使用,及避坑指南
- Li Kou today's question -729 My schedule I
- 16. [stm32] starting from the principle, I will show you the DS18B20 temperature sensor - four digit digital tube displays the temperature
- 异常com.alibaba.fastjson.JSONException: not match : - =
- 五种常见的咨询公司谈判策略以及如何维护自己的利益
- ionic cordova项目修改插件
- Virtual base class (a little difficult)
- SQL injection sqllabs (basic challenges) 11-20
- Codasip为RISC-V处理器系列增加Veridify安全启动功能
猜你喜欢

Data communication foundation ACL access control list

Information collection of penetration test

The OBD deployment mode of oceanbase Community Edition is installed locally

wxml2canvas

First PR notes

写单元测试的时候犯的错

SQL injection sqllabs (basic challenges) 11-20

Data communication foundation OSPF Foundation

Bugku alert

vulnhub-Root_ this_ box
随机推荐
【网易云信】超分辨率技术在实时音视频领域的研究与实践
MySQL table field adjustment
Data communication foundation NAT network address translation
episodic和batch的定义
项目sql中批量update的时候参数类型设置错误
Anti shake and throttling
助力数字经济发展,夯实数字人才底座—数字人才大赛在昆成功举办
I spring and autumn blasting-1
Basic JSON operations of MySQL 5.7
Misc Basic test method and knowledge points of CTF
Six common transaction solutions, you sing, I come on stage (no best, only better)
CSDN I'm coming
Analytic hierarchy process of mathematical modeling (including Matlab code)
把 ”中台“ 的思想迁移到代码中去
Data communication foundation - dynamic routing protocol rip
CODING DevSecOps 助力金融企业跑出数字加速度
异常com.alibaba.fastjson.JSONException: not match : - =
Definition of episodic and batch
Value series solution report
OceanBase社区版之OBD方式部署方式本地安装