Average Error: 52.7 → 52.0
Time: 1.0m
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{\sqrt[3]{\left(\mathsf{fma}\left(c, \left(a \cdot -4\right), \left(b \cdot b\right)\right) \cdot \mathsf{fma}\left(c, \left(a \cdot -4\right), \left(b \cdot b\right)\right)\right) \cdot \mathsf{fma}\left(c, \left(a \cdot -4\right), \left(b \cdot b\right)\right)}}}\right), \left(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(a \cdot -4\right), \left(b \cdot b\right)\right)}}\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{\sqrt[3]{\left(\mathsf{fma}\left(c, \left(a \cdot -4\right), \left(b \cdot b\right)\right) \cdot \mathsf{fma}\left(c, \left(a \cdot -4\right), \left(b \cdot b\right)\right)\right) \cdot \mathsf{fma}\left(c, \left(a \cdot -4\right), \left(b \cdot b\right)\right)}}}\right), \left(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(a \cdot -4\right), \left(b \cdot b\right)\right)}}\right), \left(-b\right)\right)}{2}}{a}
double f(double a, double b, double c) {
        double r2541004 = b;
        double r2541005 = -r2541004;
        double r2541006 = r2541004 * r2541004;
        double r2541007 = 4.0;
        double r2541008 = a;
        double r2541009 = r2541007 * r2541008;
        double r2541010 = c;
        double r2541011 = r2541009 * r2541010;
        double r2541012 = r2541006 - r2541011;
        double r2541013 = sqrt(r2541012);
        double r2541014 = r2541005 + r2541013;
        double r2541015 = 2.0;
        double r2541016 = r2541015 * r2541008;
        double r2541017 = r2541014 / r2541016;
        return r2541017;
}

double f(double a, double b, double c) {
        double r2541018 = c;
        double r2541019 = a;
        double r2541020 = -4.0;
        double r2541021 = r2541019 * r2541020;
        double r2541022 = b;
        double r2541023 = r2541022 * r2541022;
        double r2541024 = fma(r2541018, r2541021, r2541023);
        double r2541025 = r2541024 * r2541024;
        double r2541026 = r2541025 * r2541024;
        double r2541027 = cbrt(r2541026);
        double r2541028 = sqrt(r2541027);
        double r2541029 = sqrt(r2541028);
        double r2541030 = sqrt(r2541024);
        double r2541031 = sqrt(r2541030);
        double r2541032 = -r2541022;
        double r2541033 = fma(r2541029, r2541031, r2541032);
        double r2541034 = 2.0;
        double r2541035 = r2541033 / r2541034;
        double r2541036 = r2541035 / r2541019;
        return r2541036;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 52.7

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

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

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

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

    \[\leadsto \frac{\frac{\mathsf{fma}\left(\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(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)}}\right), \left(-b\right)\right)}{2}}{a}\]
  8. Final simplification52.0

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

Reproduce

herbie shell --seed 2019124 +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)))