Average Error: 44.3 → 11.0
Time: 6.2s
Precision: binary64
\[1.1102230246251565 \cdot 10^{-16} < a \land a < 9007199254740992 \land 1.1102230246251565 \cdot 10^{-16} < b \land b < 9007199254740992 \land 1.1102230246251565 \cdot 10^{-16} < c \land c < 9007199254740992\]
\[\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 0.008923916934394698:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) - b \cdot b}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(a \cdot -1.5\right) \cdot \frac{c}{b}}{3 \cdot a}\\ \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 0.008923916934394698:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) - b \cdot b}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot -1.5\right) \cdot \frac{c}{b}}{3 \cdot a}\\

\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 0.008923916934394698)
   (/
    (/
     (- (- (* b b) (* (* 3.0 a) c)) (* b b))
     (+ b (sqrt (- (* b b) (* (* 3.0 a) c)))))
    (* 3.0 a))
   (/ (* (* a -1.5) (/ c b)) (* 3.0 a))))
double code(double a, double b, double c) {
	return (((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 tmp;
	if ((b <= 0.008923916934394698)) {
		tmp = ((((double) (((double) (((double) (b * b)) - ((double) (((double) (3.0 * a)) * c)))) - ((double) (b * b)))) / ((double) (b + ((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (3.0 * a)) * c))))))))) / ((double) (3.0 * a)));
	} else {
		tmp = (((double) (((double) (a * -1.5)) * (c / b))) / ((double) (3.0 * a)));
	}
	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 2 regimes
  2. if b < 0.0089239169343946975

    1. Initial program 21.8

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied flip--_binary6421.7

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

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

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

    if 0.0089239169343946975 < b

    1. Initial program 46.8

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

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity_binary6410.2

      \[\leadsto \frac{-1.5 \cdot \frac{a \cdot c}{\color{blue}{1 \cdot b}}}{3 \cdot a}\]
    6. Applied times-frac_binary6410.1

      \[\leadsto \frac{-1.5 \cdot \color{blue}{\left(\frac{a}{1} \cdot \frac{c}{b}\right)}}{3 \cdot a}\]
    7. Applied associate-*r*_binary649.9

      \[\leadsto \frac{\color{blue}{\left(-1.5 \cdot \frac{a}{1}\right) \cdot \frac{c}{b}}}{3 \cdot a}\]
    8. Simplified9.9

      \[\leadsto \frac{\color{blue}{\left(-1.5 \cdot a\right)} \cdot \frac{c}{b}}{3 \cdot a}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification11.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 0.008923916934394698:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) - b \cdot b}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(a \cdot -1.5\right) \cdot \frac{c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020219 
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :precision binary64
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))