解方程x *x *x - 5.0 *x *x + 16.0 *x - 80.0 下面是程序,谁给我讲讲原理啊
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/10/01 22:07:24
解方程x *x *x - 5.0 *x *x + 16.0 *x - 80.0 下面是程序,谁给我讲讲原理啊
#include
#include
float f(float x)
{
float y;
y = x *x *x - 5.0 *x *x + 16.0 *x - 80.0;
return y;
}
float xpoint(float x1,float x2)
{
float y;
y = (x1 *f(x2) -x2 *f(x1))/(f(x2) -f(x1));
return y;
}
float root(float x1,float x2)
{
int i;
float x,x0,y,y1,y2;
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.0001);
return x;
}
int main(void)
{
float x1,x2,f1,f2,x;
do
{
printf("请输入x1,x2:");
scanf("%f,%f",&x1,&x2);
f1 = f(x1);
f2 = f(x2);
}while(f1 * f2 >=0);
x = root(x1,x2);
printf("方程的根为:x = %g\n",x);
getchar();
getchar();
}
y = (x1 *f(x2) -x2 *f(x1))/(f(x2) -f(x1));
所有语法都能看懂
#include
#include
float f(float x)
{
float y;
y = x *x *x - 5.0 *x *x + 16.0 *x - 80.0;
return y;
}
float xpoint(float x1,float x2)
{
float y;
y = (x1 *f(x2) -x2 *f(x1))/(f(x2) -f(x1));
return y;
}
float root(float x1,float x2)
{
int i;
float x,x0,y,y1,y2;
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.0001);
return x;
}
int main(void)
{
float x1,x2,f1,f2,x;
do
{
printf("请输入x1,x2:");
scanf("%f,%f",&x1,&x2);
f1 = f(x1);
f2 = f(x2);
}while(f1 * f2 >=0);
x = root(x1,x2);
printf("方程的根为:x = %g\n",x);
getchar();
getchar();
}
y = (x1 *f(x2) -x2 *f(x1))/(f(x2) -f(x1));
所有语法都能看懂
就是先随便取2个x的值(x1,x2),算出y的值(y1,y2),如果y1*y2
解方程x *x *x - 5.0 *x *x + 16.0 *x - 80.0 下面是程序,谁给我讲讲原理啊
(X-21):(4X/5+21)=2:3请问这个方程怎么解,最好能给我讲讲
谁教我怎么解方程啊?用牛顿迭代法求下面方程的1.5附近的根.2*x*x*x-4*x*x+3*x-6 这个方程的值不就是x
待定系数法分解因式,x^4-2x^3-27x^2-44x+7 主要给讲讲对应完之后,系数的方程怎么解
(x
|x|
x
,x
解方程4.5x + x
方程x(x-2)=x的解是
解方程(x-2004)/(x-2005)-(x-2005)/(x-2006)=(x-2007)/(x-2008)-(x-
解方程x/(x-2)=2x/(x-3)+(1-x)/(x-5x+6)