Average Error: 34.0 → 11.2
Time: 4.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 -34801737241079.82:\\ \;\;\;\;\frac{\left(-b\right) + \left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le -1.4167290353563065 \cdot 10^{-64}:\\ \;\;\;\;\frac{1}{\frac{3 \cdot a}{3 \cdot \left(a \cdot c\right)} \cdot \frac{\left({b}^{2} - {b}^{2}\right) + 3 \cdot \left(a \cdot c\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}}\\ \mathbf{elif}\;b \le 1.3695280426588302 \cdot 10^{154}:\\ \;\;\;\;1 \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{\frac{c}{1}} \cdot \left(\left(-b\right) - \left(b - 1.5 \cdot \frac{a \cdot c}{b}\right)\right)}\\ \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 -34801737241079.82:\\
\;\;\;\;\frac{\left(-b\right) + \left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}{3 \cdot a}\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{\frac{c}{1}} \cdot \left(\left(-b\right) - \left(b - 1.5 \cdot \frac{a \cdot c}{b}\right)\right)}\\

\end{array}
double code(double a, double b, double c) {
	return ((-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a));
}
double code(double a, double b, double c) {
	double temp;
	if ((b <= -34801737241079.82)) {
		temp = ((-b + ((1.5 * ((a * c) / b)) - b)) / (3.0 * a));
	} else {
		double temp_1;
		if ((b <= -1.4167290353563065e-64)) {
			temp_1 = (1.0 / (((3.0 * a) / (3.0 * (a * c))) * (((pow(b, 2.0) - pow(b, 2.0)) + (3.0 * (a * c))) / (sqrt(((b * b) - ((3.0 * a) * c))) - b))));
		} else {
			double temp_2;
			if ((b <= 1.3695280426588302e+154)) {
				temp_2 = (1.0 * (c / (-b - sqrt(((b * b) - ((3.0 * a) * c))))));
			} else {
				temp_2 = (1.0 / ((1.0 / (c / 1.0)) * (-b - (b - (1.5 * ((a * c) / b))))));
			}
			temp_1 = temp_2;
		}
		temp = temp_1;
	}
	return temp;
}

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

    1. Initial program 34.0

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

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

    if -34801737241079.82 < b < -1.4167290353563065e-64

    1. Initial program 4.5

      \[\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-+40.3

      \[\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. Simplified40.4

      \[\leadsto \frac{\frac{\color{blue}{0 + 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. Using strategy rm
    6. Applied clear-num40.4

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

      \[\leadsto \frac{1}{\color{blue}{\frac{3 \cdot a}{3 \cdot \left(a \cdot c\right)} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}\]
    8. Using strategy rm
    9. Applied flip--40.5

      \[\leadsto \frac{1}{\frac{3 \cdot a}{3 \cdot \left(a \cdot c\right)} \cdot \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}}}}\]
    10. Simplified14.6

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

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

    if -1.4167290353563065e-64 < b < 1.3695280426588302e+154

    1. Initial program 27.4

      \[\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-+30.2

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

      \[\leadsto \frac{\frac{\color{blue}{0 + 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. Using strategy rm
    6. Applied clear-num17.0

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

      \[\leadsto \frac{1}{\color{blue}{\frac{3 \cdot a}{3 \cdot \left(a \cdot c\right)} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}\]
    8. Using strategy rm
    9. Applied clear-num16.0

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

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{c}{1}}} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}\]
    11. Using strategy rm
    12. Applied div-inv11.8

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

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

    if 1.3695280426588302e+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. Using strategy rm
    3. Applied flip-+64.0

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

      \[\leadsto \frac{\frac{\color{blue}{0 + 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. Using strategy rm
    6. Applied clear-num38.1

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

      \[\leadsto \frac{1}{\color{blue}{\frac{3 \cdot a}{3 \cdot \left(a \cdot c\right)} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}\]
    8. Using strategy rm
    9. Applied clear-num38.1

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

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

      \[\leadsto \frac{1}{\frac{1}{\frac{c}{1}} \cdot \left(\left(-b\right) - \color{blue}{\left(b - 1.5 \cdot \frac{a \cdot c}{b}\right)}\right)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification11.2

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

Reproduce

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