当前位置:网站首页>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;
}
边栏推荐
- The computer is busy, and the update is a little slow
- vant popup+其他组件的组合使用,及避坑指南
- The difference between SQL Server char nchar varchar and nvarchar
- 记录一下树莓派搭建环境中遇到的坑。。。
- Bugku alert
- Reproduce ThinkPHP 2 X Arbitrary Code Execution Vulnerability
- 【簡記】解决IDE golang 代碼飄紅報錯
- 16.[STM32]从原理开始带你了解DS18B20温度传感器-四位数码管显示温度
- Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
- 17. [stm32] use only three wires to drive LCD1602 LCD
猜你喜欢

Example project: simple hexapod Walker
![16. [stm32] starting from the principle, I will show you the DS18B20 temperature sensor - four digit digital tube displays the temperature](/img/9f/c91904b6b1d3a1e85c0b50e43972e5.jpg)
16. [stm32] starting from the principle, I will show you the DS18B20 temperature sensor - four digit digital tube displays the temperature

Transfer the idea of "Zhongtai" to the code

【简记】解决IDE golang 代码飘红报错

lv_ font_ Conv offline conversion

Data communication foundation NAT network address translation

Summary of the third class

vlunhub- BoredHackerBlog Social Network

示例项目:简单的六足步行者

Object. defineProperty() - VS - new Proxy()
随机推荐
SQL injection sqllabs (basic challenges) 11-20
ICML 2022 | explore the best architecture and training method of language model
Bugku's eyes are not real
Basic JSON operations of MySQL 5.7
Transfer the idea of "Zhongtai" to the code
Bugku cyberpunk
写单元测试的时候犯的错
Data communication foundation - routing communication between VLANs
D-snow halo solution
Bugku's Ping
开发中Boolean类型使用遇到的坑
lvgl 显示图片示例
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
基于OpenHarmony的智能金属探测器
wxml2canvas
18.[STM32]读取DS18B20温度传感器的ROM并实现多点测量温度
CODING DevSecOps 助力金融企业跑出数字加速度
Object. defineProperty() - VS - new Proxy()
F. Min cost string problem solving Report
Lesson 4 knowledge summary