/*关键是迭代公式要收敛*/
#include<stdio.h>
#include<math.h>
double f(double x,double Y)
{
return 8*pow(x,4)-7*pow(x,3)+2*x*x+3*x+6-Y;
}
double f_(double x)
{
return 32*pow(x,3)-21*x*x+4*x+3;
}
int main()
{  
int T;double x1,x2,Y;
scanf("%d",&T);
while(T--)
{   
    scanf("%lf",&Y);
    if(f(0,Y)>0||f(100,Y)<0)
	{
		printf("No solution!\n");
		continue;
	}
    x1=0;x2=100;
    while(fabs(x1-x2)>1e-10)
    {
    x1=x2;
    x2=x1-f(x1,Y)/f_(x1); 
    }
    printf("%.4lf\n",x2);   
}
}  
        

  

相关文章:

  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2022-02-14
  • 2021-08-24
相关资源
相似解决方案