python - Python 使用哪种算法来估计平方根值?

标签 python algorithm sqrt

我想知道 Python 使用哪种算法来估计平方根值?是牛顿的、巴比伦的还是其他的?

最佳答案

在 CPython 中,math.sqrt is implemented in terms of C/POSIX sqrt function ,所以唯一给出的答案是“无论 C/POSIX 做什么”。在具有汇编级平方根函数(例如 x86 的 fsqrt)的系统上,C 运行时可能会委托(delegate)给芯片,在这种情况下,您需要了解芯片详细信息才能知道它如何执行计算。

an approximate square root and a more complicated algorithm for math.isqrt如果你愿意看的话。我怀疑它与教科书方法不完全匹配,因为计算机的优化与人类优化手工数学的方式不匹配。

关于python - Python 使用哪种算法来估计平方根值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63759501/

相关文章:

algorithm - 计算可以放置在字符内的最大矩形数

c++ - 平方根和的比较

java - BigInteger Sqrt 函数不收敛

python - 为什么对稀疏矩阵求和会留下空维度?

c# - 简单的数学题 :

php - PHP 中的拓扑排序

c - 在 C 中使用 math.h sqrt 函数

python - 如何清除 Tkinter 上的页面

python - PIP 卸载不查看/usr/local

python - 有没有办法让 psycopg2 将点作为 python 元组返回?