Average Error: 28.4 → 6.5
Time: 6.1s
Precision: binary64
\[\left(\left(1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156\right) \land \left(1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156\right)\right) \land \left(1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\right)\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
\[\begin{array}{l} t_0 := \left(3 \cdot a\right) \cdot c\\ \mathbf{if}\;\frac{\sqrt{b \cdot b - t_0} - b}{3 \cdot a} \leq -0.005147333578013545:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right) + \mathsf{fma}\left(-c, 3 \cdot a, t_0\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-\mathsf{fma}\left(0.5625, \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}}, \mathsf{fma}\left(1.0546875, \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}}, \mathsf{fma}\left(0.5, \frac{c}{b}, 0.375 \cdot \frac{c \cdot \left(a \cdot c\right)}{{b}^{3}}\right)\right)\right)\\ \end{array} \]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
t_0 := \left(3 \cdot a\right) \cdot c\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - t_0} - b}{3 \cdot a} \leq -0.005147333578013545:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right) + \mathsf{fma}\left(-c, 3 \cdot a, t_0\right)} - b}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(0.5625, \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}}, \mathsf{fma}\left(1.0546875, \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}}, \mathsf{fma}\left(0.5, \frac{c}{b}, 0.375 \cdot \frac{c \cdot \left(a \cdot c\right)}{{b}^{3}}\right)\right)\right)\\


\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
 (let* ((t_0 (* (* 3.0 a) c)))
   (if (<= (/ (- (sqrt (- (* b b) t_0)) b) (* 3.0 a)) -0.005147333578013545)
     (/
      (- (sqrt (+ (fma b b (* c (* a -3.0))) (fma (- c) (* 3.0 a) t_0))) b)
      (* 3.0 a))
     (-
      (fma
       0.5625
       (/ (* (* a a) (pow c 3.0)) (pow b 5.0))
       (fma
        1.0546875
        (/ (* (pow a 3.0) (pow c 4.0)) (pow b 7.0))
        (fma 0.5 (/ c b) (* 0.375 (/ (* c (* a c)) (pow b 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 t_0 = (3.0 * a) * c;
	double tmp;
	if (((sqrt((b * b) - t_0) - b) / (3.0 * a)) <= -0.005147333578013545) {
		tmp = (sqrt(fma(b, b, (c * (a * -3.0))) + fma(-c, (3.0 * a), t_0)) - b) / (3.0 * a);
	} else {
		tmp = -fma(0.5625, (((a * a) * pow(c, 3.0)) / pow(b, 5.0)), fma(1.0546875, ((pow(a, 3.0) * pow(c, 4.0)) / pow(b, 7.0)), fma(0.5, (c / b), (0.375 * ((c * (a * c)) / pow(b, 3.0))))));
	}
	return tmp;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.00514733357801354461

    1. Initial program 14.2

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

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

    if -0.00514733357801354461 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

    1. Initial program 34.4

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

      \[\leadsto \color{blue}{-\left(0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(1.0546875 \cdot \frac{{c}^{4} \cdot {a}^{3}}{{b}^{7}} + \left(0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + 0.5 \cdot \frac{c}{b}\right)\right)\right)} \]
    3. Simplified3.3

      \[\leadsto \color{blue}{-\mathsf{fma}\left(0.5625, \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}}, \mathsf{fma}\left(1.0546875, \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}}, \mathsf{fma}\left(0.5, \frac{c}{b}, 0.375 \cdot \frac{c \cdot \left(c \cdot a\right)}{{b}^{3}}\right)\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification6.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.005147333578013545:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right) + \mathsf{fma}\left(-c, 3 \cdot a, \left(3 \cdot a\right) \cdot c\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-\mathsf{fma}\left(0.5625, \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}}, \mathsf{fma}\left(1.0546875, \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}}, \mathsf{fma}\left(0.5, \frac{c}{b}, 0.375 \cdot \frac{c \cdot \left(a \cdot c\right)}{{b}^{3}}\right)\right)\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022067 
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))