当前位置:网站首页>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;
}
边栏推荐
- 17. [stm32] use only three wires to drive LCD1602 LCD
- Interval DP (gravel consolidation)
- SQL injection sqllabs (basic challenges) 1-10
- 具有倍数关系的时钟切换
- Detailed explanation of C language branch statements
- This article takes you through the addition, deletion, modification and query of JS processing tree structure data
- 把 ”中台“ 的思想迁移到代码中去
- 记录一下树莓派搭建环境中遇到的坑。。。
- wyt 。。
- Array sorting num ranking merge in ascending order
猜你喜欢
[brief notes] solve the problem of IDE golang code red and error reporting
Data communication foundation - routing communication between VLANs
SQL injection sqllabs (basic challenges) 11-20
一文搞定vscode编写go程序
Appium automation test foundation - appium basic operation API (I)
【网易云信】超分辨率技术在实时音视频领域的研究与实践
Number protection AXB function! (essence)
RepLKNet:不是大卷积不好,而是卷积不够大,31x31卷积了解一下 | CVPR 2022
I spring web upload
Intelligent metal detector based on openharmony
随机推荐
Virtual base class (a little difficult)
Interval DP (gravel consolidation)
Data communication foundation - routing communication between VLANs
Quick completion guide for manipulator (IX): forward kinematics analysis
MySQL overview
JS topic - console log()
把 ”中台“ 的思想迁移到代码中去
Bugku's eyes are not real
Appium自动化测试基础 — APPium基础操作API(一)
Appium automation test foundation - appium basic operation API (II)
2.3 learning content
obj集合转为实体集合
五种常见的咨询公司谈判策略以及如何维护自己的利益
OSI 七层模型
CSRF, XSS science popularization and defense
Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
Clock switching with multiple relationship
Aike AI frontier promotion (7.5)
Memo 00
【简记】解决IDE golang 代码飘红报错