Average Error: 43.9 → 0.2
Time: 7.3s
Precision: binary64
\[\left(\left(1.1102230246251565 \cdot 10^{-16} < a \land a < 9007199254740992\right) \land \left(1.1102230246251565 \cdot 10^{-16} < b \land b < 9007199254740992\right)\right) \land \left(1.1102230246251565 \cdot 10^{-16} < c \land c < 9007199254740992\right)\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
\[\begin{array}{l} t_0 := \mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)\\ \frac{-2 \cdot c}{\mathsf{fma}\left({t_0}^{0.25}, \sqrt{\sqrt{t_0}}, b\right)} \end{array} \]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)\\
\frac{-2 \cdot c}{\mathsf{fma}\left({t_0}^{0.25}, \sqrt{\sqrt{t_0}}, b\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
 (let* ((t_0 (fma a (* c -4.0) (* b b))))
   (/ (* -2.0 c) (fma (pow t_0 0.25) (sqrt (sqrt t_0)) b))))
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 t_0 = fma(a, (c * -4.0), (b * b));
	return (-2.0 * c) / fma(pow(t_0, 0.25), sqrt(sqrt(t_0)), b);
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 43.9

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Simplified43.9

    \[\leadsto \color{blue}{\left(\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b\right) \cdot \frac{0.5}{a}} \]
  3. Applied flip--_binary6443.9

    \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} \cdot \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b \cdot b}{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} + b}} \cdot \frac{0.5}{a} \]
  4. Applied associate-*l/_binary6443.9

    \[\leadsto \color{blue}{\frac{\left(\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} \cdot \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b \cdot b\right) \cdot \frac{0.5}{a}}{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} + b}} \]
  5. Simplified0.4

    \[\leadsto \frac{\color{blue}{\left(c \cdot \left(a \cdot -4\right) + 0\right) \cdot \frac{0.5}{a}}}{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} + b} \]
  6. Applied add-sqr-sqrt_binary640.5

    \[\leadsto \frac{\left(c \cdot \left(a \cdot -4\right) + 0\right) \cdot \frac{0.5}{a}}{\color{blue}{\sqrt{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}} + b} \]
  7. Applied fma-def_binary640.4

    \[\leadsto \frac{\left(c \cdot \left(a \cdot -4\right) + 0\right) \cdot \frac{0.5}{a}}{\color{blue}{\mathsf{fma}\left(\sqrt{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}, \sqrt{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}, b\right)}} \]
  8. Taylor expanded in c around 0 0.2

    \[\leadsto \frac{\color{blue}{-2 \cdot c}}{\mathsf{fma}\left(\sqrt{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}, \sqrt{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}, b\right)} \]
  9. Applied pow1_binary640.2

    \[\leadsto \frac{-2 \cdot c}{\mathsf{fma}\left(\sqrt{\sqrt{\color{blue}{{\left(\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)\right)}^{1}}}}, \sqrt{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}, b\right)} \]
  10. Applied sqrt-pow1_binary640.2

    \[\leadsto \frac{-2 \cdot c}{\mathsf{fma}\left(\sqrt{\color{blue}{{\left(\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)\right)}^{\left(\frac{1}{2}\right)}}}, \sqrt{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}, b\right)} \]
  11. Applied sqrt-pow1_binary640.2

    \[\leadsto \frac{-2 \cdot c}{\mathsf{fma}\left(\color{blue}{{\left(\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}}, \sqrt{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}, b\right)} \]
  12. Final simplification0.2

    \[\leadsto \frac{-2 \cdot c}{\mathsf{fma}\left({\left(\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)\right)}^{0.25}, \sqrt{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}, b\right)} \]

Reproduce

herbie shell --seed 2021275 
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :precision binary64
  :pre (and (and (and (< 1.1102230246251565e-16 a) (< a 9007199254740992.0)) (and (< 1.1102230246251565e-16 b) (< b 9007199254740992.0))) (and (< 1.1102230246251565e-16 c) (< c 9007199254740992.0)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))