Find all complex nth roots
nthRoots(x, n) returns the complete set of nth roots of x. In the complex plane, a nonzero value has n roots arranged evenly around a circle.
Why all roots matter
nthRoots(1, 3) includes 1 and two complex cube roots of unity. This is useful in polynomial equations, signal analysis, and complex geometry. Use nthRoot when only the principal root is wanted, and pow to check each root.
Caveats
n should be a positive integer. Results may include complex values even when x is real, so use re, im, or abs to inspect them. Numerical comparisons should tolerate small rounding differences.