让我们通过 complex64 和 complex128 来探索一下 Go 内建的复数。对于立方根,牛顿法需要大量循环:
complex64
complex128
找到 2 的立方根,确保算法能够工作。在 math/cmplx 包中有 Pow 函数。
math/cmplx
{$ activeFileHint $}