Average Error: 28.9 → 9.3
Time: 1.1m
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}\;b \le 0.9138784421621164:\\ \;\;\;\;\frac{\left(\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot \left(-3 \cdot c\right)\right)\right)} \cdot \left(a \cdot \left(-3 \cdot c\right)\right) + \sqrt{\mathsf{fma}\left(b, b, \left(a \cdot \left(-3 \cdot c\right)\right)\right)} \cdot \left(b \cdot b\right)\right) - b \cdot \left(b \cdot b\right)}{\left(a \cdot 3\right) \cdot \left(\sqrt{\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)} \cdot \sqrt{\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)} + \left(b \cdot \sqrt{\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)} + b \cdot b\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{3}}{a} \cdot \frac{\mathsf{fma}\left(\frac{-9}{2}, \left(b \cdot \left(a \cdot c\right)\right), \left(\frac{\left(a \cdot c\right) \cdot \left(a \cdot c\right)}{b} \cdot \frac{27}{8}\right)\right)}{\mathsf{fma}\left(\left(\sqrt{\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)}\right), b, \left(\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right) + b \cdot b\right)\right)}\\ \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 0.9138784421621164:\\
\;\;\;\;\frac{\left(\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot \left(-3 \cdot c\right)\right)\right)} \cdot \left(a \cdot \left(-3 \cdot c\right)\right) + \sqrt{\mathsf{fma}\left(b, b, \left(a \cdot \left(-3 \cdot c\right)\right)\right)} \cdot \left(b \cdot b\right)\right) - b \cdot \left(b \cdot b\right)}{\left(a \cdot 3\right) \cdot \left(\sqrt{\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)} \cdot \sqrt{\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)} + \left(b \cdot \sqrt{\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)} + b \cdot b\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{3}}{a} \cdot \frac{\mathsf{fma}\left(\frac{-9}{2}, \left(b \cdot \left(a \cdot c\right)\right), \left(\frac{\left(a \cdot c\right) \cdot \left(a \cdot c\right)}{b} \cdot \frac{27}{8}\right)\right)}{\mathsf{fma}\left(\left(\sqrt{\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)}\right), b, \left(\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right) + b \cdot b\right)\right)}\\

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r11308928 = b;
        double r11308929 = -r11308928;
        double r11308930 = r11308928 * r11308928;
        double r11308931 = 3.0;
        double r11308932 = a;
        double r11308933 = r11308931 * r11308932;
        double r11308934 = c;
        double r11308935 = r11308933 * r11308934;
        double r11308936 = r11308930 - r11308935;
        double r11308937 = sqrt(r11308936);
        double r11308938 = r11308929 + r11308937;
        double r11308939 = r11308938 / r11308933;
        return r11308939;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r11308940 = b;
        double r11308941 = 0.9138784421621164;
        bool r11308942 = r11308940 <= r11308941;
        double r11308943 = a;
        double r11308944 = -3.0;
        double r11308945 = c;
        double r11308946 = r11308944 * r11308945;
        double r11308947 = r11308943 * r11308946;
        double r11308948 = fma(r11308940, r11308940, r11308947);
        double r11308949 = sqrt(r11308948);
        double r11308950 = r11308949 * r11308947;
        double r11308951 = r11308940 * r11308940;
        double r11308952 = r11308949 * r11308951;
        double r11308953 = r11308950 + r11308952;
        double r11308954 = r11308940 * r11308951;
        double r11308955 = r11308953 - r11308954;
        double r11308956 = 3.0;
        double r11308957 = r11308943 * r11308956;
        double r11308958 = r11308943 * r11308945;
        double r11308959 = fma(r11308944, r11308958, r11308951);
        double r11308960 = sqrt(r11308959);
        double r11308961 = r11308960 * r11308960;
        double r11308962 = r11308940 * r11308960;
        double r11308963 = r11308962 + r11308951;
        double r11308964 = r11308961 + r11308963;
        double r11308965 = r11308957 * r11308964;
        double r11308966 = r11308955 / r11308965;
        double r11308967 = 0.3333333333333333;
        double r11308968 = r11308967 / r11308943;
        double r11308969 = -4.5;
        double r11308970 = r11308940 * r11308958;
        double r11308971 = r11308958 * r11308958;
        double r11308972 = r11308971 / r11308940;
        double r11308973 = 3.375;
        double r11308974 = r11308972 * r11308973;
        double r11308975 = fma(r11308969, r11308970, r11308974);
        double r11308976 = r11308959 + r11308951;
        double r11308977 = fma(r11308960, r11308940, r11308976);
        double r11308978 = r11308975 / r11308977;
        double r11308979 = r11308968 * r11308978;
        double r11308980 = r11308942 ? r11308966 : r11308979;
        return r11308980;
}

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 < 0.9138784421621164

    1. Initial program 12.0

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

      \[\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 flip3--12.1

      \[\leadsto \frac{\color{blue}{\frac{{\left(\sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right)}^{3} - {b}^{3}}{\sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} + \left(b \cdot b + \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot b\right)}}}{3 \cdot a}\]
    5. Applied associate-/l/12.1

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

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

      \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot \left(-3 \cdot c\right)\right)\right)} \cdot \color{blue}{\left(b \cdot b + a \cdot \left(-3 \cdot c\right)\right)} - b \cdot \left(b \cdot b\right)}{\left(3 \cdot a\right) \cdot \left(\sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} + \left(b \cdot b + \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot b\right)\right)}\]
    9. Applied distribute-lft-in11.2

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

    if 0.9138784421621164 < b

    1. Initial program 32.0

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

      \[\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 flip3--32.1

      \[\leadsto \frac{\color{blue}{\frac{{\left(\sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right)}^{3} - {b}^{3}}{\sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} + \left(b \cdot b + \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot b\right)}}}{3 \cdot a}\]
    5. Applied associate-/l/32.1

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

      \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot \left(-3 \cdot c\right)\right)\right)} \cdot \mathsf{fma}\left(b, b, \left(a \cdot \left(-3 \cdot c\right)\right)\right) - b \cdot \left(b \cdot b\right)}}{\left(3 \cdot a\right) \cdot \left(\sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} + \left(b \cdot b + \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot b\right)\right)}\]
    7. Taylor expanded around inf 9.0

      \[\leadsto \frac{\color{blue}{\frac{27}{8} \cdot \frac{{a}^{2} \cdot {c}^{2}}{b} - \frac{9}{2} \cdot \left(a \cdot \left(b \cdot c\right)\right)}}{\left(3 \cdot a\right) \cdot \left(\sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} + \left(b \cdot b + \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot b\right)\right)}\]
    8. Simplified9.0

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{-9}{2}, \left(\left(a \cdot c\right) \cdot b\right), \left(\frac{27}{8} \cdot \frac{\left(a \cdot c\right) \cdot \left(a \cdot c\right)}{b}\right)\right)}}{\left(3 \cdot a\right) \cdot \left(\sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} + \left(b \cdot b + \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot b\right)\right)}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity9.0

      \[\leadsto \frac{\color{blue}{1 \cdot \mathsf{fma}\left(\frac{-9}{2}, \left(\left(a \cdot c\right) \cdot b\right), \left(\frac{27}{8} \cdot \frac{\left(a \cdot c\right) \cdot \left(a \cdot c\right)}{b}\right)\right)}}{\left(3 \cdot a\right) \cdot \left(\sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} + \left(b \cdot b + \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot b\right)\right)}\]
    11. Applied times-frac9.0

      \[\leadsto \color{blue}{\frac{1}{3 \cdot a} \cdot \frac{\mathsf{fma}\left(\frac{-9}{2}, \left(\left(a \cdot c\right) \cdot b\right), \left(\frac{27}{8} \cdot \frac{\left(a \cdot c\right) \cdot \left(a \cdot c\right)}{b}\right)\right)}{\sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} + \left(b \cdot b + \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot b\right)}}\]
    12. Simplified9.0

      \[\leadsto \color{blue}{\frac{\frac{1}{3}}{a}} \cdot \frac{\mathsf{fma}\left(\frac{-9}{2}, \left(\left(a \cdot c\right) \cdot b\right), \left(\frac{27}{8} \cdot \frac{\left(a \cdot c\right) \cdot \left(a \cdot c\right)}{b}\right)\right)}{\sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} + \left(b \cdot b + \sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot b\right)}\]
    13. Simplified9.0

      \[\leadsto \frac{\frac{1}{3}}{a} \cdot \color{blue}{\frac{\mathsf{fma}\left(\left(b \cdot \frac{-9}{2}\right), \left(c \cdot a\right), \left(\frac{\frac{27}{8}}{b} \cdot \left(\left(c \cdot a\right) \cdot \left(c \cdot a\right)\right)\right)\right)}{\mathsf{fma}\left(\left(\sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right), b, \left(b \cdot b + \mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)\right)\right)}}\]
    14. Taylor expanded around inf 9.0

      \[\leadsto \frac{\frac{1}{3}}{a} \cdot \frac{\color{blue}{\frac{27}{8} \cdot \frac{{a}^{2} \cdot {c}^{2}}{b} - \frac{9}{2} \cdot \left(a \cdot \left(b \cdot c\right)\right)}}{\mathsf{fma}\left(\left(\sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right), b, \left(b \cdot b + \mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)\right)\right)}\]
    15. Simplified9.0

      \[\leadsto \frac{\frac{1}{3}}{a} \cdot \frac{\color{blue}{\mathsf{fma}\left(\frac{-9}{2}, \left(\left(a \cdot c\right) \cdot b\right), \left(\frac{27}{8} \cdot \frac{\left(a \cdot c\right) \cdot \left(a \cdot c\right)}{b}\right)\right)}}{\mathsf{fma}\left(\left(\sqrt{\mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right), b, \left(b \cdot b + \mathsf{fma}\left(-3, \left(c \cdot a\right), \left(b \cdot b\right)\right)\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification9.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 0.9138784421621164:\\ \;\;\;\;\frac{\left(\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot \left(-3 \cdot c\right)\right)\right)} \cdot \left(a \cdot \left(-3 \cdot c\right)\right) + \sqrt{\mathsf{fma}\left(b, b, \left(a \cdot \left(-3 \cdot c\right)\right)\right)} \cdot \left(b \cdot b\right)\right) - b \cdot \left(b \cdot b\right)}{\left(a \cdot 3\right) \cdot \left(\sqrt{\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)} \cdot \sqrt{\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)} + \left(b \cdot \sqrt{\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)} + b \cdot b\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{3}}{a} \cdot \frac{\mathsf{fma}\left(\frac{-9}{2}, \left(b \cdot \left(a \cdot c\right)\right), \left(\frac{\left(a \cdot c\right) \cdot \left(a \cdot c\right)}{b} \cdot \frac{27}{8}\right)\right)}{\mathsf{fma}\left(\left(\sqrt{\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right)}\right), b, \left(\mathsf{fma}\left(-3, \left(a \cdot c\right), \left(b \cdot b\right)\right) + b \cdot b\right)\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2019124 +o rules:numerics
(FPCore (a b c d)
  :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)))