Average Error: 35.0 → 6.3
Time: 4.5s
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 -5.05350087668616 \cdot 10^{+142}:\\ \;\;\;\;\frac{c}{b} \cdot 0.5 - 0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq -3.0932591459060287 \cdot 10^{-302}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{3}}{a}\\ \mathbf{elif}\;b \leq 2.3119185569929864 \cdot 10^{+122}:\\ \;\;\;\;-\frac{c}{b + \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \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 -5.05350087668616 \cdot 10^{+142}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5 - 0.6666666666666666 \cdot \frac{b}{a}\\

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

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

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

\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 -5.05350087668616e+142)
   (- (* (/ c b) 0.5) (* 0.6666666666666666 (/ b a)))
   (if (<= b -3.0932591459060287e-302)
     (/ (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) 3.0) a)
     (if (<= b 2.3119185569929864e+122)
       (- (/ c (+ b (sqrt (- (* b b) (* 3.0 (* c a)))))))
       (* (/ c b) -0.5)))))
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 <= -5.05350087668616e+142)) {
		tmp = ((double) (((double) ((c / b) * 0.5)) - ((double) (0.6666666666666666 * (b / a)))));
	} else {
		double tmp_1;
		if ((b <= -3.0932591459060287e-302)) {
			tmp_1 = ((((double) (((double) sqrt(((double) (((double) (b * b)) - ((double) (c * ((double) (a * 3.0)))))))) - b)) / 3.0) / a);
		} else {
			double tmp_2;
			if ((b <= 2.3119185569929864e+122)) {
				tmp_2 = ((double) -((c / ((double) (b + ((double) sqrt(((double) (((double) (b * b)) - ((double) (3.0 * ((double) (c * a)))))))))))));
			} else {
				tmp_2 = ((double) ((c / b) * -0.5));
			}
			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 < -5.05350087668616048e142

    1. Initial program 59.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified59.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 3.2

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}}\]
    4. Simplified3.2

      \[\leadsto \color{blue}{\frac{c}{b} \cdot 0.5 - 0.6666666666666666 \cdot \frac{b}{a}}\]

    if -5.05350087668616048e142 < b < -3.09325914590602866e-302

    1. Initial program 8.5

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

      \[\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 associate-/r*_binary648.5

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

    if -3.09325914590602866e-302 < b < 2.3119185569929864e122

    1. Initial program 33.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified33.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--_binary6433.8

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

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

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

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

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

      \[\leadsto -\color{blue}{\frac{c}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}\]
    11. Using strategy rm
    12. Applied associate-*l*_binary648.3

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

    if 2.3119185569929864e122 < b

    1. Initial program 61.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5.05350087668616 \cdot 10^{+142}:\\ \;\;\;\;\frac{c}{b} \cdot 0.5 - 0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq -3.0932591459060287 \cdot 10^{-302}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{3}}{a}\\ \mathbf{elif}\;b \leq 2.3119185569929864 \cdot 10^{+122}:\\ \;\;\;\;-\frac{c}{b + \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array}\]

Reproduce

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