Average Error: 28.4 → 16.6
Time: 6.4s
Precision: binary64
\[1.0536712127723509 \cdot 10^{-08} < a \land a < 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} < b \land b < 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} < c \land c < 94906265.62425156\]
\[\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 1966.8871478627834:\\ \;\;\;\;\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{-1.5}{\frac{\sqrt[3]{3} \cdot \sqrt[3]{3}}{c} \cdot \left(b \cdot \sqrt[3]{3}\right)}\\ \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 1966.8871478627834:\\
\;\;\;\;\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{-1.5}{\frac{\sqrt[3]{3} \cdot \sqrt[3]{3}}{c} \cdot \left(b \cdot \sqrt[3]{3}\right)}\\

\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 1966.8871478627834)
   (/
    (/
     (- (- (* b b) (* (* 3.0 a) c)) (* b b))
     (+ b (sqrt (- (* b b) (* (* 3.0 a) c)))))
    (* 3.0 a))
   (/ -1.5 (* (/ (* (cbrt 3.0) (cbrt 3.0)) c) (* b (cbrt 3.0))))))
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 <= 1966.8871478627834)) {
		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 = (-1.5 / ((double) ((((double) (((double) cbrt(3.0)) * ((double) cbrt(3.0)))) / c) * ((double) (b * ((double) cbrt(3.0)))))));
	}
	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 < 1966.8871478627834

    1. Initial program 18.1

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

      \[\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--_binary6418.1

      \[\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. Simplified17.1

      \[\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. Simplified17.1

      \[\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 1966.8871478627834 < b

    1. Initial program 36.6

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

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    4. Using strategy rm
    5. Applied associate-/l*_binary6416.2

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

      \[\leadsto \frac{-1.5}{\color{blue}{\frac{3}{\frac{c}{b}}}}\]
    7. Using strategy rm
    8. Applied div-inv_binary6416.1

      \[\leadsto \frac{-1.5}{\frac{3}{\color{blue}{c \cdot \frac{1}{b}}}}\]
    9. Applied add-cube-cbrt_binary6416.1

      \[\leadsto \frac{-1.5}{\frac{\color{blue}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}{c \cdot \frac{1}{b}}}\]
    10. Applied times-frac_binary6416.2

      \[\leadsto \frac{-1.5}{\color{blue}{\frac{\sqrt[3]{3} \cdot \sqrt[3]{3}}{c} \cdot \frac{\sqrt[3]{3}}{\frac{1}{b}}}}\]
    11. Simplified16.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1966.8871478627834:\\ \;\;\;\;\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{-1.5}{\frac{\sqrt[3]{3} \cdot \sqrt[3]{3}}{c} \cdot \left(b \cdot \sqrt[3]{3}\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2020205 
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))