Average Error: 43.7 → 0.2
Time: 7.0s
Precision: binary64
\[1.1102230246251565 \cdot 10^{-16} < a \land a < 9007199254740992 \land 1.1102230246251565 \cdot 10^{-16} < b \land b < 9007199254740992 \land 1.1102230246251565 \cdot 10^{-16} < c \land c < 9007199254740992\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
\[\frac{\frac{c \cdot 2}{-1}}{b + \sqrt{\mathsf{fma}\left(a, c \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{c \cdot 2}{-1}}{b + \sqrt{\mathsf{fma}\left(a, c \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
 (/ (/ (* c 2.0) -1.0) (+ b (sqrt (fma a (* c -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 ((c * 2.0) / -1.0) / (b + sqrt(fma(a, (c * -4.0), (b * b))));
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 43.7

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

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

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

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

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

    \[\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 frac-2neg_binary640.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)}} \]
  12. Applied distribute-frac-neg_binary640.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)}} \]
  13. Simplified0.2

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

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

Reproduce

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