当前位置:网站首页>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;
}
边栏推荐
- Misc Basic test method and knowledge points of CTF
- 写单元测试的时候犯的错
- swiper. JS to achieve barrage effect
- SQL Server learning notes
- Usage and usage instructions of JDBC connection pool
- OSI 七层模型
- Virtual base class (a little difficult)
- Fundamentals of data communication - Principles of IP routing
- Explanation report of the explosion
- Bubble sort, insert sort
猜你喜欢

Advanced level of static and extern

OceanBase社区版之OBD方式部署方式本地安装

Explanation report of the explosion

Summary of the third class
![19.[STM32]HC_SR04超声波测距_定时器方式(OLED显示)](/img/fe/8f59db28823290da8e9280df06673d.jpg)
19.[STM32]HC_SR04超声波测距_定时器方式(OLED显示)

通过的英特尔Evo 3.0整机认证到底有多难?忆联科技告诉你

写单元测试的时候犯的错

OSI 七层模型

Information collection of penetration test
![[brief notes] solve the problem of IDE golang code red and error reporting](/img/b6/0b2ea06eb5fbe651ff9247b109fa15.png)
[brief notes] solve the problem of IDE golang code red and error reporting
随机推荐
数学建模之层次分析法(含MATLAB代码)
Basic JSON operations of MySQL 5.7
Noi / 1.4 07: collect bottle caps to win awards
Bugku alert
This article takes you through the addition, deletion, modification and query of JS processing tree structure data
I include of spring and Autumn
【 note 】 résoudre l'erreur de code IDE golang
Modify PyUnit_ Time makes it support the time text of 'xx~xx months'
Bubble sort, insert sort
Why should we learn mathematical modeling?
Usage and usage instructions of JDBC connection pool
MySQL table field adjustment
Six common transaction solutions, you sing, I come on stage (no best, only better)
Data communication foundation - route republication
具有倍数关系的时钟切换
DataArts Studio数据架构——数据标准介绍
Record the pits encountered in the raspberry pie construction environment...
16.[STM32]从原理开始带你了解DS18B20温度传感器-四位数码管显示温度
vulnhub-Root_ this_ box
SQL Server learning notes