Function nthRoots #
Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation “x^root = A”. This function returns an array of Complex values. Note that currently the precision of Complex numbers are limited to the precision of a 64-bit IEEE floating point, so even if the input is a BigNumber with greater precision, rounding to 64 bits will occur in computing the nth roots.
Syntax #
math.nthRoots(x)
math.nthRoots(x, root)
Parameters #
| Parameter | Type | Description |
|---|---|---|
x |
number | BigNumber | Fraction | Complex | Number to be rounded |
root |
number | Optional root, default value is 2 Default value: 2. |
Returns #
| Type | Description |
|---|---|
| number | BigNumber | Fraction | Complex | Returns the nth roots |
Throws #
Type | Description —- | ———–
Examples #
math.nthRoots(1) // returns [ {re: 1, im: 0}, {re: -1, im: 0} ]
math.nthRoots(1, 3)
// Complex [1, "-0.5+0.866025403784439i", "-0.5-0.866025403784439i"]
See also #
History #
| Version | Comment |
|---|---|
| v1.1 | Created |