Average Error: 34.1 → 11.5
Time: 4.1s
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 -3.57925205560055901 \cdot 10^{-75}:\\ \;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \le 8.47915506480201008 \cdot 10^{53}:\\ \;\;\;\;1 \cdot \frac{c}{a \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{3 \cdot c}{-6 \cdot b}\\ \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 -3.57925205560055901 \cdot 10^{-75}:\\
\;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\

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

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

\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 VAR;
	if ((b <= -3.579252055600559e-75)) {
		VAR = (((1.5 * ((a * c) / b)) - (2.0 * b)) / (3.0 * a));
	} else {
		double VAR_1;
		if ((b <= 8.47915506480201e+53)) {
			VAR_1 = (1.0 * (c / (a * ((-b - sqrt(((b * b) - (3.0 * (a * c))))) / a))));
		} else {
			VAR_1 = ((3.0 * c) / (-6.0 * b));
		}
		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 3 regimes
  2. if b < -3.579252055600559e-75

    1. Initial program 27.1

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

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

    if -3.579252055600559e-75 < b < 8.47915506480201e+53

    1. Initial program 23.2

      \[\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-*l*23.2

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

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

      \[\leadsto \frac{\frac{\color{blue}{3 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\]
    7. Using strategy rm
    8. Applied *-commutative18.5

      \[\leadsto \frac{\frac{3 \cdot \color{blue}{\left(c \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\]
    9. Applied associate-*r*18.6

      \[\leadsto \frac{\frac{\color{blue}{\left(3 \cdot c\right) \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\]
    10. Applied associate-/l*17.2

      \[\leadsto \frac{\color{blue}{\frac{3 \cdot c}{\frac{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{a}}}}{3 \cdot a}\]
    11. Applied associate-/l/14.3

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

      \[\leadsto \frac{3 \cdot c}{\color{blue}{3 \cdot \left(a \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{a}\right)}}\]
    14. Applied times-frac14.0

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

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

    if 8.47915506480201e+53 < b

    1. Initial program 57.2

      \[\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-*l*57.2

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

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

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

      \[\leadsto \frac{\frac{3 \cdot \color{blue}{\left(c \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\]
    9. Applied associate-*r*28.1

      \[\leadsto \frac{\frac{\color{blue}{\left(3 \cdot c\right) \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\]
    10. Applied associate-/l*30.3

      \[\leadsto \frac{\color{blue}{\frac{3 \cdot c}{\frac{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{a}}}}{3 \cdot a}\]
    11. Applied associate-/l/29.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.57925205560055901 \cdot 10^{-75}:\\ \;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \le 8.47915506480201008 \cdot 10^{53}:\\ \;\;\;\;1 \cdot \frac{c}{a \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{3 \cdot c}{-6 \cdot b}\\ \end{array}\]

Reproduce

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