当前位置:网站首页>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;
}
边栏推荐
- MySQL 巨坑:update 更新慎用影响行数做判断!!!
- 21. [STM32] I don't understand the I2C protocol. Dig deep into the sequence diagram to help you write the underlying driver
- Why should we learn mathematical modeling?
- Appium自动化测试基础 — APPium基础操作API(二)
- Bugku's Ping
- Detailed explanation of C language branch statements
- Quick completion guide for manipulator (IX): forward kinematics analysis
- OceanBase社区版之OBD方式部署方式本地安装
- 研发效能度量指标构成及效能度量方法论
- Summary of the second lesson
猜你喜欢
Appium automation test foundation - appium basic operation API (II)
Misc Basic test method and knowledge points of CTF
Appium自动化测试基础 — APPium基础操作API(一)
【 note 】 résoudre l'erreur de code IDE golang
vlunhub- BoredHackerBlog Social Network
Detailed explanation of C language branch statements
Appium automation test foundation - appium basic operation API (I)
lvgl 显示图片示例
Advanced level of static and extern
写单元测试的时候犯的错
随机推荐
Verilog realizes the calculation of the maximum common divisor and the minimum common multiple
Ionic Cordova project modification plug-in
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
DataArts Studio数据架构——数据标准介绍
Hongmeng system -- Analysis from the perspective of business
Appium自动化测试基础 — APPium基础操作API(二)
Advanced level of static and extern
Nine hours, nine people, nine doors problem solving Report
把 ”中台“ 的思想迁移到代码中去
Analytic hierarchy process of mathematical modeling (including Matlab code)
超分辨率技术在实时音视频领域的研究与实践
vant popup+其他组件的组合使用,及避坑指南
I spring and autumn blasting-2
项目sql中批量update的时候参数类型设置错误
数学建模之层次分析法(含MATLAB代码)
17.[STM32]仅用三根线带你驱动LCD1602液晶
vulnhub-Root_ this_ box
Transfer the idea of "Zhongtai" to the code
Dataarts studio data architecture - Introduction to data standards
I'm fat, huh