Average Error: 52.8 → 0.4
Time: 19.4s
Precision: 64
\[4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt a \lt 20282409603651670423947251286016 \land 4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt b \lt 20282409603651670423947251286016 \land 4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt c \lt 20282409603651670423947251286016\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\frac{\frac{c}{\frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}}{4 \cdot a}}}{a} \cdot \frac{1}{2}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{\frac{c}{\frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}}{4 \cdot a}}}{a} \cdot \frac{1}{2}
double f(double a, double b, double c) {
        double r35806 = b;
        double r35807 = -r35806;
        double r35808 = r35806 * r35806;
        double r35809 = 4.0;
        double r35810 = a;
        double r35811 = r35809 * r35810;
        double r35812 = c;
        double r35813 = r35811 * r35812;
        double r35814 = r35808 - r35813;
        double r35815 = sqrt(r35814);
        double r35816 = r35807 + r35815;
        double r35817 = 2.0;
        double r35818 = r35817 * r35810;
        double r35819 = r35816 / r35818;
        return r35819;
}

double f(double a, double b, double c) {
        double r35820 = c;
        double r35821 = b;
        double r35822 = -r35821;
        double r35823 = 4.0;
        double r35824 = a;
        double r35825 = r35823 * r35824;
        double r35826 = r35825 * r35820;
        double r35827 = -r35826;
        double r35828 = fma(r35821, r35821, r35827);
        double r35829 = sqrt(r35828);
        double r35830 = r35822 - r35829;
        double r35831 = r35830 / r35825;
        double r35832 = r35820 / r35831;
        double r35833 = r35832 / r35824;
        double r35834 = 1.0;
        double r35835 = 2.0;
        double r35836 = r35834 / r35835;
        double r35837 = r35833 * r35836;
        return r35837;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 52.8

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
  2. Using strategy rm
  3. Applied flip-+52.8

    \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
  4. Simplified0.4

    \[\leadsto \frac{\frac{\color{blue}{0 + c \cdot \left(4 \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
  5. Using strategy rm
  6. Applied add-cube-cbrt0.9

    \[\leadsto \frac{\frac{0 + c \cdot \left(4 \cdot a\right)}{\left(-b\right) - \color{blue}{\left(\sqrt[3]{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt[3]{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right) \cdot \sqrt[3]{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}}{2 \cdot a}\]
  7. Applied add-sqr-sqrt0.9

    \[\leadsto \frac{\frac{0 + c \cdot \left(4 \cdot a\right)}{\left(-\color{blue}{\sqrt{b} \cdot \sqrt{b}}\right) - \left(\sqrt[3]{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt[3]{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right) \cdot \sqrt[3]{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
  8. Applied distribute-lft-neg-in0.9

    \[\leadsto \frac{\frac{0 + c \cdot \left(4 \cdot a\right)}{\color{blue}{\left(-\sqrt{b}\right) \cdot \sqrt{b}} - \left(\sqrt[3]{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt[3]{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right) \cdot \sqrt[3]{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
  9. Applied prod-diff0.9

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

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

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

    \[\leadsto \frac{\frac{0 + c \cdot \left(4 \cdot a\right)}{\color{blue}{1 \cdot \left(\mathsf{fma}\left(\sqrt{b}, -\sqrt{b}, -\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \left(-1 + 1\right)\right)}}}{2 \cdot a}\]
  14. Applied *-un-lft-identity0.4

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019212 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, wide range"
  :precision binary64
  :pre (and (< 4.93038e-32 a 2.02824e31) (< 4.93038e-32 b 2.02824e31) (< 4.93038e-32 c 2.02824e31))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))