Given the equation x ^ 3 + 2x ^ 2-3x-6 = 0, how many real roots can be found by dichotomy How to find the interval for such questions? Is it a trial one by one?

Given the equation x ^ 3 + 2x ^ 2-3x-6 = 0, how many real roots can be found by dichotomy How to find the interval for such questions? Is it a trial one by one?


If one root is - 2, let (x ^ 3 + 2x2-3x-6) / (x + 2) = (x ^ 2-3) get x ^ 3 + 2x2-3x-6 = (x + 2) (x ^ 2-3) = (x + 2) (x + radical 3) (x-radical 3) easily get three solutions of X - 2, - radical 3 and radical 3. The specific interval can be brought into the middle value



C program experiment: using dichotomy to find the root of the following equation 2x ^ 3-4x ^ 2 + 3x-6 = 0, the error is less than 0.00001


If you don't understand, you can explain it again. If you feel satisfied with the answer, please click adopt instead of close the question
#include
#include
double f(double x)
{
return 2*x*x*x-4*x*x+3*x-6;
}
main()
{
double left=-100,right=100,mid;
double ans;
do
{
mid=(left+right)/2;
ans=f(mid);
if(ans>0)
right=mid;
else if(ans1e-5);
printf("%lf\t%lf\n",mid,ans);
system("pause");
}



Write a program to find the root of equation 2x3-4x2 + 3x-6 = 0 between (- 10,10) by dichotomy
Tips:
Using do while statement
The calculation steps of dichotomy are as follows
Prepare to calculate the values f (a), f (b) of F (x) at the end of the rooted interval [a, b]
Dichotomize the value of F (x) at (a + b) / 2 in the interval f [(a + b) / 2]
If f [(a + b) / 2] = 0, it is the root, and the calculation process ends
Otherwise, test:
If f [(a + b) / 2] is different from F (a), then the root is in the interval [a, (a + b) / 2], and (a + b) / 2 replaces B;
If f [(a + b) / 2] has the same sign as f (a), then the root is in the interval [(a + b) / 2, b], and (a + b) / 2 is used to replace a;
Repeat steps 2 and 3 until the length of interval [a, b] is reduced to the allowable error range, and the midpoint (a + b) / 2 is the root
I did it. I don't know what went wrong
#include
#include
void main()
{
float a=-10.0;
float b=10.0;
float fc,fa,c;
c=(a+b)/2;
fc=2*pow(c,3)-4*pow(c,2)+3*c-6;
fa=2*pow(a,3)-4*pow(a,2)+3*a-6;
if (fc==0)
printf("the result is %lf.\n",c);
else
{
do
{
c=(a+b)/2;
if (fa*fc0.1e-6);
printf("the result is %lf.\n",c);
}
}


#include
using namespace std;
double p(double x)
{
return 2*x*x*x-4*x*x+3*x-6;
}
int main()
{
double a,b;
cin >> a >> b;
double fa = p(a),fb = p(b),fm;
do
{
fm = p((a+b)/2);
if(fm==0) break;
if(fm*fa