Average Error: 33.4 → 6.5
Time: 14.5s
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.3306748570243904 \cdot 10^{+154}:\\ \;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\ \mathbf{elif}\;b \leq -2.785220397969887 \cdot 10^{-291}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{elif}\;b \leq 1.362728423927137 \cdot 10^{+124}:\\ \;\;\;\;\frac{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\frac{\sqrt[3]{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 -1.3306748570243904 \cdot 10^{+154}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\

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

\mathbf{elif}\;b \leq 1.362728423927137 \cdot 10^{+124}:\\
\;\;\;\;\frac{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\frac{\sqrt[3]{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 -1.3306748570243904e+154)
   (/ (* b -2.0) (* 3.0 a))
   (if (<= b -2.785220397969887e-291)
     (/ (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) 3.0) a)
     (if (<= b 1.362728423927137e+124)
       (/
        (/ 1.0 (* (cbrt 3.0) (cbrt 3.0)))
        (/ (cbrt 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 <= -1.3306748570243904e+154) {
		tmp = (b * -2.0) / (3.0 * a);
	} else if (b <= -2.785220397969887e-291) {
		tmp = ((sqrt((b * b) - ((3.0 * a) * c)) - b) / 3.0) / a;
	} else if (b <= 1.362728423927137e+124) {
		tmp = (1.0 / (cbrt(3.0) * cbrt(3.0))) / (cbrt(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 < -1.3306748570243904e154

    1. Initial program 64.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified64.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 3.2

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

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

    if -1.3306748570243904e154 < b < -2.78522039796988684e-291

    1. Initial program 8.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified8.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 associate-/r*_binary648.3

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

    if -2.78522039796988684e-291 < b < 1.3627284239271371e124

    1. Initial program 32.5

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

      \[\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 associate-/r*_binary6432.6

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

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

      \[\leadsto \frac{\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}}}{3}}{a}\]
    8. Simplified15.7

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

      \[\leadsto \frac{\frac{\frac{a \cdot \left(c \cdot -3\right)}{\color{blue}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}}{3}}{a}\]
    10. Using strategy rm
    11. Applied add-cube-cbrt_binary6415.7

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

      \[\leadsto \frac{\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)}}}}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}{a}\]
    13. Applied times-frac_binary6415.8

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \frac{\frac{a \cdot \left(c \cdot -3\right)}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{\sqrt[3]{3}}}}{a}\]
    14. Applied associate-/l*_binary6415.9

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

      \[\leadsto \frac{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\color{blue}{\frac{a}{\frac{a}{\sqrt[3]{3}} \cdot \frac{c \cdot -3}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}}}\]
    16. Using strategy rm
    17. Applied associate-/r*_binary648.4

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

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

    if 1.3627284239271371e124 < b

    1. Initial program 61.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.3306748570243904 \cdot 10^{+154}:\\ \;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\ \mathbf{elif}\;b \leq -2.785220397969887 \cdot 10^{-291}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{elif}\;b \leq 1.362728423927137 \cdot 10^{+124}:\\ \;\;\;\;\frac{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\frac{\sqrt[3]{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 2021175 
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))