@@ -52,20 +52,20 @@ std::array<std::complex<long double>, 2> quadraticEquation(long double a,
52
52
long double discriminant = b * b - 4 * a * c;
53
53
std::array<std::complex<long double >, 2 > solutions{0 , 0 };
54
54
55
- // Complex root (discriminant < 0)
56
- // Note that the left term (-b / 2a) is always real. The imaginary part
57
- // appears when b^2 - 4ac < 0, so sqrt(b^2 - 4ac) has no real roots. So, the
58
- // imaginary component is i * (+/-)sqrt(abs(b^2 - 4ac)) / 2a.
55
+ // / Complex root (discriminant < 0)
56
+ // / Note that the left term (-b / 2a) is always real. The imaginary part
57
+ // / appears when b^2 - 4ac < 0, so sqrt(b^2 - 4ac) has no real roots. So,
58
+ // / the imaginary component is i * (+/-)sqrt(abs(b^2 - 4ac)) / 2a.
59
59
if (discriminant < 0 ) {
60
- // Since b^2 - 4ac is < 0, for faster computation, -discriminant is
61
- // enough to make it positive.
60
+ // / Since b^2 - 4ac is < 0, for faster computation, -discriminant is
61
+ // / enough to make it positive.
62
62
solutions[0 ] = std::complex<long double >{
63
63
-b * 0.5 / a, -std::sqrt (-discriminant) * 0.5 / a};
64
64
solutions[1 ] = std::complex<long double >{
65
65
-b * 0.5 / a, std::sqrt (-discriminant) * 0.5 / a};
66
66
} else {
67
- // Since discriminant > 0, there are only real roots. Therefore,
68
- // imaginary component = 0.
67
+ // / Since discriminant > 0, there are only real roots. Therefore,
68
+ // / imaginary component = 0.
69
69
solutions[0 ] = std::complex<long double >{
70
70
(-b - std::sqrt (discriminant)) * 0.5 / a, 0 };
71
71
solutions[1 ] = std::complex<long double >{
0 commit comments