Average Error: 52.6 → 0.1
Time: 6.7s
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{-2 \cdot c}{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{-2 \cdot c}{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) (+ 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) / (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.6

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

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

    \[\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. Simplified0.4

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{-2 \cdot \left(c \cdot a\right)}{a}}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}} \]
  10. Using strategy rm
  11. Applied clear-num_binary640.4

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

    \[\leadsto \frac{1}{\color{blue}{\frac{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}{-2 \cdot \left(c \cdot 1\right)}}} \]
  13. Using strategy rm
  14. Applied div-inv_binary640.3

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

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

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

Reproduce

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