Average Error: 28.2 → 5.3
Time: 6.2s
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(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
\[\begin{array}{l} \mathbf{if}\;b \leq 0.12224626186314973:\\ \;\;\;\;\begin{array}{l} t_0 := \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a \cdot 2}\\ \sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)} \end{array}\\ \mathbf{else}:\\ \;\;\;\;-\mathsf{fma}\left(2, \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}}, \mathsf{fma}\left(5, \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}}, \frac{c}{b} + \frac{c \cdot \left(a \cdot c\right)}{{b}^{3}}\right)\right)\\ \end{array} \]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \leq 0.12224626186314973:\\
\;\;\;\;\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a \cdot 2}\\
\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}
\end{array}\\

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


\end{array}
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
 :precision binary64
 (if (<= b 0.12224626186314973)
   (let* ((t_0 (/ (- (sqrt (- (* b b) (* (* 4.0 a) c))) b) (* a 2.0))))
     (cbrt (* t_0 (* t_0 t_0))))
   (-
    (fma
     2.0
     (/ (* (* a a) (pow c 3.0)) (pow b 5.0))
     (fma
      5.0
      (/ (* (pow a 3.0) (pow c 4.0)) (pow b 7.0))
      (+ (/ c b) (/ (* c (* a c)) (pow b 3.0))))))))
double code(double a, double b, double c) {
	return (-b + sqrt((b * b) - ((4.0 * a) * c))) / (2.0 * a);
}
double code(double a, double b, double c) {
	double tmp;
	if (b <= 0.12224626186314973) {
		double t_0_1 = (sqrt((b * b) - ((4.0 * a) * c)) - b) / (a * 2.0);
		tmp = cbrt(t_0_1 * (t_0_1 * t_0_1));
	} else {
		tmp = -fma(2.0, (((a * a) * pow(c, 3.0)) / pow(b, 5.0)), fma(5.0, ((pow(a, 3.0) * pow(c, 4.0)) / pow(b, 7.0)), ((c / b) + ((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 b < 0.122246261863149727

    1. Initial program 10.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Applied add-cbrt-cube_binary6410.4

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

    if 0.122246261863149727 < b

    1. Initial program 30.4

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

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

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

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

Reproduce

herbie shell --seed 2022081 
(FPCore (a b c)
  :name "Quadratic roots, 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) (* (* 4.0 a) c)))) (* 2.0 a)))