作业帮 > 综合 > 作业

C语言用牛顿迭代法求方程(xe^x)-1=0在0.5附近的近似根,要求精确到10^-5

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/06/04 12:11:05
C语言用牛顿迭代法求方程(xe^x)-1=0在0.5附近的近似根,要求精确到10^-5
明天就考试了
C语言用牛顿迭代法求方程(xe^x)-1=0在0.5附近的近似根,要求精确到10^-5
#include
#include
int main(){
double diedai(double e,double x);
double e,x ;
x=0.5;
printf("输入系数e:") ;
scanf("%lf",&e) ;
x=diedai(e,x);
printf("x = %.2lf", x) ;
return 0;
}
double diedai(double e,double x){
while(abs(x*pow(e,x)-1)>pow(10,-5)){
x=x-(pow(e*x,x))/(pow(e,x)*(1+x));
}
return x;
}