当前位置:网站首页>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;
}
边栏推荐
- 【简记】解决IDE golang 代码飘红报错
- 21. [STM32] I don't understand the I2C protocol. Dig deep into the sequence diagram to help you write the underlying driver
- Memo 00
- Bugku alert
- vulnhub-Root_ this_ box
- Array sorting num ranking merge in ascending order
- 定义严苛标准,英特尔Evo 3.0正在加速PC产业升级
- 具有倍数关系的时钟切换
- Noi / 1.5 06: element maximum span value of integer sequence
- wyt 。。
猜你喜欢

Usage and usage instructions of JDBC connection pool

Data communication foundation smart_ Link_&_ Monitor_ Link

项目sql中批量update的时候参数类型设置错误

SQL injection sqllabs (basic challenges) 11-20

定义严苛标准,英特尔Evo 3.0正在加速PC产业升级

力扣今日题-729. 我的日程安排表 I

Example of lvgl display picture

Detailed explanation of C language branch statements

Clock switching with multiple relationship

Intelligent metal detector based on openharmony
随机推荐
lv_font_conv离线转换
Ionic Cordova project modification plug-in
Maximum common subsequence
修改pyunit_time使得其支持‘xx~xx月’的时间文本
【简记】解决IDE golang 代码飘红报错
Explanation report of the explosion
20.[STM32]利用超声波模块和舵机实现智能垃圾桶功能
F. Min cost string problem solving Report
obj集合转为实体集合
Nine hours, nine people, nine doors problem solving Report
2.3 learning content
obj解析为集合
机械臂速成小指南(九):正运动学分析
Bugku's Eval
MySQL overview
Data communication foundation - routing communication between VLANs
MySQL5.7的JSON基本操作
如何将 DevSecOps 引入企业?
vulnhub-Root_ this_ box
16.[STM32]从原理开始带你了解DS18B20温度传感器-四位数码管显示温度