Average Error: 18.8 → 6.9
Time: 26.3s
Precision: 64
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -5.1217249295588275 \cdot 10^{+88}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{a}{b} \cdot c - b\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 9.19242293018462 \cdot 10^{+63}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(\frac{c}{\frac{b}{a}} - b\right) \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt{-b}, \sqrt{-b}, \sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)}\right)}{2 \cdot a}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

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

\end{array}
\begin{array}{l}
\mathbf{if}\;b \le -5.1217249295588275 \cdot 10^{+88}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

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

\end{array}\\

\mathbf{elif}\;b \le 9.19242293018462 \cdot 10^{+63}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

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

\end{array}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r865144 = b;
        double r865145 = 0.0;
        bool r865146 = r865144 >= r865145;
        double r865147 = 2.0;
        double r865148 = c;
        double r865149 = r865147 * r865148;
        double r865150 = -r865144;
        double r865151 = r865144 * r865144;
        double r865152 = 4.0;
        double r865153 = a;
        double r865154 = r865152 * r865153;
        double r865155 = r865154 * r865148;
        double r865156 = r865151 - r865155;
        double r865157 = sqrt(r865156);
        double r865158 = r865150 - r865157;
        double r865159 = r865149 / r865158;
        double r865160 = r865150 + r865157;
        double r865161 = r865147 * r865153;
        double r865162 = r865160 / r865161;
        double r865163 = r865146 ? r865159 : r865162;
        return r865163;
}

double f(double a, double b, double c) {
        double r865164 = b;
        double r865165 = -5.1217249295588275e+88;
        bool r865166 = r865164 <= r865165;
        double r865167 = 0.0;
        bool r865168 = r865164 >= r865167;
        double r865169 = 2.0;
        double r865170 = c;
        double r865171 = r865169 * r865170;
        double r865172 = -r865164;
        double r865173 = r865164 * r865164;
        double r865174 = 4.0;
        double r865175 = a;
        double r865176 = r865174 * r865175;
        double r865177 = r865176 * r865170;
        double r865178 = r865173 - r865177;
        double r865179 = sqrt(r865178);
        double r865180 = r865172 - r865179;
        double r865181 = r865171 / r865180;
        double r865182 = r865175 / r865164;
        double r865183 = r865182 * r865170;
        double r865184 = r865183 - r865164;
        double r865185 = r865169 * r865184;
        double r865186 = r865169 * r865175;
        double r865187 = r865185 / r865186;
        double r865188 = r865168 ? r865181 : r865187;
        double r865189 = 9.19242293018462e+63;
        bool r865190 = r865164 <= r865189;
        double r865191 = sqrt(r865179);
        double r865192 = r865191 * r865191;
        double r865193 = r865172 + r865192;
        double r865194 = r865193 / r865186;
        double r865195 = r865168 ? r865181 : r865194;
        double r865196 = r865164 / r865175;
        double r865197 = r865170 / r865196;
        double r865198 = r865197 - r865164;
        double r865199 = r865198 * r865169;
        double r865200 = r865171 / r865199;
        double r865201 = sqrt(r865172);
        double r865202 = -4.0;
        double r865203 = r865202 * r865170;
        double r865204 = fma(r865203, r865175, r865173);
        double r865205 = sqrt(r865204);
        double r865206 = fma(r865201, r865201, r865205);
        double r865207 = r865206 / r865186;
        double r865208 = r865168 ? r865200 : r865207;
        double r865209 = r865190 ? r865195 : r865208;
        double r865210 = r865166 ? r865188 : r865209;
        return r865210;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -5.1217249295588275e+88

    1. Initial program 41.8

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt41.8

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \end{array}\]
    5. Taylor expanded around -inf 9.9

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

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

    if -5.1217249295588275e+88 < b < 9.19242293018462e+63

    1. Initial program 9.2

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

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

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

    if 9.19242293018462e+63 < b

    1. Initial program 25.8

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt25.8

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt{-b}, \sqrt{-b}, \sqrt{{b}^{2} - 4 \cdot \left(a \cdot c\right)}\right)}{2 \cdot a}\\ \end{array}\]
    6. Simplified25.8

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

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

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

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

Reproduce

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