Average Error: 34.2 → 6.9
Time: 7.7s
Precision: binary64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \leq -3.0772718270963217 \cdot 10^{+137}:\\ \;\;\;\;\frac{1}{-1.5 \cdot \frac{a}{b}}\\ \mathbf{elif}\;b \leq -1.944440046579189 \cdot 10^{-259}:\\ \;\;\;\;\left(\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b\right) \cdot \frac{0.3333333333333333}{a}\\ \mathbf{elif}\;b \leq 1.6151502496309929 \cdot 10^{+106}:\\ \;\;\;\;\frac{1}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}}{c}}\\ \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 \leq -3.0772718270963217 \cdot 10^{+137}:\\
\;\;\;\;\frac{1}{-1.5 \cdot \frac{a}{b}}\\

\mathbf{elif}\;b \leq -1.944440046579189 \cdot 10^{-259}:\\
\;\;\;\;\left(\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b\right) \cdot \frac{0.3333333333333333}{a}\\

\mathbf{elif}\;b \leq 1.6151502496309929 \cdot 10^{+106}:\\
\;\;\;\;\frac{1}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}}{c}}\\

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

\end{array}
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
 :precision binary64
 (if (<= b -3.0772718270963217e+137)
   (/ 1.0 (* -1.5 (/ a b)))
   (if (<= b -1.944440046579189e-259)
     (* (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (/ 0.3333333333333333 a))
     (if (<= b 1.6151502496309929e+106)
       (/ 1.0 (/ (- (- b) (sqrt (- (* b b) (* (* a 3.0) c)))) c))
       (* -0.5 (/ c b))))))
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 tmp;
	if (b <= -3.0772718270963217e+137) {
		tmp = 1.0 / (-1.5 * (a / b));
	} else if (b <= -1.944440046579189e-259) {
		tmp = (sqrt((b * b) - ((a * 3.0) * c)) - b) * (0.3333333333333333 / a);
	} else if (b <= 1.6151502496309929e+106) {
		tmp = 1.0 / ((-b - sqrt((b * b) - ((a * 3.0) * c))) / c);
	} else {
		tmp = -0.5 * (c / b);
	}
	return tmp;
}

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 < -3.07727182709632172e137

    1. Initial program 57.2

      \[\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-+_binary64_246163.8

      \[\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. Simplified62.7

      \[\leadsto \frac{\frac{\color{blue}{\left(3 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied clear-num_binary64_248662.7

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

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

      \[\leadsto \frac{1}{1 \cdot \color{blue}{\left(-1.5 \cdot \frac{a}{b}\right)}}\]

    if -3.07727182709632172e137 < b < -1.94444004657918906e-259

    1. Initial program 8.4

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

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

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

    if -1.94444004657918906e-259 < b < 1.6151502496309929e106

    1. Initial program 31.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-+_binary64_246131.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. Simplified16.2

      \[\leadsto \frac{\frac{\color{blue}{\left(3 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied clear-num_binary64_248616.3

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

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

    if 1.6151502496309929e106 < b

    1. Initial program 59.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -3.0772718270963217 \cdot 10^{+137}:\\ \;\;\;\;\frac{1}{-1.5 \cdot \frac{a}{b}}\\ \mathbf{elif}\;b \leq -1.944440046579189 \cdot 10^{-259}:\\ \;\;\;\;\left(\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b\right) \cdot \frac{0.3333333333333333}{a}\\ \mathbf{elif}\;b \leq 1.6151502496309929 \cdot 10^{+106}:\\ \;\;\;\;\frac{1}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}}{c}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2020292 
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))