Average Error: 33.5 → 7.8
Time: 12.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 -8.957255745626847 \cdot 10^{+114}:\\ \;\;\;\;\frac{1}{\frac{3}{1.5 \cdot \frac{c}{b} - 2 \cdot \frac{b}{a}}}\\ \mathbf{elif}\;b \leq -8.289375697312939 \cdot 10^{-303}:\\ \;\;\;\;\frac{1}{\frac{3}{\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{a}}}\\ \mathbf{elif}\;b \leq 3970.532612665264:\\ \;\;\;\;\frac{1}{\frac{3}{\frac{a \cdot \frac{c \cdot -3}{b + \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{a}}}\\ \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 -8.957255745626847 \cdot 10^{+114}:\\
\;\;\;\;\frac{1}{\frac{3}{1.5 \cdot \frac{c}{b} - 2 \cdot \frac{b}{a}}}\\

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

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

\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 -8.957255745626847e+114)
   (/ 1.0 (/ 3.0 (- (* 1.5 (/ c b)) (* 2.0 (/ b a)))))
   (if (<= b -8.289375697312939e-303)
     (/ 1.0 (/ 3.0 (/ (- (sqrt (- (* b b) (* 3.0 (* c a)))) b) a)))
     (if (<= b 3970.532612665264)
       (/
        1.0
        (/
         3.0
         (/ (* a (/ (* c -3.0) (+ b (sqrt (- (* b b) (* 3.0 (* c a))))))) a)))
       (* (/ c b) -0.5)))))
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.957255745626847e+114) {
		tmp = 1.0 / (3.0 / ((1.5 * (c / b)) - (2.0 * (b / a))));
	} else if (b <= -8.289375697312939e-303) {
		tmp = 1.0 / (3.0 / ((sqrt((b * b) - (3.0 * (c * a))) - b) / a));
	} else if (b <= 3970.532612665264) {
		tmp = 1.0 / (3.0 / ((a * ((c * -3.0) / (b + sqrt((b * b) - (3.0 * (c * a)))))) / a));
	} else {
		tmp = (c / b) * -0.5;
	}
	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.95725574562684703e114

    1. Initial program 50.7

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

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

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

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

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

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

      \[\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. Taylor expanded around -inf 3.7

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

    if -8.95725574562684703e114 < b < -8.28937569731293899e-303

    1. Initial program 7.8

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

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

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

    if -8.28937569731293899e-303 < b < 3970.53261266526397

    1. Initial program 25.8

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{3}{\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)}}}{a}}}\]
    12. Applied times-frac_binary64_110713.8

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

    if 3970.53261266526397 < b

    1. Initial program 55.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -8.957255745626847 \cdot 10^{+114}:\\ \;\;\;\;\frac{1}{\frac{3}{1.5 \cdot \frac{c}{b} - 2 \cdot \frac{b}{a}}}\\ \mathbf{elif}\;b \leq -8.289375697312939 \cdot 10^{-303}:\\ \;\;\;\;\frac{1}{\frac{3}{\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{a}}}\\ \mathbf{elif}\;b \leq 3970.532612665264:\\ \;\;\;\;\frac{1}{\frac{3}{\frac{a \cdot \frac{c \cdot -3}{b + \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array}\]

Reproduce

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