Average Error: 19.5 → 13.9
Time: 20.9s
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 2.0410715251838527 \cdot 10^{+49}:\\ \;\;\;\;\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{\mathsf{fma}\left(\sqrt{\sqrt[3]{\sqrt{\sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt{\sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}} \cdot \left(\sqrt[3]{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt[3]{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\right)}, \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}, -b\right)}{2}}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{\left(\frac{a}{b} \cdot c - b\right) \cdot 2}{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 2.0410715251838527 \cdot 10^{+49}:\\
\;\;\;\;\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{\mathsf{fma}\left(\sqrt{\sqrt[3]{\sqrt{\sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt{\sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}} \cdot \left(\sqrt[3]{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt[3]{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\right)}, \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}, -b\right)}{2}}\\

\end{array}\\

\mathbf{elif}\;b \ge 0:\\
\;\;\;\;\frac{\left(\frac{a}{b} \cdot c - b\right) \cdot 2}{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 r1673981 = b;
        double r1673982 = 0.0;
        bool r1673983 = r1673981 >= r1673982;
        double r1673984 = -r1673981;
        double r1673985 = r1673981 * r1673981;
        double r1673986 = 4.0;
        double r1673987 = a;
        double r1673988 = r1673986 * r1673987;
        double r1673989 = c;
        double r1673990 = r1673988 * r1673989;
        double r1673991 = r1673985 - r1673990;
        double r1673992 = sqrt(r1673991);
        double r1673993 = r1673984 - r1673992;
        double r1673994 = 2.0;
        double r1673995 = r1673994 * r1673987;
        double r1673996 = r1673993 / r1673995;
        double r1673997 = r1673994 * r1673989;
        double r1673998 = r1673984 + r1673992;
        double r1673999 = r1673997 / r1673998;
        double r1674000 = r1673983 ? r1673996 : r1673999;
        return r1674000;
}

double f(double a, double b, double c) {
        double r1674001 = b;
        double r1674002 = 2.0410715251838527e+49;
        bool r1674003 = r1674001 <= r1674002;
        double r1674004 = 0.0;
        bool r1674005 = r1674001 >= r1674004;
        double r1674006 = -r1674001;
        double r1674007 = c;
        double r1674008 = a;
        double r1674009 = -4.0;
        double r1674010 = r1674008 * r1674009;
        double r1674011 = r1674001 * r1674001;
        double r1674012 = fma(r1674007, r1674010, r1674011);
        double r1674013 = sqrt(r1674012);
        double r1674014 = r1674006 - r1674013;
        double r1674015 = 2.0;
        double r1674016 = r1674015 * r1674008;
        double r1674017 = r1674014 / r1674016;
        double r1674018 = cbrt(r1674012);
        double r1674019 = r1674018 * r1674018;
        double r1674020 = sqrt(r1674019);
        double r1674021 = sqrt(r1674018);
        double r1674022 = r1674020 * r1674021;
        double r1674023 = cbrt(r1674022);
        double r1674024 = cbrt(r1674013);
        double r1674025 = r1674024 * r1674024;
        double r1674026 = r1674023 * r1674025;
        double r1674027 = sqrt(r1674026);
        double r1674028 = sqrt(r1674013);
        double r1674029 = fma(r1674027, r1674028, r1674006);
        double r1674030 = r1674029 / r1674015;
        double r1674031 = r1674007 / r1674030;
        double r1674032 = r1674005 ? r1674017 : r1674031;
        double r1674033 = r1674008 / r1674001;
        double r1674034 = r1674033 * r1674007;
        double r1674035 = r1674034 - r1674001;
        double r1674036 = r1674035 * r1674015;
        double r1674037 = r1674036 / r1674016;
        double r1674038 = r1674013 - r1674001;
        double r1674039 = r1674038 / r1674015;
        double r1674040 = r1674007 / r1674039;
        double r1674041 = r1674005 ? r1674037 : r1674040;
        double r1674042 = r1674003 ? r1674032 : r1674041;
        return r1674042;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 2.0410715251838527e+49

    1. Initial program 15.5

      \[\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.5

      \[\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.5

      \[\leadsto \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{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} \cdot \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} - b}{2}}\\ \end{array}\]
    5. Applied sqrt-prod15.6

      \[\leadsto \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{\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)}} - b}{2}}\\ \end{array}\]
    6. Applied fma-neg15.6

      \[\leadsto \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{\color{blue}{c}}{\frac{\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)}}, -b\right)}{2}}\\ \end{array}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt15.7

      \[\leadsto \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{\mathsf{fma}\left(\sqrt{\left(\sqrt[3]{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt[3]{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\right) \cdot \sqrt[3]{\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)}}, -b\right)}{2}}\\ \end{array}\]
    9. Using strategy rm
    10. Applied add-cube-cbrt15.7

      \[\leadsto \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{\mathsf{fma}\left(\sqrt{\left(\sqrt[3]{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt[3]{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\right) \cdot \sqrt[3]{\sqrt{\left(\sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}}}, \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}, -b\right)}{2}}\\ \end{array}\]
    11. Applied sqrt-prod15.7

      \[\leadsto \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{\mathsf{fma}\left(\sqrt{\left(\sqrt[3]{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt[3]{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\right) \cdot \sqrt[3]{\sqrt{\sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt{\sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}}}, \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}, -b\right)}{2}}\\ \end{array}\]

    if 2.0410715251838527e+49 < b

    1. Initial program 36.3

      \[\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. Simplified36.2

      \[\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 inf 11.1

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot 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}\]
    4. Simplified6.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\color{blue}{\left(\frac{a}{b} \cdot c - b\right) \cdot 2}}{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.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 2.0410715251838527 \cdot 10^{+49}:\\ \;\;\;\;\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{\mathsf{fma}\left(\sqrt{\sqrt[3]{\sqrt{\sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt{\sqrt[3]{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}} \cdot \left(\sqrt[3]{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt[3]{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\right)}, \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}, -b\right)}{2}}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{\left(\frac{a}{b} \cdot c - b\right) \cdot 2}{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 2019162 +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)))))))