Function nthRoots #

计算一个值的n次方根。正实数A的n次方根是方程“x^root = A”的正实数解。此函数返回一个复数数组。请注意,目前复数的精度仅限于64位IEEE浮点数的精度,因此即使输入是具有更高精度的BigNumber,在计算n次方根时也会发生舍入到64位。

Syntax #

math.nthRoots(x)
math.nthRoots(x, root)

Parameters #

Parameter Type Description
x number | BigNumber | Fraction | Complex 要取根的数字
number 可选的根,默认值为2 默认值: 2。

Returns #

Type Description
number | BigNumber | Fraction | Complex 返回n次方根

Throws #

Type | Description —- | ———–

Examples #

math.nthRoots(1)
// returns [
//   {re: 1, im: 0},
//   {re: -1, im: 0}
// ]
math.nthRoots(1, 3)
// returns [
//   { re: 1, im: 0 },
//   { re: -0.4999999999999998, im: 0.8660254037844387 },
//   { re: -0.5000000000000004, im: -0.8660254037844385 }
// ]

另请参阅 #

nthRoot, pow, sqrt

Fork me on GitHub