Average Error: 19.6 → 13.4
Time: 28.2s
Precision: 64
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le 6.2482814833755615 \cdot 10^{+78}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \left(-\sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\right)\right) + \mathsf{fma}\left(-\sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}, \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}, \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\frac{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b}{2}}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\frac{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b}{2}}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

\end{array}
\begin{array}{l}
\mathbf{if}\;b \le 6.2482814833755615 \cdot 10^{+78}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \left(-\sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\right)\right) + \mathsf{fma}\left(-\sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}, \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}, \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\right)}{2 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{\frac{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b}{2}}\\

\end{array}\\

\mathbf{elif}\;b \ge 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{\frac{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b}{2}}\\

\end{array}
double f(double a, double b, double c) {
        double r1276818 = b;
        double r1276819 = 0.0;
        bool r1276820 = r1276818 >= r1276819;
        double r1276821 = -r1276818;
        double r1276822 = r1276818 * r1276818;
        double r1276823 = 4.0;
        double r1276824 = a;
        double r1276825 = r1276823 * r1276824;
        double r1276826 = c;
        double r1276827 = r1276825 * r1276826;
        double r1276828 = r1276822 - r1276827;
        double r1276829 = sqrt(r1276828);
        double r1276830 = r1276821 - r1276829;
        double r1276831 = 2.0;
        double r1276832 = r1276831 * r1276824;
        double r1276833 = r1276830 / r1276832;
        double r1276834 = r1276831 * r1276826;
        double r1276835 = r1276821 + r1276829;
        double r1276836 = r1276834 / r1276835;
        double r1276837 = r1276820 ? r1276833 : r1276836;
        return r1276837;
}

double f(double a, double b, double c) {
        double r1276838 = b;
        double r1276839 = 6.2482814833755615e+78;
        bool r1276840 = r1276838 <= r1276839;
        double r1276841 = 0.0;
        bool r1276842 = r1276838 >= r1276841;
        double r1276843 = -r1276838;
        double r1276844 = cbrt(r1276843);
        double r1276845 = r1276844 * r1276844;
        double r1276846 = c;
        double r1276847 = a;
        double r1276848 = -4.0;
        double r1276849 = r1276847 * r1276848;
        double r1276850 = r1276838 * r1276838;
        double r1276851 = fma(r1276846, r1276849, r1276850);
        double r1276852 = sqrt(r1276851);
        double r1276853 = sqrt(r1276852);
        double r1276854 = -r1276853;
        double r1276855 = r1276853 * r1276854;
        double r1276856 = fma(r1276845, r1276844, r1276855);
        double r1276857 = r1276853 * r1276853;
        double r1276858 = fma(r1276854, r1276853, r1276857);
        double r1276859 = r1276856 + r1276858;
        double r1276860 = 2.0;
        double r1276861 = r1276860 * r1276847;
        double r1276862 = r1276859 / r1276861;
        double r1276863 = r1276852 - r1276838;
        double r1276864 = r1276863 / r1276860;
        double r1276865 = r1276846 / r1276864;
        double r1276866 = r1276842 ? r1276862 : r1276865;
        double r1276867 = r1276843 - r1276838;
        double r1276868 = r1276867 / r1276861;
        double r1276869 = r1276842 ? r1276868 : r1276865;
        double r1276870 = r1276840 ? r1276866 : r1276869;
        return r1276870;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 6.2482814833755615e+78

    1. Initial program 15.1

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Simplified15.1

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\frac{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b}{2}}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt15.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \color{blue}{\sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\frac{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b}{2}}\\ \end{array}\]
    5. Applied add-cube-cbrt15.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\color{blue}{\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}\right) \cdot \sqrt[3]{-b}} - \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\frac{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b}{2}}\\ \end{array}\]
    6. Applied prod-diff15.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\color{blue}{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, -\sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\right) + \mathsf{fma}\left(-\sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}, \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}, \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\frac{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b}{2}}\\ \end{array}\]

    if 6.2482814833755615e+78 < b

    1. Initial program 39.8

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Simplified39.8

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\frac{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b}{2}}\\ \end{array}}\]
    3. Taylor expanded around 0 4.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \color{blue}{b}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\frac{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b}{2}}\\ \end{array}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification13.4

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

Reproduce

herbie shell --seed 2019144 +o rules:numerics
(FPCore (a b c)
  :name "jeff quadratic root 1"
  (if (>= b 0) (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))))