Average Error: 33.9 → 9.1
Time: 5.1s
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 -2.7824475285260255 \cdot 10^{+153}:\\ \;\;\;\;\frac{1.5 \cdot \left(c \cdot \frac{a}{b}\right) + b \cdot -2}{a \cdot 3}\\ \mathbf{elif}\;b \leq 9.589091698821888 \cdot 10^{-216}:\\ \;\;\;\;\left(\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b\right) \cdot \frac{1}{a \cdot 3}\\ \mathbf{elif}\;b \leq 1.6062084660570117 \cdot 10^{+25}:\\ \;\;\;\;\frac{1}{a \cdot 3} \cdot \frac{3 \cdot \left(c \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}\\ \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 -2.7824475285260255 \cdot 10^{+153}:\\
\;\;\;\;\frac{1.5 \cdot \left(c \cdot \frac{a}{b}\right) + b \cdot -2}{a \cdot 3}\\

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

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

\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 -2.7824475285260255e+153)
   (/ (+ (* 1.5 (* c (/ a b))) (* b -2.0)) (* a 3.0))
   (if (<= b 9.589091698821888e-216)
     (* (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (/ 1.0 (* a 3.0)))
     (if (<= b 1.6062084660570117e+25)
       (*
        (/ 1.0 (* a 3.0))
        (/ (* 3.0 (* c a)) (- (- b) (sqrt (- (* b b) (* 3.0 (* c a)))))))
       (* -0.5 (/ c b))))))
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 <= -2.7824475285260255e+153)) {
		tmp = (((double) (((double) (1.5 * ((double) (c * (a / b))))) + ((double) (b * -2.0)))) / ((double) (a * 3.0)));
	} else {
		double tmp_1;
		if ((b <= 9.589091698821888e-216)) {
			tmp_1 = ((double) (((double) (((double) sqrt(((double) (((double) (b * b)) - ((double) (c * ((double) (a * 3.0)))))))) - b)) * (1.0 / ((double) (a * 3.0)))));
		} else {
			double tmp_2;
			if ((b <= 1.6062084660570117e+25)) {
				tmp_2 = ((double) ((1.0 / ((double) (a * 3.0))) * (((double) (3.0 * ((double) (c * a)))) / ((double) (((double) -(b)) - ((double) sqrt(((double) (((double) (b * b)) - ((double) (3.0 * ((double) (c * a)))))))))))));
			} else {
				tmp_2 = ((double) (-0.5 * (c / b)));
			}
			tmp_1 = tmp_2;
		}
		tmp = tmp_1;
	}
	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 < -2.78244752852602553e153

    1. Initial program Error: 63.8 bits

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

      \[\leadsto \frac{\color{blue}{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{3 \cdot a}\]
    3. SimplifiedError: 2.2 bits

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

    if -2.78244752852602553e153 < b < 9.58909169882188815e-216

    1. Initial program Error: 10.0 bits

      \[\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-invError: 10.1 bits

      \[\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}}\]

    if 9.58909169882188815e-216 < b < 1.60620846605701173e25

    1. Initial program Error: 32.1 bits

      \[\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-invError: 32.1 bits

      \[\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. Using strategy rm
    5. Applied flip-+Error: 32.2 bits

      \[\leadsto \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}}} \cdot \frac{1}{3 \cdot a}\]
    6. SimplifiedError: 18.3 bits

      \[\leadsto \frac{\color{blue}{3 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \frac{1}{3 \cdot a}\]
    7. SimplifiedError: 18.2 bits

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

    if 1.60620846605701173e25 < b

    1. Initial program Error: 56.1 bits

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplificationError: 9.1 bits

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2.7824475285260255 \cdot 10^{+153}:\\ \;\;\;\;\frac{1.5 \cdot \left(c \cdot \frac{a}{b}\right) + b \cdot -2}{a \cdot 3}\\ \mathbf{elif}\;b \leq 9.589091698821888 \cdot 10^{-216}:\\ \;\;\;\;\left(\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b\right) \cdot \frac{1}{a \cdot 3}\\ \mathbf{elif}\;b \leq 1.6062084660570117 \cdot 10^{+25}:\\ \;\;\;\;\frac{1}{a \cdot 3} \cdot \frac{3 \cdot \left(c \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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