nthRoots method
Implementation
List<Complex> nthRoots(int n) {
if (n <= 0) {
throw ArgumentError('n must be a positive integer.');
}
final roots = <Complex>[];
final double rRoot = double.parse(
(math.pow(modulus, 1 / n).toDouble()).toStringAsPrecision(13),
);
for (int k = 0; k < n; k++) {
final angle = double.parse(
((theta1 + (2 * math.pi * k)) / n).toStringAsPrecision(13),
);
final real = double.parse(
(rRoot * math.cos(angle)).toStringAsPrecision(13),
);
final imag = double.parse(
(rRoot * math.sin(angle)).toStringAsPrecision(13),
);
roots.add(Complex._service(real, imag, rRoot, angle, angle));
}
return roots;
}