Average Error: 34.1 → 6.9
Time: 11.3s
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 -5.43891712310251 \cdot 10^{+135}:\\ \;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\ \mathbf{elif}\;b \leq -2.5850424185292603 \cdot 10^{-267}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} - \frac{b}{3 \cdot a}\\ \mathbf{elif}\;b \leq 1.3383888372372949 \cdot 10^{+51}:\\ \;\;\;\;\frac{1}{\frac{3}{\frac{c \cdot -3}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{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 \leq -5.43891712310251 \cdot 10^{+135}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\

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

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

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

\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 -5.43891712310251e+135)
   (/ (* b -2.0) (* 3.0 a))
   (if (<= b -2.5850424185292603e-267)
     (- (/ (sqrt (- (* b b) (* (* 3.0 a) c))) (* 3.0 a)) (/ b (* 3.0 a)))
     (if (<= b 1.3383888372372949e+51)
       (/ 1.0 (/ 3.0 (/ (* c -3.0) (+ b (sqrt (- (* b b) (* 3.0 (* a c))))))))
       (* -0.5 (/ c b))))))
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 tmp;
	if (b <= -5.43891712310251e+135) {
		tmp = (b * -2.0) / (3.0 * a);
	} else if (b <= -2.5850424185292603e-267) {
		tmp = (sqrt((b * b) - ((3.0 * a) * c)) / (3.0 * a)) - (b / (3.0 * a));
	} else if (b <= 1.3383888372372949e+51) {
		tmp = 1.0 / (3.0 / ((c * -3.0) / (b + sqrt((b * b) - (3.0 * (a * c))))));
	} else {
		tmp = -0.5 * (c / b);
	}
	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 < -5.4389171231025101e135

    1. Initial program 58.0

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

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

      \[\leadsto \frac{\color{blue}{-2 \cdot b}}{3 \cdot a}\]
    4. Simplified2.7

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

    if -5.4389171231025101e135 < b < -2.58504241852926e-267

    1. Initial program 8.1

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

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

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

    if -2.58504241852926e-267 < b < 1.33838883723729491e51

    1. Initial program 29.0

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{3}{\frac{\frac{a \cdot \left(c \cdot -3\right)}{\color{blue}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}}{a}}}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity_binary64_246516.9

      \[\leadsto \frac{1}{\frac{3}{\frac{\frac{a \cdot \left(c \cdot -3\right)}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{\color{blue}{1 \cdot a}}}}\]
    12. Applied *-un-lft-identity_binary64_246516.9

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

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

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

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

    if 1.33838883723729491e51 < 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. Simplified57.2

      \[\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}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5.43891712310251 \cdot 10^{+135}:\\ \;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\ \mathbf{elif}\;b \leq -2.5850424185292603 \cdot 10^{-267}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} - \frac{b}{3 \cdot a}\\ \mathbf{elif}\;b \leq 1.3383888372372949 \cdot 10^{+51}:\\ \;\;\;\;\frac{1}{\frac{3}{\frac{c \cdot -3}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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