Average Error: 33.7 → 7.6
Time: 16.4s
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 -8.363321097884155 \cdot 10^{+91}:\\ \;\;\;\;\frac{\frac{b \cdot -2}{3}}{a}\\ \mathbf{elif}\;b \leq 1.9677039219986912 \cdot 10^{-169}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{elif}\;b \leq 2.2080465071725722 \cdot 10^{+76}:\\ \;\;\;\;\frac{a}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{\frac{\frac{c \cdot -3}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3}}{\sqrt[3]{a}}\\ \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 -8.363321097884155 \cdot 10^{+91}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{3}}{a}\\

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

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

\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 -8.363321097884155e+91)
   (/ (/ (* b -2.0) 3.0) a)
   (if (<= b 1.9677039219986912e-169)
     (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
     (if (<= b 2.2080465071725722e+76)
       (*
        (/ a (* (cbrt a) (cbrt a)))
        (/
         (/ (/ (* c -3.0) (+ b (sqrt (- (* b b) (* 3.0 (* a c)))))) 3.0)
         (cbrt a)))
       (* -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 <= -8.363321097884155e+91) {
		tmp = ((b * -2.0) / 3.0) / a;
	} else if (b <= 1.9677039219986912e-169) {
		tmp = (sqrt((b * b) - ((3.0 * a) * c)) - b) / (3.0 * a);
	} else if (b <= 2.2080465071725722e+76) {
		tmp = (a / (cbrt(a) * cbrt(a))) * ((((c * -3.0) / (b + sqrt((b * b) - (3.0 * (a * c))))) / 3.0) / cbrt(a));
	} 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 < -8.36332109788415504e91

    1. Initial program 45.3

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

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

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

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

    if -8.36332109788415504e91 < b < 1.9677039219986912e-169

    1. Initial program 10.6

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

    if 1.9677039219986912e-169 < b < 2.2080465071725722e76

    1. Initial program 35.6

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

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}}\]
    5. Simplified35.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--_binary64_516835.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. Simplified16.5

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

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

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

      \[\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}{1 \cdot 3}}}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}\]
    13. Applied *-un-lft-identity_binary64_519317.1

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

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

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

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

    if 2.2080465071725722e76 < b

    1. Initial program 58.1

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

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

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

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

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

      \[\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. Taylor expanded around 0 3.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -8.363321097884155 \cdot 10^{+91}:\\ \;\;\;\;\frac{\frac{b \cdot -2}{3}}{a}\\ \mathbf{elif}\;b \leq 1.9677039219986912 \cdot 10^{-169}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{elif}\;b \leq 2.2080465071725722 \cdot 10^{+76}:\\ \;\;\;\;\frac{a}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{\frac{\frac{c \cdot -3}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3}}{\sqrt[3]{a}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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