Average Error: 52.8 → 51.0
Time: 1.3m
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(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\frac{\mathsf{fma}\left(\left(\sqrt{\sqrt{{\left(\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)\right)}^{\frac{1}{3}} \cdot \sqrt[3]{\mathsf{fma}\left(\left(-3 \cdot c\right), a, \left(b \cdot b\right)\right) \cdot \mathsf{fma}\left(\left(-3 \cdot c\right), a, \left(b \cdot b\right)\right)}}}\right), \left(\sqrt{\sqrt{\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)}}\right), \left(-b\right)\right)}{3 \cdot a}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\frac{\mathsf{fma}\left(\left(\sqrt{\sqrt{{\left(\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)\right)}^{\frac{1}{3}} \cdot \sqrt[3]{\mathsf{fma}\left(\left(-3 \cdot c\right), a, \left(b \cdot b\right)\right) \cdot \mathsf{fma}\left(\left(-3 \cdot c\right), a, \left(b \cdot b\right)\right)}}}\right), \left(\sqrt{\sqrt{\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)}}\right), \left(-b\right)\right)}{3 \cdot a}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r17823996 = b;
        double r17823997 = -r17823996;
        double r17823998 = r17823996 * r17823996;
        double r17823999 = 3.0;
        double r17824000 = a;
        double r17824001 = r17823999 * r17824000;
        double r17824002 = c;
        double r17824003 = r17824001 * r17824002;
        double r17824004 = r17823998 - r17824003;
        double r17824005 = sqrt(r17824004);
        double r17824006 = r17823997 + r17824005;
        double r17824007 = r17824006 / r17824001;
        return r17824007;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r17824008 = -3.0;
        double r17824009 = a;
        double r17824010 = c;
        double r17824011 = r17824009 * r17824010;
        double r17824012 = b;
        double r17824013 = r17824012 * r17824012;
        double r17824014 = fma(r17824008, r17824011, r17824013);
        double r17824015 = 0.3333333333333333;
        double r17824016 = pow(r17824014, r17824015);
        double r17824017 = r17824008 * r17824010;
        double r17824018 = fma(r17824017, r17824009, r17824013);
        double r17824019 = r17824018 * r17824018;
        double r17824020 = cbrt(r17824019);
        double r17824021 = r17824016 * r17824020;
        double r17824022 = sqrt(r17824021);
        double r17824023 = sqrt(r17824022);
        double r17824024 = sqrt(r17824014);
        double r17824025 = sqrt(r17824024);
        double r17824026 = -r17824012;
        double r17824027 = fma(r17824023, r17824025, r17824026);
        double r17824028 = 3.0;
        double r17824029 = r17824028 * r17824009;
        double r17824030 = r17824027 / r17824029;
        return r17824030;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Initial program 52.8

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

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

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

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019125 +o rules:numerics
(FPCore (a b c d)
  :name "Cubic critical, 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) (* (* 3 a) c)))) (* 3 a)))