Average Error: 34.3 → 9.0
Time: 5.5s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -2.7863758169125638 \cdot 10^{138}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 2.5643996228054395 \cdot 10^{-134}:\\ \;\;\;\;\frac{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt[3]{3}}\\ \mathbf{elif}\;b \le 7.7470557689106299 \cdot 10^{72}:\\ \;\;\;\;\frac{\frac{0 + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -2.7863758169125638 \cdot 10^{138}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \le 2.5643996228054395 \cdot 10^{-134}:\\
\;\;\;\;\frac{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt[3]{3}}\\

\mathbf{elif}\;b \le 7.7470557689106299 \cdot 10^{72}:\\
\;\;\;\;\frac{\frac{0 + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\end{array}
double code(double a, double b, double c) {
	return ((-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a));
}
double code(double a, double b, double c) {
	double VAR;
	if ((b <= -2.7863758169125638e+138)) {
		VAR = ((0.5 * (c / b)) - (0.6666666666666666 * (b / a)));
	} else {
		double VAR_1;
		if ((b <= 2.5643996228054395e-134)) {
			VAR_1 = ((1.0 / (cbrt(3.0) * cbrt(3.0))) / ((a / (-b + sqrt(((b * b) - ((3.0 * a) * c))))) * cbrt(3.0)));
		} else {
			double VAR_2;
			if ((b <= 7.74705576891063e+72)) {
				VAR_2 = (((0.0 + (3.0 * (a * c))) / (-b - sqrt(((b * b) - ((3.0 * a) * c))))) / (3.0 * a));
			} else {
				VAR_2 = (-0.5 * (c / b));
			}
			VAR_1 = VAR_2;
		}
		VAR = VAR_1;
	}
	return VAR;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b < -2.7863758169125638e+138

    1. Initial program 58.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around -inf 3.0

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}}\]

    if -2.7863758169125638e+138 < b < 2.5643996228054395e-134

    1. Initial program 10.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied clear-num10.9

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity10.9

      \[\leadsto \frac{1}{\frac{3 \cdot a}{\color{blue}{1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}\]
    6. Applied times-frac10.9

      \[\leadsto \frac{1}{\color{blue}{\frac{3}{1} \cdot \frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}\]
    7. Simplified10.9

      \[\leadsto \frac{1}{\color{blue}{3} \cdot \frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}\]
    8. Using strategy rm
    9. Applied associate-/r*10.9

      \[\leadsto \color{blue}{\frac{\frac{1}{3}}{\frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}\]
    10. Using strategy rm
    11. Applied add-cube-cbrt10.9

      \[\leadsto \frac{\frac{1}{\color{blue}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}}{\frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}\]
    12. Applied *-un-lft-identity10.9

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot 1}}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}{\frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}\]
    13. Applied times-frac11.1

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \frac{1}{\sqrt[3]{3}}}}{\frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}\]
    14. Applied associate-/l*11.0

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\frac{\frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{\frac{1}{\sqrt[3]{3}}}}}\]
    15. Simplified10.9

      \[\leadsto \frac{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\color{blue}{\frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt[3]{3}}}\]

    if 2.5643996228054395e-134 < b < 7.74705576891063e+72

    1. Initial program 39.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+39.3

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    4. Simplified17.1

      \[\leadsto \frac{\frac{\color{blue}{0 + 3 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]

    if 7.74705576891063e+72 < b

    1. Initial program 58.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around inf 3.2

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification9.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.7863758169125638 \cdot 10^{138}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 2.5643996228054395 \cdot 10^{-134}:\\ \;\;\;\;\frac{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt[3]{3}}\\ \mathbf{elif}\;b \le 7.7470557689106299 \cdot 10^{72}:\\ \;\;\;\;\frac{\frac{0 + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2020078 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))