Average Error: 28.7 → 9.2
Time: 28.7s
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.7074726914968051:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(b \cdot \left(-b\right)\right), b, \left(b \cdot \left(b \cdot b\right)\right)\right) + \mathsf{fma}\left(\left(\mathsf{fma}\left(b, b, \left(c \cdot \left(a \cdot -3\right)\right)\right)\right), \left(\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot \left(a \cdot -3\right)\right)\right)}\right), \left(b \cdot \left(b \cdot \left(-b\right)\right)\right)\right)}{\mathsf{fma}\left(b, b, \left(c \cdot \left(a \cdot -3\right)\right)\right) + b \cdot \left(b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot \left(a \cdot -3\right)\right)\right)}\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{\left(\left(a \cdot c\right) \cdot \left(a \cdot c\right)\right) \cdot \frac{27}{8}}{b} - \left(a \cdot \frac{9}{2}\right) \cdot \left(b \cdot c\right)}{\mathsf{fma}\left(b, \left(b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot \left(a \cdot -3\right)\right)\right)}\right), \left(\mathsf{fma}\left(b, b, \left(c \cdot \left(a \cdot -3\right)\right)\right)\right)\right) \cdot 3}}{a}\\ \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.7074726914968051:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(b \cdot \left(-b\right)\right), b, \left(b \cdot \left(b \cdot b\right)\right)\right) + \mathsf{fma}\left(\left(\mathsf{fma}\left(b, b, \left(c \cdot \left(a \cdot -3\right)\right)\right)\right), \left(\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot \left(a \cdot -3\right)\right)\right)}\right), \left(b \cdot \left(b \cdot \left(-b\right)\right)\right)\right)}{\mathsf{fma}\left(b, b, \left(c \cdot \left(a \cdot -3\right)\right)\right) + b \cdot \left(b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot \left(a \cdot -3\right)\right)\right)}\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2020742 = b;
        double r2020743 = -r2020742;
        double r2020744 = r2020742 * r2020742;
        double r2020745 = 3.0;
        double r2020746 = a;
        double r2020747 = r2020745 * r2020746;
        double r2020748 = c;
        double r2020749 = r2020747 * r2020748;
        double r2020750 = r2020744 - r2020749;
        double r2020751 = sqrt(r2020750);
        double r2020752 = r2020743 + r2020751;
        double r2020753 = r2020752 / r2020747;
        return r2020753;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2020754 = b;
        double r2020755 = 0.7074726914968051;
        bool r2020756 = r2020754 <= r2020755;
        double r2020757 = -r2020754;
        double r2020758 = r2020754 * r2020757;
        double r2020759 = r2020754 * r2020754;
        double r2020760 = r2020754 * r2020759;
        double r2020761 = fma(r2020758, r2020754, r2020760);
        double r2020762 = c;
        double r2020763 = a;
        double r2020764 = -3.0;
        double r2020765 = r2020763 * r2020764;
        double r2020766 = r2020762 * r2020765;
        double r2020767 = fma(r2020754, r2020754, r2020766);
        double r2020768 = sqrt(r2020767);
        double r2020769 = r2020754 * r2020758;
        double r2020770 = fma(r2020767, r2020768, r2020769);
        double r2020771 = r2020761 + r2020770;
        double r2020772 = r2020754 + r2020768;
        double r2020773 = r2020754 * r2020772;
        double r2020774 = r2020767 + r2020773;
        double r2020775 = r2020771 / r2020774;
        double r2020776 = 3.0;
        double r2020777 = r2020776 * r2020763;
        double r2020778 = r2020775 / r2020777;
        double r2020779 = r2020763 * r2020762;
        double r2020780 = r2020779 * r2020779;
        double r2020781 = 3.375;
        double r2020782 = r2020780 * r2020781;
        double r2020783 = r2020782 / r2020754;
        double r2020784 = 4.5;
        double r2020785 = r2020763 * r2020784;
        double r2020786 = r2020754 * r2020762;
        double r2020787 = r2020785 * r2020786;
        double r2020788 = r2020783 - r2020787;
        double r2020789 = fma(r2020754, r2020772, r2020767);
        double r2020790 = r2020789 * r2020776;
        double r2020791 = r2020788 / r2020790;
        double r2020792 = r2020791 / r2020763;
        double r2020793 = r2020756 ? r2020778 : r2020792;
        return r2020793;
}

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.7074726914968051

    1. Initial program 11.7

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

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

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

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

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

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

    if 0.7074726914968051 < b

    1. Initial program 31.6

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

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

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

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

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

      \[\leadsto \frac{\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)}}{b \cdot \left(\sqrt{\mathsf{fma}\left(b, b, \left(\left(a \cdot -3\right) \cdot c\right)\right)} + b\right) + \mathsf{fma}\left(b, b, \left(\left(a \cdot -3\right) \cdot c\right)\right)}}{3 \cdot a}\]
    8. Simplified8.9

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

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

      \[\leadsto \frac{\frac{\frac{\frac{27}{8} \cdot \color{blue}{\left(\left(c \cdot a\right) \cdot \left(c \cdot a\right)\right)}}{b} - \left(\frac{9}{2} \cdot a\right) \cdot \left(c \cdot b\right)}{b \cdot \left(\sqrt{\mathsf{fma}\left(b, b, \left(\left(a \cdot -3\right) \cdot c\right)\right)} + b\right) + \mathsf{fma}\left(b, b, \left(\left(a \cdot -3\right) \cdot c\right)\right)}}{3 \cdot a}\]
    11. Using strategy rm
    12. Applied associate-/r*8.9

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

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

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

Reproduce

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