Average Error: 52.6 → 0.1
Time: 6.6s
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. Applied associate-*l/_binary6452.6

    \[\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}} \]
  6. Simplified0.3

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

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

    \[\leadsto \color{blue}{\frac{-2 \cdot c}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}} \]
  9. Using strategy rm
  10. Applied *-un-lft-identity_binary640.1

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

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

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

    \[\leadsto \frac{-2 \cdot c}{b + 1 \cdot \color{blue}{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}} \]
  14. 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)))