Average Error: 52.9 → 51.1
Time: 1.7m
Precision: 64
\[4.930380657631324 \cdot 10^{-32} \lt a \lt 2.028240960365167 \cdot 10^{+31} \land 4.930380657631324 \cdot 10^{-32} \lt b \lt 2.028240960365167 \cdot 10^{+31} \land 4.930380657631324 \cdot 10^{-32} \lt c \lt 2.028240960365167 \cdot 10^{+31}\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\frac{\frac{\mathsf{fma}\left(\left(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(a \cdot -4\right), \left(b \cdot b\right)\right)}}\right), \left(\sqrt{\sqrt{\sqrt[3]{\mathsf{fma}\left(\left(c \cdot -4\right), a, \left(b \cdot b\right)\right) \cdot \mathsf{fma}\left(\left(c \cdot -4\right), a, \left(b \cdot b\right)\right)} \cdot {\left(\mathsf{fma}\left(c, \left(a \cdot -4\right), \left(b \cdot b\right)\right)\right)}^{\frac{1}{3}}}}\right), \left(-b\right)\right)}{2}}{a}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{\frac{\mathsf{fma}\left(\left(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(a \cdot -4\right), \left(b \cdot b\right)\right)}}\right), \left(\sqrt{\sqrt{\sqrt[3]{\mathsf{fma}\left(\left(c \cdot -4\right), a, \left(b \cdot b\right)\right) \cdot \mathsf{fma}\left(\left(c \cdot -4\right), a, \left(b \cdot b\right)\right)} \cdot {\left(\mathsf{fma}\left(c, \left(a \cdot -4\right), \left(b \cdot b\right)\right)\right)}^{\frac{1}{3}}}}\right), \left(-b\right)\right)}{2}}{a}
double f(double a, double b, double c) {
        double r6019267 = b;
        double r6019268 = -r6019267;
        double r6019269 = r6019267 * r6019267;
        double r6019270 = 4.0;
        double r6019271 = a;
        double r6019272 = r6019270 * r6019271;
        double r6019273 = c;
        double r6019274 = r6019272 * r6019273;
        double r6019275 = r6019269 - r6019274;
        double r6019276 = sqrt(r6019275);
        double r6019277 = r6019268 + r6019276;
        double r6019278 = 2.0;
        double r6019279 = r6019278 * r6019271;
        double r6019280 = r6019277 / r6019279;
        return r6019280;
}

double f(double a, double b, double c) {
        double r6019281 = c;
        double r6019282 = a;
        double r6019283 = -4.0;
        double r6019284 = r6019282 * r6019283;
        double r6019285 = b;
        double r6019286 = r6019285 * r6019285;
        double r6019287 = fma(r6019281, r6019284, r6019286);
        double r6019288 = sqrt(r6019287);
        double r6019289 = sqrt(r6019288);
        double r6019290 = r6019281 * r6019283;
        double r6019291 = fma(r6019290, r6019282, r6019286);
        double r6019292 = r6019291 * r6019291;
        double r6019293 = cbrt(r6019292);
        double r6019294 = 0.3333333333333333;
        double r6019295 = pow(r6019287, r6019294);
        double r6019296 = r6019293 * r6019295;
        double r6019297 = sqrt(r6019296);
        double r6019298 = sqrt(r6019297);
        double r6019299 = -r6019285;
        double r6019300 = fma(r6019289, r6019298, r6019299);
        double r6019301 = 2.0;
        double r6019302 = r6019300 / r6019301;
        double r6019303 = r6019302 / r6019282;
        return r6019303;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 52.9

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

    \[\leadsto \color{blue}{\frac{\frac{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)} - b}{2}}{a}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt52.7

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

    \[\leadsto \frac{\frac{\color{blue}{\mathsf{fma}\left(\left(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)}}\right), \left(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)}}\right), \left(-b\right)\right)}}{2}}{a}\]
  6. Using strategy rm
  7. Applied add-cbrt-cube52.1

    \[\leadsto \frac{\frac{\mathsf{fma}\left(\left(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)}}\right), \left(\sqrt{\sqrt{\color{blue}{\sqrt[3]{\left(\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right) \cdot \mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)\right) \cdot \mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)}}}}\right), \left(-b\right)\right)}{2}}{a}\]
  8. Using strategy rm
  9. Applied pow1/351.5

    \[\leadsto \frac{\frac{\mathsf{fma}\left(\left(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)}}\right), \left(\sqrt{\sqrt{\color{blue}{{\left(\left(\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right) \cdot \mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)\right) \cdot \mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)\right)}^{\frac{1}{3}}}}}\right), \left(-b\right)\right)}{2}}{a}\]
  10. Using strategy rm
  11. Applied unpow-prod-down51.5

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

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

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

Reproduce

herbie shell --seed 2019125 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, wide range"
  :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 a) c)))) (* 2 a)))