Average Error: 34.4 → 12.8
Time: 5.3s
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.3337681397070838 \cdot 10^{+154}:\\ \;\;\;\;\frac{\left(1.5 \cdot \frac{a \cdot c}{b} - b\right) - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 1.9979259851056098 \cdot 10^{-117}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 3.816879541232831 \cdot 10^{+141}:\\ \;\;\;\;\frac{\frac{a \cdot \left(c \cdot -3\right)}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a \cdot c}{b} \cdot -1.5}{a \cdot 3}\\ \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.3337681397070838 \cdot 10^{+154}:\\
\;\;\;\;\frac{\left(1.5 \cdot \frac{a \cdot c}{b} - b\right) - b}{a \cdot 3}\\

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

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

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

\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.3337681397070838e+154)
   (/ (- (- (* 1.5 (/ (* a c) b)) b) b) (* a 3.0))
   (if (<= b 1.9979259851056098e-117)
     (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
     (if (<= b 3.816879541232831e+141)
       (/
        (/ (* a (* c -3.0)) (+ b (sqrt (- (* b b) (* c (* a 3.0))))))
        (* a 3.0))
       (/ (* (/ (* a c) b) -1.5) (* a 3.0))))))
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.3337681397070838e+154) {
		tmp = (((1.5 * ((a * c) / b)) - b) - b) / (a * 3.0);
	} else if (b <= 1.9979259851056098e-117) {
		tmp = (sqrt((b * b) - (c * (a * 3.0))) - b) / (a * 3.0);
	} else if (b <= 3.816879541232831e+141) {
		tmp = ((a * (c * -3.0)) / (b + sqrt((b * b) - (c * (a * 3.0))))) / (a * 3.0);
	} else {
		tmp = (((a * c) / b) * -1.5) / (a * 3.0);
	}
	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.33376813970708378e154

    1. Initial program 64.0

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

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

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

    if -1.33376813970708378e154 < b < 1.9979259851056098e-117

    1. Initial program 11.1

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

    if 1.9979259851056098e-117 < b < 3.81687954123283089e141

    1. Initial program 41.9

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

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

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

      \[\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}\]

    if 3.81687954123283089e141 < b

    1. Initial program 62.8

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    4. Simplified14.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.3337681397070838 \cdot 10^{+154}:\\ \;\;\;\;\frac{\left(1.5 \cdot \frac{a \cdot c}{b} - b\right) - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 1.9979259851056098 \cdot 10^{-117}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 3.816879541232831 \cdot 10^{+141}:\\ \;\;\;\;\frac{\frac{a \cdot \left(c \cdot -3\right)}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a \cdot c}{b} \cdot -1.5}{a \cdot 3}\\ \end{array}\]

Reproduce

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