Average Error: 34.2 → 13.0
Time: 4.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 -1.3217401295489042 \cdot 10^{+154}:\\ \;\;\;\;\frac{\left(1.5 \cdot \frac{a \cdot c}{b} - b\right) - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 2.0737225518150114 \cdot 10^{-113}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 3.4989832974040957 \cdot 10^{+108}:\\ \;\;\;\;\frac{\frac{-c \cdot \left(a \cdot 3\right)}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{a \cdot 3}\\ \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 -1.3217401295489042 \cdot 10^{+154}:\\
\;\;\;\;\frac{\left(1.5 \cdot \frac{a \cdot c}{b} - b\right) - b}{a \cdot 3}\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{a \cdot 3}\\

\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 -1.3217401295489042e+154)
   (/ (- (- (* 1.5 (/ (* a c) b)) b) b) (* a 3.0))
   (if (<= b 2.0737225518150114e-113)
     (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
     (if (<= b 3.4989832974040957e+108)
       (/
        (/ (- (* c (* a 3.0))) (+ b (sqrt (- (* b b) (* c (* a 3.0))))))
        (* a 3.0))
       (/ (- (* 1.5 (/ (* a c) b))) (* a 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 <= -1.3217401295489042e+154)) {
		tmp = (((double) (((double) (((double) (1.5 * (((double) (a * c)) / b))) - b)) - b)) / ((double) (a * 3.0)));
	} else {
		double tmp_1;
		if ((b <= 2.0737225518150114e-113)) {
			tmp_1 = (((double) (((double) sqrt(((double) (((double) (b * b)) - ((double) (c * ((double) (a * 3.0)))))))) - b)) / ((double) (a * 3.0)));
		} else {
			double tmp_2;
			if ((b <= 3.4989832974040957e+108)) {
				tmp_2 = ((((double) -(((double) (c * ((double) (a * 3.0)))))) / ((double) (b + ((double) sqrt(((double) (((double) (b * b)) - ((double) (c * ((double) (a * 3.0))))))))))) / ((double) (a * 3.0)));
			} else {
				tmp_2 = (((double) -(((double) (1.5 * (((double) (a * c)) / b))))) / ((double) (a * 3.0)));
			}
			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 < -1.3217401295489042e154

    1. Initial program 64.0

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

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

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

    if -1.3217401295489042e154 < b < 2.0737225518150114e-113

    1. Initial program 11.4

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

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

    if 2.0737225518150114e-113 < b < 3.4989832974040957e108

    1. Initial program 40.7

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

      \[\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--_binary6440.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.5

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

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

    if 3.4989832974040957e108 < b

    1. Initial program 60.0

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

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification13.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.3217401295489042 \cdot 10^{+154}:\\ \;\;\;\;\frac{\left(1.5 \cdot \frac{a \cdot c}{b} - b\right) - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 2.0737225518150114 \cdot 10^{-113}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 3.4989832974040957 \cdot 10^{+108}:\\ \;\;\;\;\frac{\frac{-c \cdot \left(a \cdot 3\right)}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{a \cdot 3}\\ \end{array}\]

Reproduce

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