Average Error: 33.9 → 8.9
Time: 5.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.3249665758399062 \cdot 10^{+154}:\\ \;\;\;\;\frac{\left(1.5 \cdot \frac{a \cdot c}{b} - b\right) - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 8.969766515049942 \cdot 10^{-182}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 3.2493324446871104 \cdot 10^{+131}:\\ \;\;\;\;\sqrt[3]{\frac{-1}{\frac{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}{c}}} \cdot \left(\sqrt[3]{\frac{-1}{\frac{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}{c}}} \cdot \sqrt[3]{\frac{-1}{\frac{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}{c}}}\right)\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{c \cdot -3}{b + \left(b - 1.5 \cdot \frac{a \cdot c}{b}\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 \leq -1.3249665758399062 \cdot 10^{+154}:\\
\;\;\;\;\frac{\left(1.5 \cdot \frac{a \cdot c}{b} - b\right) - b}{a \cdot 3}\\

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

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

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

\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.3249665758399062e+154)
   (/ (- (- (* 1.5 (/ (* a c) b)) b) b) (* a 3.0))
   (if (<= b 8.969766515049942e-182)
     (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
     (if (<= b 3.2493324446871104e+131)
       (*
        (cbrt (/ -1.0 (/ (+ b (sqrt (- (* b b) (* c (* a 3.0))))) c)))
        (*
         (cbrt (/ -1.0 (/ (+ b (sqrt (- (* b b) (* c (* a 3.0))))) c)))
         (cbrt (/ -1.0 (/ (+ b (sqrt (- (* b b) (* c (* a 3.0))))) c)))))
       (*
        0.3333333333333333
        (/ (* c -3.0) (+ b (- b (* 1.5 (/ (* a 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.3249665758399062e+154) {
		tmp = (((1.5 * ((a * c) / b)) - b) - b) / (a * 3.0);
	} else if (b <= 8.969766515049942e-182) {
		tmp = (sqrt((b * b) - (c * (a * 3.0))) - b) / (a * 3.0);
	} else if (b <= 3.2493324446871104e+131) {
		tmp = cbrt(-1.0 / ((b + sqrt((b * b) - (c * (a * 3.0)))) / c)) * (cbrt(-1.0 / ((b + sqrt((b * b) - (c * (a * 3.0)))) / c)) * cbrt(-1.0 / ((b + sqrt((b * b) - (c * (a * 3.0)))) / c)));
	} else {
		tmp = 0.3333333333333333 * ((c * -3.0) / (b + (b - (1.5 * ((a * 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.32496657583990621e154

    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 11.8

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

    if -1.32496657583990621e154 < b < 8.9697665150499419e-182

    1. Initial program 10.1

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

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

    if 8.9697665150499419e-182 < b < 3.24933244468711035e131

    1. Initial program 38.0

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

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

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

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

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

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

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

    if 3.24933244468711035e131 < b

    1. Initial program 61.4

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

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

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

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

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

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

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

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

      \[\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)}\]
    12. Taylor expanded around inf 6.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.3249665758399062 \cdot 10^{+154}:\\ \;\;\;\;\frac{\left(1.5 \cdot \frac{a \cdot c}{b} - b\right) - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 8.969766515049942 \cdot 10^{-182}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 3.2493324446871104 \cdot 10^{+131}:\\ \;\;\;\;\sqrt[3]{\frac{-1}{\frac{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}{c}}} \cdot \left(\sqrt[3]{\frac{-1}{\frac{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}{c}}} \cdot \sqrt[3]{\frac{-1}{\frac{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}{c}}}\right)\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{c \cdot -3}{b + \left(b - 1.5 \cdot \frac{a \cdot c}{b}\right)}\\ \end{array}\]

Reproduce

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