solutions method
Finds the roots (the solutions) of the associated P(x) = 0 equation.
Implementation
@override
List<Complex> solutions() {
final fb = b / a;
final fc = c / a;
final fd = d / a;
final fe = e / a;
final q1 = (fc * fc) -
(fb * fd * const Complex.fromReal(3)) +
(fe * const Complex.fromReal(12));
final q2 = (fc.pow(3) * const Complex.fromReal(2)) -
(fb * fc * fd * const Complex.fromReal(9)) +
(fd.pow(2) * const Complex.fromReal(27)) +
(fb.pow(2) * fe * const Complex.fromReal(27)) -
(fc * fe * const Complex.fromReal(72));
final q3 = (fb * fc * const Complex.fromReal(8)) -
(fd * const Complex.fromReal(16)) -
(fb.pow(3) * const Complex.fromReal(2));
final q4 = (fb.pow(2) * const Complex.fromReal(3)) -
(fc * const Complex.fromReal(8));
var temp = (q2 * q2 / const Complex.fromReal(4)) - (q1.pow(3));
final q5 = (temp.sqrt() + (q2 / const Complex.fromReal(2))).pow(1.0 / 3.0);
final q6 = ((q1 / q5) + q5) / const Complex.fromReal(3);
temp = (q4 / const Complex.fromReal(12)) + q6;
final q7 = temp.sqrt() * const Complex.fromReal(2);
temp = ((q4 * const Complex.fromReal(4)) / const Complex.fromReal(6)) -
(q6 * const Complex.fromReal(4)) -
(q3 / q7);
final solutions = [
(fb.negate - q7 - temp.sqrt()) / const Complex.fromReal(4),
(fb.negate - q7 + temp.sqrt()) / const Complex.fromReal(4),
];
temp = ((q4 * const Complex.fromReal(4)) / const Complex.fromReal(6)) -
(q6 * const Complex.fromReal(4)) +
(q3 / q7);
solutions
..add((fb.negate + q7 - temp.sqrt()) / const Complex.fromReal(4))
..add((fb.negate + q7 + temp.sqrt()) / const Complex.fromReal(4));
return solutions;
}