Average Error: 33.8 → 6.3
Time: 11.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 -1.2490394173203949 \cdot 10^{+78}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq -3.2016173609121512 \cdot 10^{-291}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 1.4494405112157072 \cdot 10^{+119}:\\ \;\;\;\;3 \cdot \frac{\frac{c}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}}{-3}\\ \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 -1.2490394173203949 \cdot 10^{+78}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\

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

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

\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 -1.2490394173203949e+78)
   (- (* 0.5 (/ c b)) (* 0.6666666666666666 (/ b a)))
   (if (<= b -3.2016173609121512e-291)
     (/ (- (sqrt (+ (* b b) (* a (* c -3.0)))) b) (* a 3.0))
     (if (<= b 1.4494405112157072e+119)
       (* 3.0 (/ (/ c (+ b (sqrt (- (* b b) (* c (* a 3.0)))))) -3.0))
       (* (/ 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 <= -1.2490394173203949e+78) {
		tmp = (0.5 * (c / b)) - (0.6666666666666666 * (b / a));
	} else if (b <= -3.2016173609121512e-291) {
		tmp = (sqrt((b * b) + (a * (c * -3.0))) - b) / (a * 3.0);
	} else if (b <= 1.4494405112157072e+119) {
		tmp = 3.0 * ((c / (b + sqrt((b * b) - (c * (a * 3.0))))) / -3.0);
	} 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 < -1.24903941732039485e78

    1. Initial program 42.2

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}}\]

    if -1.24903941732039485e78 < b < -3.2016173609121512e-291

    1. Initial program 9.0

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

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

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

    if -3.2016173609121512e-291 < b < 1.44944051121570723e119

    1. Initial program 31.6

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

      \[\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.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. Simplified15.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 frac-2neg_binary64_111215.6

      \[\leadsto \color{blue}{\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. Simplified15.5

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

      \[\leadsto \frac{\frac{\left(3 \cdot a\right) \cdot c}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{\color{blue}{a \cdot -3}}\]
    11. Using strategy rm
    12. Applied *-un-lft-identity_binary64_110115.5

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

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

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

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

    if 1.44944051121570723e119 < b

    1. Initial program 60.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.2490394173203949 \cdot 10^{+78}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq -3.2016173609121512 \cdot 10^{-291}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 1.4494405112157072 \cdot 10^{+119}:\\ \;\;\;\;3 \cdot \frac{\frac{c}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}}{-3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array}\]

Reproduce

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