Average Error: 33.5 → 7.2
Time: 6.6s
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.684656237783103 \cdot 10^{+83}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.094867628068678 \cdot 10^{-237}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{3}}{a}\\ \mathbf{elif}\;b \leq 2.276445623250457 \cdot 10^{+54}:\\ \;\;\;\;\frac{-c}{b + \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}\\ \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 -6.684656237783103 \cdot 10^{+83}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\

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

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

\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 -6.684656237783103e+83)
   (- (* 0.5 (/ c b)) (* 0.6666666666666666 (/ b a)))
   (if (<= b 1.094867628068678e-237)
     (/ (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) 3.0) a)
     (if (<= b 2.276445623250457e+54)
       (/ (- c) (+ b (sqrt (- (* b b) (* 3.0 (* c 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 <= -6.684656237783103e+83) {
		tmp = (0.5 * (c / b)) - (0.6666666666666666 * (b / a));
	} else if (b <= 1.094867628068678e-237) {
		tmp = ((sqrt((b * b) - (c * (a * 3.0))) - b) / 3.0) / a;
	} else if (b <= 2.276445623250457e+54) {
		tmp = -c / (b + sqrt((b * b) - (3.0 * (c * 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 < -6.68465623778310309e83

    1. Initial program 42.4

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

      \[\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} - 0.6666666666666666 \cdot \frac{b}{a}}\]

    if -6.68465623778310309e83 < b < 1.09486762806867801e-237

    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_17279.9

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

    if 1.09486762806867801e-237 < b < 2.276445623250457e54

    1. Initial program 32.6

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

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

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

      \[\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 *-un-lft-identity_binary64_178317.1

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

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

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

      \[\leadsto 0.3333333333333333 \cdot \color{blue}{\left(1 \cdot \frac{c \cdot -3}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}\right)}\]
    12. Using strategy rm
    13. Applied associate-*r/_binary64_17258.8

      \[\leadsto 0.3333333333333333 \cdot \color{blue}{\frac{1 \cdot \left(c \cdot -3\right)}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}\]
    14. Applied associate-*r/_binary64_17258.7

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

      \[\leadsto \frac{\color{blue}{-c}}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}\]
    16. Using strategy rm
    17. Applied associate-*l*_binary64_17248.5

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

    if 2.276445623250457e54 < b

    1. Initial program 57.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -6.684656237783103 \cdot 10^{+83}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.094867628068678 \cdot 10^{-237}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{3}}{a}\\ \mathbf{elif}\;b \leq 2.276445623250457 \cdot 10^{+54}:\\ \;\;\;\;\frac{-c}{b + \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array}\]

Reproduce

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