Average Error: 33.5 → 17.4
Time: 24.6s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le 4.585517465995339 \cdot 10^{-129}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c, \left(a \cdot -3\right), \left(b \cdot b\right)\right)} - b}{\frac{3}{\frac{1}{a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{-2 \cdot \frac{b}{c}}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le 4.585517465995339 \cdot 10^{-129}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c, \left(a \cdot -3\right), \left(b \cdot b\right)\right)} - b}{\frac{3}{\frac{1}{a}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{-2 \cdot \frac{b}{c}}\\

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2015275 = b;
        double r2015276 = -r2015275;
        double r2015277 = r2015275 * r2015275;
        double r2015278 = 3.0;
        double r2015279 = a;
        double r2015280 = r2015278 * r2015279;
        double r2015281 = c;
        double r2015282 = r2015280 * r2015281;
        double r2015283 = r2015277 - r2015282;
        double r2015284 = sqrt(r2015283);
        double r2015285 = r2015276 + r2015284;
        double r2015286 = r2015285 / r2015280;
        return r2015286;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2015287 = b;
        double r2015288 = 4.585517465995339e-129;
        bool r2015289 = r2015287 <= r2015288;
        double r2015290 = c;
        double r2015291 = a;
        double r2015292 = -3.0;
        double r2015293 = r2015291 * r2015292;
        double r2015294 = r2015287 * r2015287;
        double r2015295 = fma(r2015290, r2015293, r2015294);
        double r2015296 = sqrt(r2015295);
        double r2015297 = r2015296 - r2015287;
        double r2015298 = 3.0;
        double r2015299 = 1.0;
        double r2015300 = r2015299 / r2015291;
        double r2015301 = r2015298 / r2015300;
        double r2015302 = r2015297 / r2015301;
        double r2015303 = -2.0;
        double r2015304 = r2015287 / r2015290;
        double r2015305 = r2015303 * r2015304;
        double r2015306 = r2015299 / r2015305;
        double r2015307 = r2015289 ? r2015302 : r2015306;
        return r2015307;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Split input into 2 regimes
  2. if b < 4.585517465995339e-129

    1. Initial program 20.9

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

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity20.9

      \[\leadsto \frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - \color{blue}{1 \cdot b}}{3 \cdot a}\]
    5. Applied *-un-lft-identity20.9

      \[\leadsto \frac{\color{blue}{1 \cdot \sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)}} - 1 \cdot b}{3 \cdot a}\]
    6. Applied distribute-lft-out--20.9

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b\right)}}{3 \cdot a}\]
    7. Applied associate-/l*21.0

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

      \[\leadsto \frac{1}{\color{blue}{\frac{3}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{a}}}}\]
    10. Using strategy rm
    11. Applied div-inv21.0

      \[\leadsto \frac{1}{\frac{3}{\color{blue}{\left(\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b\right) \cdot \frac{1}{a}}}}\]
    12. Applied *-un-lft-identity21.0

      \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot 3}}{\left(\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b\right) \cdot \frac{1}{a}}}\]
    13. Applied times-frac21.1

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b} \cdot \frac{3}{\frac{1}{a}}}}\]
    14. Applied associate-/r*21.0

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

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

    if 4.585517465995339e-129 < b

    1. Initial program 49.8

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

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity49.8

      \[\leadsto \frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - \color{blue}{1 \cdot b}}{3 \cdot a}\]
    5. Applied *-un-lft-identity49.8

      \[\leadsto \frac{\color{blue}{1 \cdot \sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)}} - 1 \cdot b}{3 \cdot a}\]
    6. Applied distribute-lft-out--49.8

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b\right)}}{3 \cdot a}\]
    7. Applied associate-/l*49.8

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

      \[\leadsto \frac{1}{\color{blue}{\frac{3}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{a}}}}\]
    10. Taylor expanded around 0 12.8

      \[\leadsto \frac{1}{\color{blue}{-2 \cdot \frac{b}{c}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification17.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 4.585517465995339 \cdot 10^{-129}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c, \left(a \cdot -3\right), \left(b \cdot b\right)\right)} - b}{\frac{3}{\frac{1}{a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{-2 \cdot \frac{b}{c}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019128 +o rules:numerics
(FPCore (a b c d)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))