Average Error: 33.9 → 8.8
Time: 7.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 -5.843460629957331 \cdot 10^{+100}:\\ \;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - b \cdot 2}{a \cdot 3}\\ \mathbf{elif}\;b \leq 1.672182564513283 \cdot 10^{-279}:\\ \;\;\;\;\left(\frac{c}{3} \cdot \frac{1}{c}\right) \cdot \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a}\\ \mathbf{elif}\;b \leq 6.036361899813576 \cdot 10^{+122}:\\ \;\;\;\;\frac{1}{\frac{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1.5 \cdot \frac{a \cdot c}{b} - b \cdot 2}{c}}\\ \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 -5.843460629957331 \cdot 10^{+100}:\\
\;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - b \cdot 2}{a \cdot 3}\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1.5 \cdot \frac{a \cdot c}{b} - b \cdot 2}{c}}\\

\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 -5.843460629957331e+100)
   (/ (- (* 1.5 (/ (* a c) b)) (* b 2.0)) (* a 3.0))
   (if (<= b 1.672182564513283e-279)
     (* (* (/ c 3.0) (/ 1.0 c)) (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) a))
     (if (<= b 6.036361899813576e+122)
       (/ 1.0 (/ (- (- b) (sqrt (- (* b b) (* c (* a 3.0))))) c))
       (/ 1.0 (/ (- (* 1.5 (/ (* a c) b)) (* b 2.0)) c))))))
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 <= -5.843460629957331e+100) {
		tmp = ((1.5 * ((a * c) / b)) - (b * 2.0)) / (a * 3.0);
	} else if (b <= 1.672182564513283e-279) {
		tmp = ((c / 3.0) * (1.0 / c)) * ((sqrt((b * b) - (c * (a * 3.0))) - b) / a);
	} else if (b <= 6.036361899813576e+122) {
		tmp = 1.0 / ((-b - sqrt((b * b) - (c * (a * 3.0)))) / c);
	} else {
		tmp = 1.0 / (((1.5 * ((a * c) / b)) - (b * 2.0)) / c);
	}
	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 < -5.8434606299573309e100

    1. Initial program 47.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around -inf 10.5

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

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

    if -5.8434606299573309e100 < b < 1.672182564513283e-279

    1. Initial program 9.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+_binary64_211733.0

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

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

      \[\leadsto \frac{\frac{\left(3 \cdot a\right) \cdot c}{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}}{3 \cdot a}\]
    7. Applied associate-/r/_binary64_208933.2

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

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

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

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

    if 1.672182564513283e-279 < b < 6.03636189981357567e122

    1. Initial program 33.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+_binary64_211733.9

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

      \[\leadsto \frac{\frac{\color{blue}{\left(3 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied clear-num_binary64_214215.8

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

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

    if 6.03636189981357567e122 < b

    1. Initial program 60.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+_binary64_211760.9

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

      \[\leadsto \frac{\frac{\color{blue}{\left(3 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied clear-num_binary64_214235.0

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

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

      \[\leadsto \frac{1}{1 \cdot \frac{\color{blue}{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{c}}\]
    9. Simplified7.4

      \[\leadsto \frac{1}{1 \cdot \frac{\color{blue}{1.5 \cdot \frac{a \cdot c}{b} - b \cdot 2}}{c}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5.843460629957331 \cdot 10^{+100}:\\ \;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - b \cdot 2}{a \cdot 3}\\ \mathbf{elif}\;b \leq 1.672182564513283 \cdot 10^{-279}:\\ \;\;\;\;\left(\frac{c}{3} \cdot \frac{1}{c}\right) \cdot \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a}\\ \mathbf{elif}\;b \leq 6.036361899813576 \cdot 10^{+122}:\\ \;\;\;\;\frac{1}{\frac{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1.5 \cdot \frac{a \cdot c}{b} - b \cdot 2}{c}}\\ \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)))