Spaces:
Sleeping
Sleeping
Update app.cpp
Browse files32 unmodified lines33343536373839404130 unmodified lines7273747576777832 unmodified linesconst double epsilon = 1e-14;const double zero_threshold = 1e-10; // Threshold for considering a value as zero// Handle special case for a == 0 (quadratic)if (std::abs(a) < epsilon) {CubicRoots roots;// For a quadratic equation: bz^2 + cz + d = 0if (std::abs(b) < epsilon) { // Linear equation or constantif (std::abs(c) < epsilon) { // Constant - no finite roots30 unmodified lines// Handle special case when d is zero - one root is zeroif (std::abs(d) < epsilon) {// Factor out z: z(az^2 + bz + c) = 0CubicRoots roots;roots.root1 = std::complex<double>(0.0, 0.0); // One root is exactly zero// Solve the quadratic: az^2 + bz + c = 032 unmodified lines333435363738394041424330 unmodified lines74757677787932 unmodified linesconst double epsilon = 1e-14;const double zero_threshold = 1e-10; // Threshold for considering a value as zero// Declare roots at the beginning of the function so it's in scope throughoutCubicRoots roots;// Handle special case for a == 0 (quadratic)if (std::abs(a) < epsilon) {// For a quadratic equation: bz^2 + cz + d = 0if (std::abs(b) < epsilon) { // Linear equation or constantif (std::abs(c) < epsilon) { // Constant - no finite roots30 unmodified lines// Handle special case when d is zero - one root is zeroif (std::abs(d) < epsilon) {// Factor out z: z(az^2 + bz + c) = 0roots.root1 = std::complex<double>(0.0, 0.0); // One root is exactly zero// Solve the quadratic: az^2 + bz + c = 0
app.cpp+3-2