Average Error: 34.5 → 7.0
Time: 15.1s
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 -6.861638225360705 \cdot 10^{+123}:\\ \;\;\;\;\frac{\frac{b \cdot -2}{3}}{a}\\ \mathbf{elif}\;b \leq 8.03613068826263 \cdot 10^{-297}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3}}{a}\\ \mathbf{elif}\;b \leq 7.877237009026803 \cdot 10^{+126}:\\ \;\;\;\;\frac{1}{3 \cdot \frac{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{c \cdot -3}}\\ \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 -6.861638225360705 \cdot 10^{+123}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{3}}{a}\\

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

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

\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 -6.861638225360705e+123)
   (/ (/ (* b -2.0) 3.0) a)
   (if (<= b 8.03613068826263e-297)
     (/ (/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) 3.0) a)
     (if (<= b 7.877237009026803e+126)
       (/ 1.0 (* 3.0 (/ (+ b (sqrt (- (* b b) (* 3.0 (* a c))))) (* c -3.0))))
       (* -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 <= -6.861638225360705e+123) {
		tmp = ((b * -2.0) / 3.0) / a;
	} else if (b <= 8.03613068826263e-297) {
		tmp = ((sqrt((b * b) - (3.0 * (a * c))) - b) / 3.0) / a;
	} else if (b <= 7.877237009026803e+126) {
		tmp = 1.0 / (3.0 * ((b + sqrt((b * b) - (3.0 * (a * c)))) / (c * -3.0)));
	} 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 < -6.8616382253607053e123

    1. Initial program 53.2

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

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

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

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

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

    if -6.8616382253607053e123 < b < 8.0361306882626304e-297

    1. Initial program 9.9

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

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

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

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

    if 8.0361306882626304e-297 < b < 7.8772370090268035e126

    1. Initial program 33.5

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

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

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

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

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

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

    if 7.8772370090268035e126 < b

    1. Initial program 61.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -6.861638225360705 \cdot 10^{+123}:\\ \;\;\;\;\frac{\frac{b \cdot -2}{3}}{a}\\ \mathbf{elif}\;b \leq 8.03613068826263 \cdot 10^{-297}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3}}{a}\\ \mathbf{elif}\;b \leq 7.877237009026803 \cdot 10^{+126}:\\ \;\;\;\;\frac{1}{3 \cdot \frac{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{c \cdot -3}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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