Average Error: 34.0 → 7.0
Time: 12.5s
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.3146037788049252 \cdot 10^{+89}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq -1.3835721528989353 \cdot 10^{-212}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 1.1610828712163664 \cdot 10^{+78}:\\ \;\;\;\;\frac{1}{-\frac{b + \sqrt{b \cdot b + a \cdot \left(c \cdot -3\right)}}{c}}\\ \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.3146037788049252 \cdot 10^{+89}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\

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

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

\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.3146037788049252e+89)
   (+ (* 0.5 (/ c b)) (* -0.6666666666666666 (/ b a)))
   (if (<= b -1.3835721528989353e-212)
     (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
     (if (<= b 1.1610828712163664e+78)
       (/ 1.0 (- (/ (+ b (sqrt (+ (* b b) (* a (* c -3.0))))) c)))
       (* (/ 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.3146037788049252e+89) {
		tmp = (0.5 * (c / b)) + (-0.6666666666666666 * (b / a));
	} else if (b <= -1.3835721528989353e-212) {
		tmp = (sqrt((b * b) - (c * (a * 3.0))) - b) / (a * 3.0);
	} else if (b <= 1.1610828712163664e+78) {
		tmp = 1.0 / -((b + sqrt((b * b) + (a * (c * -3.0)))) / c);
	} 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.3146037788049252e89

    1. Initial program 45.2

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

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

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

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

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

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

    if -1.3146037788049252e89 < b < -1.383572152898935e-212

    1. Initial program 7.7

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

    if -1.383572152898935e-212 < b < 1.16108287121636636e78

    1. Initial program 28.5

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

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

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

      \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{c}}}\]
    10. Using strategy rm
    11. Applied sub-neg_binary64_143510.4

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

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

    if 1.16108287121636636e78 < b

    1. Initial program 58.8

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

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

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

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

      \[\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 -1.3146037788049252 \cdot 10^{+89}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} + -0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq -1.3835721528989353 \cdot 10^{-212}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 1.1610828712163664 \cdot 10^{+78}:\\ \;\;\;\;\frac{1}{-\frac{b + \sqrt{b \cdot b + a \cdot \left(c \cdot -3\right)}}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array}\]

Reproduce

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