计算e的近似值,求在数学上为什么这么算? 在线等
来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/06/26 03:38:57
计算e的近似值,求在数学上为什么这么算? 在线等
#include
main( )
{ double e =1.0, x=1.0, y, detax;
int i=1;
printf ("\n please enter a error:");
scanf ("%lf",&detax);
y =1/x;
while (y>=detax)
{ x=x *i;
y=1/x;
e=e+y;
++i;
}
printf ("%12.10lf ",e);
return 0;
}
算了, 知道了
#include
main( )
{ double e =1.0, x=1.0, y, detax;
int i=1;
printf ("\n please enter a error:");
scanf ("%lf",&detax);
y =1/x;
while (y>=detax)
{ x=x *i;
y=1/x;
e=e+y;
++i;
}
printf ("%12.10lf ",e);
return 0;
}
算了, 知道了
![计算e的近似值,求在数学上为什么这么算? 在线等](/uploads/image/z/3692822-14-2.jpg?t=%E8%AE%A1%E7%AE%97e%E7%9A%84%E8%BF%91%E4%BC%BC%E5%80%BC%2C%E6%B1%82%E5%9C%A8%E6%95%B0%E5%AD%A6%E4%B8%8A%E4%B8%BA%E4%BB%80%E4%B9%88%E8%BF%99%E4%B9%88%E7%AE%97%3F+%E5%9C%A8%E7%BA%BF%E7%AD%89)
while循环体执行之后就是1+1/2+1/3…………一直加到y小于detax,上述式子求极限就是e,所以detax很小的时候就可以求出e的近似值对吧.
lz我在做任务,虽然你已经知道了,还是采纳我吧,
lz我在做任务,虽然你已经知道了,还是采纳我吧,