Average Error: 33.4 → 10.6
Time: 19.8s
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.14150427142127049 \cdot 10^{144}:\\ \;\;\;\;-0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 5.44225729163346047 \cdot 10^{-52}:\\ \;\;\;\;\frac{\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.14150427142127049 \cdot 10^{144}:\\
\;\;\;\;-0.66666666666666663 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \le 5.44225729163346047 \cdot 10^{-52}:\\
\;\;\;\;\frac{\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 ((double) (((double) (((double) -(b)) + ((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (3.0 * a)) * c)))))))) / ((double) (3.0 * a))));
}
double code(double a, double b, double c) {
	double VAR;
	if ((b <= -2.1415042714212705e+144)) {
		VAR = ((double) (-0.6666666666666666 * ((double) (b / a))));
	} else {
		double VAR_1;
		if ((b <= 5.4422572916334605e-52)) {
			VAR_1 = ((double) (((double) (((double) -(b)) + ((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (3.0 * a)) * c)))))))) / ((double) (3.0 * a))));
		} else {
			VAR_1 = ((double) (-0.5 * ((double) (c / b))));
		}
		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 3 regimes
  2. if b < -2.1415042714212705e+144

    1. Initial program 60.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 *-commutative60.3

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

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

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

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

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

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

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

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

    if -2.1415042714212705e+144 < b < 5.4422572916334605e-52

    1. Initial program 13.4

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

    if 5.4422572916334605e-52 < b

    1. Initial program 53.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.14150427142127049 \cdot 10^{144}:\\ \;\;\;\;-0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 5.44225729163346047 \cdot 10^{-52}:\\ \;\;\;\;\frac{\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 2020113 
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))