Average Error: 28.7 → 14.9
Time: 30.9s
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(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -3.5237154995471856 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right), \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}, \left(b \cdot b\right) \cdot \left(-b\right)\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}, \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} + b, b \cdot b\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-3}{2} \cdot a}{a} \cdot \frac{c}{3 \cdot b}\\ \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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -3.5237154995471856 \cdot 10^{-05}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right), \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}, \left(b \cdot b\right) \cdot \left(-b\right)\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}, \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} + b, b \cdot b\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r3941723 = b;
        double r3941724 = -r3941723;
        double r3941725 = r3941723 * r3941723;
        double r3941726 = 3.0;
        double r3941727 = a;
        double r3941728 = r3941726 * r3941727;
        double r3941729 = c;
        double r3941730 = r3941728 * r3941729;
        double r3941731 = r3941725 - r3941730;
        double r3941732 = sqrt(r3941731);
        double r3941733 = r3941724 + r3941732;
        double r3941734 = r3941733 / r3941728;
        return r3941734;
}

double f(double a, double b, double c) {
        double r3941735 = b;
        double r3941736 = r3941735 * r3941735;
        double r3941737 = 3.0;
        double r3941738 = a;
        double r3941739 = r3941737 * r3941738;
        double r3941740 = c;
        double r3941741 = r3941739 * r3941740;
        double r3941742 = r3941736 - r3941741;
        double r3941743 = sqrt(r3941742);
        double r3941744 = -r3941735;
        double r3941745 = r3941743 + r3941744;
        double r3941746 = r3941745 / r3941739;
        double r3941747 = -3.5237154995471856e-05;
        bool r3941748 = r3941746 <= r3941747;
        double r3941749 = -3.0;
        double r3941750 = r3941749 * r3941740;
        double r3941751 = fma(r3941738, r3941750, r3941736);
        double r3941752 = sqrt(r3941751);
        double r3941753 = r3941736 * r3941744;
        double r3941754 = fma(r3941751, r3941752, r3941753);
        double r3941755 = r3941752 + r3941735;
        double r3941756 = fma(r3941752, r3941755, r3941736);
        double r3941757 = r3941754 / r3941756;
        double r3941758 = r3941757 / r3941739;
        double r3941759 = -1.5;
        double r3941760 = r3941759 * r3941738;
        double r3941761 = r3941760 / r3941738;
        double r3941762 = r3941737 * r3941735;
        double r3941763 = r3941740 / r3941762;
        double r3941764 = r3941761 * r3941763;
        double r3941765 = r3941748 ? r3941758 : r3941764;
        return r3941765;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -3.5237154995471856e-05

    1. Initial program 16.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied flip3-+16.7

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

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

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

    if -3.5237154995471856e-05 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 39.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around inf 14.0

      \[\leadsto \frac{\color{blue}{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity14.0

      \[\leadsto \frac{\frac{-3}{2} \cdot \frac{a \cdot c}{\color{blue}{1 \cdot b}}}{3 \cdot a}\]
    5. Applied times-frac14.0

      \[\leadsto \frac{\frac{-3}{2} \cdot \color{blue}{\left(\frac{a}{1} \cdot \frac{c}{b}\right)}}{3 \cdot a}\]
    6. Applied associate-*r*13.9

      \[\leadsto \frac{\color{blue}{\left(\frac{-3}{2} \cdot \frac{a}{1}\right) \cdot \frac{c}{b}}}{3 \cdot a}\]
    7. Simplified13.9

      \[\leadsto \frac{\color{blue}{\left(\frac{-3}{2} \cdot a\right)} \cdot \frac{c}{b}}{3 \cdot a}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity13.9

      \[\leadsto \frac{\left(\frac{-3}{2} \cdot a\right) \cdot \frac{c}{b}}{3 \cdot \color{blue}{\left(1 \cdot a\right)}}\]
    10. Applied associate-*r*13.9

      \[\leadsto \frac{\left(\frac{-3}{2} \cdot a\right) \cdot \frac{c}{b}}{\color{blue}{\left(3 \cdot 1\right) \cdot a}}\]
    11. Applied *-commutative13.9

      \[\leadsto \frac{\color{blue}{\frac{c}{b} \cdot \left(\frac{-3}{2} \cdot a\right)}}{\left(3 \cdot 1\right) \cdot a}\]
    12. Applied times-frac13.9

      \[\leadsto \color{blue}{\frac{\frac{c}{b}}{3 \cdot 1} \cdot \frac{\frac{-3}{2} \cdot a}{a}}\]
    13. Simplified14.0

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

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

Reproduce

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