roots method
Computes the n-th roots of this complex number.
Implementation
List<Complex> roots(int n) {
if (n == 0) {
throw ArgumentError.value(n, 'n', 'Expected non-zero root');
}
final root = abs().pow(1 / n);
final phiBase = arg() / n;
final phiOffset = 2 * math.pi / n;
return List.generate(
n.abs(),
(i) => Complex.fromPolar(root, phiBase + i * phiOffset),
growable: false,
);
}