Average Error: 33.9 → 7.1
Time: 5.2s
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.7028086930165435 \cdot 10^{+99}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq 2.4133286600301676 \cdot 10^{-279}:\\ \;\;\;\;\frac{1}{\frac{3}{\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a}}}\\ \mathbf{elif}\;b \leq 1.7451134981590885 \cdot 10^{+117}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{c \cdot -3}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\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 -1.7028086930165435 \cdot 10^{+99}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\

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

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

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

\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.7028086930165435e+99)
   (- (* 0.5 (/ c b)) (* 0.6666666666666666 (/ b a)))
   (if (<= b 2.4133286600301676e-279)
     (/ 1.0 (/ 3.0 (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) a)))
     (if (<= b 1.7451134981590885e+117)
       (*
        0.3333333333333333
        (/ (* c -3.0) (+ b (sqrt (- (* b b) (* c (* a 3.0)))))))
       (* (/ c b) -0.5)))))
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.7028086930165435e+99)) {
		tmp = ((double) (((double) (0.5 * (c / b))) - ((double) (0.6666666666666666 * (b / a)))));
	} else {
		double tmp_1;
		if ((b <= 2.4133286600301676e-279)) {
			tmp_1 = (1.0 / (3.0 / (((double) (((double) sqrt(((double) (((double) (b * b)) - ((double) (c * ((double) (a * 3.0)))))))) - b)) / a)));
		} else {
			double tmp_2;
			if ((b <= 1.7451134981590885e+117)) {
				tmp_2 = ((double) (0.3333333333333333 * (((double) (c * -3.0)) / ((double) (b + ((double) sqrt(((double) (((double) (b * b)) - ((double) (c * ((double) (a * 3.0)))))))))))));
			} else {
				tmp_2 = ((double) ((c / b) * -0.5));
			}
			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.70280869301654355e99

    1. Initial program 46.9

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

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

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

    if -1.70280869301654355e99 < b < 2.4133286600301676e-279

    1. Initial program 9.8

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

      \[\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 clear-num_binary649.9

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

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

    if 2.4133286600301676e-279 < b < 1.7451134981590885e117

    1. Initial program 33.3

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

      \[\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--_binary6433.3

      \[\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}{a \cdot \left(c \cdot -3\right)}}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}{3 \cdot a}\]
    6. Simplified16.5

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

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{a \cdot \left(c \cdot -3\right)}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    9. Applied times-frac_binary6416.5

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

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

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

    if 1.7451134981590885e117 < b

    1. Initial program 60.3

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

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification7.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.7028086930165435 \cdot 10^{+99}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq 2.4133286600301676 \cdot 10^{-279}:\\ \;\;\;\;\frac{1}{\frac{3}{\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a}}}\\ \mathbf{elif}\;b \leq 1.7451134981590885 \cdot 10^{+117}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{c \cdot -3}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array}\]

Reproduce

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