当前位置:网站首页>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;
}
边栏推荐
- obj集合转为实体集合
- queryRunner. Query method
- 助力数字经济发展,夯实数字人才底座—数字人才大赛在昆成功举办
- I spring and autumn blasting-2
- MySQL overview
- Object. defineProperty() - VS - new Proxy()
- Modify PyUnit_ Time makes it support the time text of 'xx~xx months'
- Arduino controls a tiny hexapod 3D printing robot
- Data communication foundation ACL access control list
- obj解析为集合
猜你喜欢

RepLKNet:不是大卷积不好,而是卷积不够大,31x31卷积了解一下 | CVPR 2022

CSRF, XSS science popularization and defense

JS knowledge points-01

Bugku's Eval

MySQL overview

Data communication foundation - Ethernet port mirroring and link aggregation

Good article inventory

How difficult is it to pass the certification of Intel Evo 3.0? Yilian technology tells you

SQL injection sqllabs (basic challenges) 1-10

Li Kou today's question -729 My schedule I
随机推荐
Ionic Cordova project modification plug-in
视觉体验全面升级,豪威集团与英特尔Evo 3.0共同加速PC产业变革
wyt 。。
Maximum common subsequence
Dataarts studio data architecture - Introduction to data standards
力扣今日题-729. 我的日程安排表 I
16. [stm32] starting from the principle, I will show you the DS18B20 temperature sensor - four digit digital tube displays the temperature
Appium automation test foundation - appium basic operation API (II)
Arduino控制微小的六足3D打印机器人
【簡記】解决IDE golang 代碼飄紅報錯
Data communication foundation ACL access control list
Nine hours, nine people, nine doors problem solving Report
vant tabbar遮挡内容的解决方式
MySQL 巨坑:update 更新慎用影响行数做判断!!!
CSDN I'm coming
Coding devsecops helps financial enterprises run out of digital acceleration
Appium自动化测试基础 — APPium基础操作API(一)
OSI seven layer model
Appium automation test foundation - appium basic operation API (I)
Clock switching with multiple relationship