当前位置:网站首页>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;
}
边栏推荐
- Bugku alert
- Defining strict standards, Intel Evo 3.0 is accelerating the upgrading of the PC industry
- 19.[STM32]HC_ SR04 ultrasonic ranging_ Timer mode (OLED display)
- queryRunner. Query method
- RepLKNet:不是大卷积不好,而是卷积不够大,31x31卷积了解一下 | CVPR 2022
- 项目sql中批量update的时候参数类型设置错误
- Misc Basic test method and knowledge points of CTF
- episodic和batch的定义
- Definition of episodic and batch
- 具有倍数关系的时钟切换
猜你喜欢

Codasip adds verify safe startup function to risc-v processor series

JS knowledge points-01

Appium自动化测试基础 — APPium基础操作API(一)

First PR notes

【簡記】解决IDE golang 代碼飄紅報錯

wxml2canvas

CODING DevSecOps 助力金融企业跑出数字加速度

verilog实现计算最大公约数和最小公倍数

我们为什么要学习数学建模?

Quick completion guide for manipulator (IX): forward kinematics analysis
随机推荐
Data communication foundation - routing communication between VLANs
Data communication foundation ACL access control list
queryRunner. Query method
Data communication foundation - Ethernet port mirroring and link aggregation
视觉体验全面升级,豪威集团与英特尔Evo 3.0共同加速PC产业变革
How difficult is it to pass the certification of Intel Evo 3.0? Yilian technology tells you
CSRF, XSS science popularization and defense
复现Thinkphp 2.x 任意代码执行漏洞
OSI 七层模型
keep-alive
Detailed explanation of C language branch statements
sql中查询最近一条记录
16. [stm32] starting from the principle, I will show you the DS18B20 temperature sensor - four digit digital tube displays the temperature
Summary of the third class
Analytic hierarchy process of mathematical modeling (including Matlab code)
Why should we learn mathematical modeling?
obj解析为集合
Fundamentals of data communication - Principles of IP routing
I spring and autumn blasting-1
Misc Basic test method and knowledge points of CTF