Average Error: 20.0 → 13.9
Time: 26.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 2.6656023684116586 \cdot 10^{+55}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt{\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]{\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)}}}}}{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 2.6656023684116586 \cdot 10^{+55}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \cdot \sqrt{\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]{\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)}}}}}{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 r1240026 = b;
        double r1240027 = 0.0;
        bool r1240028 = r1240026 >= r1240027;
        double r1240029 = -r1240026;
        double r1240030 = r1240026 * r1240026;
        double r1240031 = 4.0;
        double r1240032 = a;
        double r1240033 = r1240031 * r1240032;
        double r1240034 = c;
        double r1240035 = r1240033 * r1240034;
        double r1240036 = r1240030 - r1240035;
        double r1240037 = sqrt(r1240036);
        double r1240038 = r1240029 - r1240037;
        double r1240039 = 2.0;
        double r1240040 = r1240039 * r1240032;
        double r1240041 = r1240038 / r1240040;
        double r1240042 = r1240039 * r1240034;
        double r1240043 = r1240029 + r1240037;
        double r1240044 = r1240042 / r1240043;
        double r1240045 = r1240028 ? r1240041 : r1240044;
        return r1240045;
}

double f(double a, double b, double c) {
        double r1240046 = b;
        double r1240047 = 2.6656023684116586e+55;
        bool r1240048 = r1240046 <= r1240047;
        double r1240049 = 0.0;
        bool r1240050 = r1240046 >= r1240049;
        double r1240051 = -r1240046;
        double r1240052 = c;
        double r1240053 = a;
        double r1240054 = -4.0;
        double r1240055 = r1240053 * r1240054;
        double r1240056 = r1240046 * r1240046;
        double r1240057 = fma(r1240052, r1240055, r1240056);
        double r1240058 = sqrt(r1240057);
        double r1240059 = sqrt(r1240058);
        double r1240060 = cbrt(r1240057);
        double r1240061 = r1240060 * r1240060;
        double r1240062 = sqrt(r1240061);
        double r1240063 = r1240061 * r1240060;
        double r1240064 = cbrt(r1240063);
        double r1240065 = sqrt(r1240064);
        double r1240066 = r1240062 * r1240065;
        double r1240067 = sqrt(r1240066);
        double r1240068 = r1240059 * r1240067;
        double r1240069 = r1240051 - r1240068;
        double r1240070 = 2.0;
        double r1240071 = r1240070 * r1240053;
        double r1240072 = r1240069 / r1240071;
        double r1240073 = r1240058 - r1240046;
        double r1240074 = r1240073 / r1240070;
        double r1240075 = r1240052 / r1240074;
        double r1240076 = r1240050 ? r1240072 : r1240075;
        double r1240077 = r1240051 - r1240046;
        double r1240078 = r1240077 / r1240071;
        double r1240079 = r1240050 ? r1240078 : r1240075;
        double r1240080 = r1240048 ? r1240076 : r1240079;
        return r1240080;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 2.6656023684116586e+55

    1. Initial program 15.7

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

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

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

      \[\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}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt15.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt{\color{blue}{\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)}}}} \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}\]
    8. Applied sqrt-prod15.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\color{blue}{\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 \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}\]
    9. Using strategy rm
    10. Applied add-cbrt-cube15.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\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{\color{blue}{\sqrt[3]{\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)}}}}} \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}\]

    if 2.6656023684116586e+55 < b

    1. Initial program 37.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. Simplified37.0

      \[\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 6.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.9

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