Average Error: 35.2 → 10.6
Time: 5.7s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -2.9081271504349842 \cdot 10^{74}:\\ \;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \le -1.24967178822398719 \cdot 10^{-269}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.3291736419050374 \cdot 10^{154}:\\ \;\;\;\;-\frac{1}{\frac{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \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 \le -2.9081271504349842 \cdot 10^{74}:\\
\;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\

\mathbf{elif}\;b \le -1.24967178822398719 \cdot 10^{-269}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

\mathbf{elif}\;b \le 1.3291736419050374 \cdot 10^{154}:\\
\;\;\;\;-\frac{1}{\frac{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{c}}\\

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

\end{array}
double code(double a, double b, double c) {
	return ((double) (((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 <= -2.908127150434984e+74)) {
		VAR = ((double) (((double) (((double) (1.5 * ((double) (((double) (a * c)) / b)))) - ((double) (2.0 * b)))) / ((double) (3.0 * a))));
	} else {
		double VAR_1;
		if ((b <= -1.2496717882239872e-269)) {
			VAR_1 = ((double) (((double) (((double) -(b)) + ((double) (((double) sqrt(((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (3.0 * a)) * c)))))))) * ((double) sqrt(((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (3.0 * a)) * c)))))))))))) / ((double) (3.0 * a))));
		} else {
			double VAR_2;
			if ((b <= 1.3291736419050374e+154)) {
				VAR_2 = ((double) -(((double) (1.0 / ((double) (((double) (b + ((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (3.0 * a)) * c)))))))) / c))))));
			} else {
				VAR_2 = ((double) (((double) (-1.5 * ((double) (((double) (a * c)) / b)))) / ((double) (3.0 * a))));
			}
			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 < -2.908127150434984e+74

    1. Initial program 43.1

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

      \[\leadsto \frac{\color{blue}{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{3 \cdot a}\]

    if -2.908127150434984e+74 < b < -1.2496717882239872e-269

    1. Initial program 9.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt9.6

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

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

    if -1.2496717882239872e-269 < b < 1.3291736419050374e+154

    1. Initial program 34.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt34.6

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

      \[\leadsto \frac{\left(-b\right) + \color{blue}{\sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied flip-+36.7

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

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

      \[\leadsto \frac{\frac{0 + \left(3 \cdot a\right) \cdot c}{\color{blue}{-\left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a}\]
    9. Using strategy rm
    10. Applied neg-mul-116.6

      \[\leadsto \frac{\frac{0 + \left(3 \cdot a\right) \cdot c}{\color{blue}{-1 \cdot \left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a}\]
    11. Applied *-un-lft-identity16.6

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

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

      \[\leadsto \frac{\color{blue}{-1} \cdot \frac{0 + \left(3 \cdot a\right) \cdot c}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    14. Simplified15.2

      \[\leadsto \frac{-1 \cdot \color{blue}{\frac{3 \cdot a}{\frac{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{c}}}}{3 \cdot a}\]
    15. Using strategy rm
    16. Applied mul-1-neg15.2

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

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

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

    if 1.3291736419050374e+154 < b

    1. Initial program 64.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.9081271504349842 \cdot 10^{74}:\\ \;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \le -1.24967178822398719 \cdot 10^{-269}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.3291736419050374 \cdot 10^{154}:\\ \;\;\;\;-\frac{1}{\frac{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020123 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))