Average Error: 52.3 → 0.2
Time: 6.4s
Precision: binary64
\[4.930380657631324 \cdot 10^{-32} < a \land a < 2.028240960365167 \cdot 10^{+31} \land 4.930380657631324 \cdot 10^{-32} < b \land b < 2.028240960365167 \cdot 10^{+31} \land 4.930380657631324 \cdot 10^{-32} < c \land c < 2.028240960365167 \cdot 10^{+31}\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
\[\frac{\frac{-2 \cdot \left(c \cdot a\right)}{a}}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{\frac{-2 \cdot \left(c \cdot a\right)}{a}}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
 :precision binary64
 (/ (/ (* -2.0 (* c a)) a) (+ b (sqrt (fma c (* a -4.0) (* b 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) {
	return ((-2.0 * (c * a)) / a) / (b + sqrt(fma(c, (a * -4.0), (b * b))));
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 52.3

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

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

    \[\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} \]
  5. Applied frac-times_binary6452.3

    \[\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 0.5}{\left(\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} + b\right) \cdot a}} \]
  6. Simplified0.4

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

    \[\leadsto \frac{0.5 \cdot \mathsf{fma}\left(a, c \cdot -4, 0\right)}{\color{blue}{a \cdot \left(b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\right)}} \]
  8. Using strategy rm
  9. Applied times-frac_binary640.5

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

    \[\leadsto \frac{0.5}{a} \cdot \color{blue}{\frac{c \cdot \left(a \cdot -4\right)}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}} \]
  11. Using strategy rm
  12. Applied associate-*r/_binary640.3

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

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

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

Reproduce

herbie shell --seed 2021209 
(FPCore (a b c)
  :name "Quadratic roots, wide range"
  :precision binary64
  :pre (and (< 4.930380657631324e-32 a 2.028240960365167e+31) (< 4.930380657631324e-32 b 2.028240960365167e+31) (< 4.930380657631324e-32 c 2.028240960365167e+31))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))