Average Error: 33.1 → 7.4
Time: 5.4s
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 -4.074717120578057 \cdot 10^{+20}:\\ \;\;\;\;\frac{c}{b} \cdot 0.5 - 0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq 3.446689799828328 \cdot 10^{-299}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{3}}{a}\\ \mathbf{elif}\;b \leq 3.417086748878012 \cdot 10^{+116}:\\ \;\;\;\;\frac{c}{\left(-b\right) - \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 -4.074717120578057 \cdot 10^{+20}:\\
\;\;\;\;\frac{c}{b} \cdot 0.5 - 0.6666666666666666 \cdot \frac{b}{a}\\

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

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

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

\end{array}
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 VAR;
	if ((b <= -4.074717120578057e+20)) {
		VAR = ((double) (((double) ((c / b) * 0.5)) - ((double) (0.6666666666666666 * (b / a)))));
	} else {
		double VAR_1;
		if ((b <= 3.446689799828328e-299)) {
			VAR_1 = ((((double) (((double) sqrt(((double) (((double) (b * b)) - ((double) (3.0 * ((double) (c * a)))))))) - b)) / 3.0) / a);
		} else {
			double VAR_2;
			if ((b <= 3.417086748878012e+116)) {
				VAR_2 = (c / ((double) (((double) -(b)) - ((double) sqrt(((double) (((double) (b * b)) - ((double) (3.0 * ((double) (c * a)))))))))));
			} else {
				VAR_2 = ((double) ((c / b) * -0.5));
			}
			VAR_1 = VAR_2;
		}
		VAR = VAR_1;
	}
	return VAR;
}

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 < -407471712057805701000

    1. Initial program Error: 32.9 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: 7.1 bits

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}}\]
    3. SimplifiedError: 7.1 bits

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

    if -407471712057805701000 < b < 3.44668979982832785e-299

    1. Initial program Error: 10.8 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 associate-/r*Error: 10.8 bits

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

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

    if 3.44668979982832785e-299 < b < 3.41708674887801234e116

    1. Initial program Error: 31.8 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 flip-+Error: 31.8 bits

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

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

      \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{\color{blue}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}}{3 \cdot a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identityError: 15.7 bits

      \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{\color{blue}{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}\right)}}}{3 \cdot a}\]
    8. Applied times-fracError: 15.7 bits

      \[\leadsto \frac{\color{blue}{\frac{3}{1} \cdot \frac{a \cdot c}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}}{3 \cdot a}\]
    9. Applied times-fracError: 15.6 bits

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

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

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

    if 3.41708674887801234e116 < b

    1. Initial program Error: 60.2 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: 2.0 bits

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.074717120578057 \cdot 10^{+20}:\\ \;\;\;\;\frac{c}{b} \cdot 0.5 - 0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq 3.446689799828328 \cdot 10^{-299}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{3}}{a}\\ \mathbf{elif}\;b \leq 3.417086748878012 \cdot 10^{+116}:\\ \;\;\;\;\frac{c}{\left(-b\right) - \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 2020200 
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))