Average Error: 28.4 → 5.1
Time: 7.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} \mathbf{if}\;b \leq 0.2687084208203283:\\ \;\;\;\;\begin{array}{l} t_0 := \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\\ \frac{\frac{b \cdot b - t_0 \cdot t_0}{\left(-b\right) - t_0}}{3 \cdot a} \end{array}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{a \cdot \frac{c}{b}}{a} - \frac{\mathsf{fma}\left(\frac{{\left(a \cdot c\right)}^{2}}{{b}^{3}}, 1.125, \mathsf{fma}\left(1.6875, \frac{{\left(a \cdot c\right)}^{3}}{{b}^{5}}, 3.1640625 \cdot \frac{{\left(a \cdot c\right)}^{4}}{{b}^{7}}\right)\right)}{3 \cdot a}\\ \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 0.2687084208203283:\\
\;\;\;\;\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\\
\frac{\frac{b \cdot b - t_0 \cdot t_0}{\left(-b\right) - t_0}}{3 \cdot a}
\end{array}\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{a \cdot \frac{c}{b}}{a} - \frac{\mathsf{fma}\left(\frac{{\left(a \cdot c\right)}^{2}}{{b}^{3}}, 1.125, \mathsf{fma}\left(1.6875, \frac{{\left(a \cdot c\right)}^{3}}{{b}^{5}}, 3.1640625 \cdot \frac{{\left(a \cdot c\right)}^{4}}{{b}^{7}}\right)\right)}{3 \cdot a}\\


\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 0.2687084208203283)
   (let* ((t_0 (sqrt (- (* b b) (* (* 3.0 a) c)))))
     (/ (/ (- (* b b) (* t_0 t_0)) (- (- b) t_0)) (* 3.0 a)))
   (-
    (* -0.5 (/ (* a (/ c b)) a))
    (/
     (fma
      (/ (pow (* a c) 2.0) (pow b 3.0))
      1.125
      (fma
       1.6875
       (/ (pow (* a c) 3.0) (pow b 5.0))
       (* 3.1640625 (/ (pow (* a c) 4.0) (pow b 7.0)))))
     (* 3.0 a)))))
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 <= 0.2687084208203283) {
		double t_0_1 = sqrt((b * b) - ((3.0 * a) * c));
		tmp = (((b * b) - (t_0_1 * t_0_1)) / (-b - t_0_1)) / (3.0 * a);
	} else {
		tmp = (-0.5 * ((a * (c / b)) / a)) - (fma((pow((a * c), 2.0) / pow(b, 3.0)), 1.125, fma(1.6875, (pow((a * c), 3.0) / pow(b, 5.0)), (3.1640625 * (pow((a * c), 4.0) / pow(b, 7.0))))) / (3.0 * a));
	}
	return tmp;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 0.26870842082032831

    1. Initial program 10.3

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

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \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) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a} \]

    if 0.26870842082032831 < b

    1. Initial program 31.1

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

      \[\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. Simplified4.6

      \[\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 div-sub_binary644.6

      \[\leadsto \color{blue}{\frac{-1.5 \cdot \frac{c \cdot a}{b}}{3 \cdot a} - \frac{\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}} \]
    5. Simplified4.4

      \[\leadsto \color{blue}{-0.5 \cdot \frac{\frac{c}{b} \cdot a}{a}} - \frac{\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} \]
    6. Simplified4.4

      \[\leadsto -0.5 \cdot \frac{\frac{c}{b} \cdot a}{a} - \color{blue}{\frac{\mathsf{fma}\left(\frac{{\left(c \cdot a\right)}^{2}}{{b}^{3}}, 1.125, \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)}{3 \cdot a}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.1

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

Reproduce

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