Average Error: 28.9 → 0.3
Time: 1.9m
Precision: 64
\[1.0536712127723509 \cdot 10^{-08} \lt a \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt b \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt c \lt 94906265.62425156\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\frac{c}{\left(b + \sqrt{\mathsf{fma}\left(\left(a \cdot c\right), -4, \left(b \cdot b\right)\right)}\right) \cdot \frac{-1}{2}}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{c}{\left(b + \sqrt{\mathsf{fma}\left(\left(a \cdot c\right), -4, \left(b \cdot b\right)\right)}\right) \cdot \frac{-1}{2}}
double f(double a, double b, double c) {
        double r10485936 = b;
        double r10485937 = -r10485936;
        double r10485938 = r10485936 * r10485936;
        double r10485939 = 4.0;
        double r10485940 = a;
        double r10485941 = r10485939 * r10485940;
        double r10485942 = c;
        double r10485943 = r10485941 * r10485942;
        double r10485944 = r10485938 - r10485943;
        double r10485945 = sqrt(r10485944);
        double r10485946 = r10485937 + r10485945;
        double r10485947 = 2.0;
        double r10485948 = r10485947 * r10485940;
        double r10485949 = r10485946 / r10485948;
        return r10485949;
}

double f(double a, double b, double c) {
        double r10485950 = c;
        double r10485951 = b;
        double r10485952 = a;
        double r10485953 = r10485952 * r10485950;
        double r10485954 = -4.0;
        double r10485955 = r10485951 * r10485951;
        double r10485956 = fma(r10485953, r10485954, r10485955);
        double r10485957 = sqrt(r10485956);
        double r10485958 = r10485951 + r10485957;
        double r10485959 = -0.5;
        double r10485960 = r10485958 * r10485959;
        double r10485961 = r10485950 / r10485960;
        return r10485961;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 28.9

    \[\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-+28.9

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

    \[\leadsto \frac{\frac{\color{blue}{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 *-un-lft-identity0.5

    \[\leadsto \frac{\frac{c \cdot \left(4 \cdot a\right)}{\left(-b\right) - \color{blue}{1 \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
  7. Applied *-un-lft-identity0.5

    \[\leadsto \frac{\frac{c \cdot \left(4 \cdot a\right)}{\left(-\color{blue}{1 \cdot b}\right) - 1 \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
  8. Applied distribute-rgt-neg-in0.5

    \[\leadsto \frac{\frac{c \cdot \left(4 \cdot a\right)}{\color{blue}{1 \cdot \left(-b\right)} - 1 \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
  9. Applied distribute-lft-out--0.5

    \[\leadsto \frac{\frac{c \cdot \left(4 \cdot a\right)}{\color{blue}{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}{2 \cdot a}\]
  10. Applied times-frac0.5

    \[\leadsto \frac{\color{blue}{\frac{c}{1} \cdot \frac{4 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
  11. Applied associate-/l*0.3

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

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

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

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

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

Reproduce

herbie shell --seed 2019125 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))