•计算一个数字的立方根,不使用库函数

详细描述:

•接口说明

原型:

public static double getCubeRoot(double input)

输入:double 待求解参数

返回值:double  输入参数的立方根,保留一位小数

牛顿迭代法:之前看到很多人说这种方法,光看代码还是不能理解什么意思,后来看了这篇博客理解了https://blog.csdn.net/sunbobosun56801/article/details/78088085

number=float(raw_input().strip())
#初始化一个估计解
t
=5 while abs(t*t*t-number)>0.01: t=t-(t*t*t*0.1-number*0.1)/(3.0*t*t) print "%.1f" % t

 

相关文章:

  • 2021-11-16
  • 2021-08-10
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
  • 2021-11-24
  • 2021-08-27
猜你喜欢
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2021-09-01
  • 2021-08-13
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案