求x^3-15x^2+16x-80一个实根,下面程序怎么算不出来#include#includefloat f(float x){return ((x-5)*x-16)*x-80;}float xpoint(float x1,float x2){return (x1*f(x2)-x2*f(x1))/(f(x2)-f(x1));}float root(float x1,float x2){float x,y,y1;y1=f(x1);do{
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/08 06:16:36
![求x^3-15x^2+16x-80一个实根,下面程序怎么算不出来#include#includefloat f(float x){return ((x-5)*x-16)*x-80;}float xpoint(float x1,float x2){return (x1*f(x2)-x2*f(x1))/(f(x2)-f(x1));}float root(float x1,float x2){float x,y,y1;y1=f(x1);do{](/uploads/image/z/2701175-23-5.jpg?t=%E6%B1%82x%5E3-15x%5E2%2B16x-80%E4%B8%80%E4%B8%AA%E5%AE%9E%E6%A0%B9%2C%E4%B8%8B%E9%9D%A2%E7%A8%8B%E5%BA%8F%E6%80%8E%E4%B9%88%E7%AE%97%E4%B8%8D%E5%87%BA%E6%9D%A5%23include%23includefloat+f%28float+x%29%7Breturn+%28%28x-5%29%2Ax-16%29%2Ax-80%3B%7Dfloat+xpoint%28float+x1%2Cfloat+x2%29%7Breturn+%28x1%2Af%28x2%29-x2%2Af%28x1%29%29%2F%28f%28x2%29-f%28x1%29%29%3B%7Dfloat+root%28float+x1%2Cfloat+x2%29%7Bfloat+x%2Cy%2Cy1%3By1%3Df%28x1%29%3Bdo%7B)
求x^3-15x^2+16x-80一个实根,下面程序怎么算不出来#include#includefloat f(float x){return ((x-5)*x-16)*x-80;}float xpoint(float x1,float x2){return (x1*f(x2)-x2*f(x1))/(f(x2)-f(x1));}float root(float x1,float x2){float x,y,y1;y1=f(x1);do{
求x^3-15x^2+16x-80一个实根,下面程序怎么算不出来
#include
#include
float f(float x)
{
return ((x-5)*x-16)*x-80;
}
float xpoint(float x1,float x2)
{
return (x1*f(x2)-x2*f(x1))/(f(x2)-f(x1));
}
float root(float x1,float x2)
{
float 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;
}
void main()
{
float x,x1,x2,y1,y2;
do
{
scanf("%f,%f",&x1,&x2);
y1=f(x1);
y2=f(x2);
}while(y1*y2>0);
x=root(x1,x2);
printf("A root is %f\n",x);
getch();
}
是我最上面的函数表达式写错啦,本来应该是“-”号,所以程序里面的函数应该是对的,你看看如果按照“-”号来做我的程序又不有问题,要是没有的话你看看最后结果是多少,我需要结果!
求x^3-15x^2+16x-80一个实根,下面程序怎么算不出来#include#includefloat f(float x){return ((x-5)*x-16)*x-80;}float xpoint(float x1,float x2){return (x1*f(x2)-x2*f(x1))/(f(x2)-f(x1));}float root(float x1,float x2){float x,y,y1;y1=f(x1);do{
你的f函数的表达式写错了.应该是:
float f(float x)
{
return ((x-15)*x+16)*x-80;
}
我要是没有看错的话,你应该用的是牛顿弦切法吧?
如果是这样的话:x^3-15x^2+16x-80=0 那么,
X1=14.2716697265195
X2=0.364165136740241+2.3394218598286*i
X3=0.364165136740241-2.3394218598286*i
如果是这样的话:x^3-15x^2-16x-80=0 那么,
X1=16.2842317770781
X2=-0.64211588853906+2.12141818110309*i
X3=-0.64211588853906-2.12141818110309*i
如果是这样的话:x^3-5x^2+16x-80=0 那么,
X1=5
X2=4*i
X3=-4*i
如果是这样的话:x^3-5x^2-16x-80=0 那么,
X1=8.16146306754548
X2=-1.58073153377274+2.70248994139071*i
X3=-1.58073153377274-2.70248994139071*i