Average Error: 28.3 → 5.3
Time: 8.4s
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 := \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\\ \mathbf{if}\;\frac{t_0 - b}{3 \cdot a} \leq -101.76990264424886:\\ \;\;\;\;\frac{{\left(-b\right)}^{3} + {t_0}^{3}}{\left(3 \cdot a\right) \cdot \left(b \cdot b + \left(t_0 \cdot t_0 + b \cdot t_0\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}}, -0.5625, \mathsf{fma}\left(\frac{{c}^{4} \cdot {a}^{3}}{{b}^{7}}, -1.0546875, \mathsf{fma}\left(\frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}, -0.375, -0.5 \cdot \frac{c}{b}\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 := \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\\
\mathbf{if}\;\frac{t_0 - b}{3 \cdot a} \leq -101.76990264424886:\\
\;\;\;\;\frac{{\left(-b\right)}^{3} + {t_0}^{3}}{\left(3 \cdot a\right) \cdot \left(b \cdot b + \left(t_0 \cdot t_0 + b \cdot t_0\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}}, -0.5625, \mathsf{fma}\left(\frac{{c}^{4} \cdot {a}^{3}}{{b}^{7}}, -1.0546875, \mathsf{fma}\left(\frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}, -0.375, -0.5 \cdot \frac{c}{b}\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 (sqrt (- (* b b) (* (* 3.0 a) c)))))
   (if (<= (/ (- t_0 b) (* 3.0 a)) -101.76990264424886)
     (/
      (+ (pow (- b) 3.0) (pow t_0 3.0))
      (* (* 3.0 a) (+ (* b b) (+ (* t_0 t_0) (* b t_0)))))
     (fma
      (/ (* (* a a) (pow c 3.0)) (pow b 5.0))
      -0.5625
      (fma
       (/ (* (pow c 4.0) (pow a 3.0)) (pow b 7.0))
       -1.0546875
       (fma (/ (* a (* c c)) (pow b 3.0)) -0.375 (* -0.5 (/ c b))))))))
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 = sqrt((b * b) - ((3.0 * a) * c));
	double tmp;
	if (((t_0 - b) / (3.0 * a)) <= -101.76990264424886) {
		tmp = (pow(-b, 3.0) + pow(t_0, 3.0)) / ((3.0 * a) * ((b * b) + ((t_0 * t_0) + (b * t_0))));
	} else {
		tmp = fma((((a * a) * pow(c, 3.0)) / pow(b, 5.0)), -0.5625, fma(((pow(c, 4.0) * pow(a, 3.0)) / pow(b, 7.0)), -1.0546875, fma(((a * (c * c)) / pow(b, 3.0)), -0.375, (-0.5 * (c / b)))));
	}
	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)) < -101.769902644248859

    1. Initial program 8.0

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

      \[\leadsto \frac{\color{blue}{\frac{{\left(-b\right)}^{3} + {\left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}^{3}}{\left(-b\right) \cdot \left(-b\right) + \left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \left(-b\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a} \]
    3. Applied associate-/l/_binary648.1

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

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

    1. Initial program 29.5

      \[\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 5.4

      \[\leadsto \frac{\color{blue}{-\left(1.5 \cdot \frac{c \cdot a}{b} + \left(1.125 \cdot \frac{{c}^{2} \cdot {a}^{2}}{{b}^{3}} + \left(3.1640625 \cdot \frac{{c}^{4} \cdot {a}^{4}}{{b}^{7}} + 1.6875 \cdot \frac{{c}^{3} \cdot {a}^{3}}{{b}^{5}}\right)\right)\right)}}{3 \cdot a} \]
    3. Simplified5.4

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{c \cdot a}{b} - \mathsf{fma}\left(1.125, \frac{\left(c \cdot a\right) \cdot \left(c \cdot a\right)}{{b}^{3}}, \mathsf{fma}\left(1.6875, \frac{{\left(c \cdot a\right)}^{3}}{{b}^{5}}, 3.1640625 \cdot \frac{{c}^{4} \cdot {a}^{4}}{{b}^{7}}\right)\right)}}{3 \cdot a} \]
    4. Applied frac-2neg_binary645.4

      \[\leadsto \color{blue}{\frac{-\left(-1.5 \cdot \frac{c \cdot a}{b} - \mathsf{fma}\left(1.125, \frac{\left(c \cdot a\right) \cdot \left(c \cdot a\right)}{{b}^{3}}, \mathsf{fma}\left(1.6875, \frac{{\left(c \cdot a\right)}^{3}}{{b}^{5}}, 3.1640625 \cdot \frac{{c}^{4} \cdot {a}^{4}}{{b}^{7}}\right)\right)\right)}{-3 \cdot a}} \]
    5. Simplified5.3

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(1.5, \frac{c}{b} \cdot a, \mathsf{fma}\left(1.125, \frac{{\left(c \cdot a\right)}^{2}}{{b}^{3}}, \mathsf{fma}\left(1.6875, \frac{{\left(c \cdot a\right)}^{3}}{{b}^{5}}, 3.1640625 \cdot \frac{{\left(c \cdot a\right)}^{4}}{{b}^{7}}\right)\right)\right)}}{-3 \cdot a} \]
    6. Simplified5.3

      \[\leadsto \frac{\mathsf{fma}\left(1.5, \frac{c}{b} \cdot a, \mathsf{fma}\left(1.125, \frac{{\left(c \cdot a\right)}^{2}}{{b}^{3}}, \mathsf{fma}\left(1.6875, \frac{{\left(c \cdot a\right)}^{3}}{{b}^{5}}, 3.1640625 \cdot \frac{{\left(c \cdot a\right)}^{4}}{{b}^{7}}\right)\right)\right)}{\color{blue}{a \cdot -3}} \]
    7. Taylor expanded in c around 0 5.1

      \[\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)} \]
    8. Simplified5.1

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

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

Reproduce

herbie shell --seed 2021329 
(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)))