Average Error: 20.0 → 7.9
Time: 13.9s
Precision: 64
\[\begin{array}{l} \mathbf{if}\;b \ge 0.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 -3.50519849908317111 \cdot 10^{136}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.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}{-\mathsf{fma}\left(2, \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}, b \cdot -2\right)}\\ \end{array}\\ \mathbf{elif}\;b \le 4.1199128263687574 \cdot 10^{46}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.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}{\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}} - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \ge 0.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 -3.50519849908317111 \cdot 10^{136}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.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}{-\mathsf{fma}\left(2, \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}, b \cdot -2\right)}\\

\end{array}\\

\mathbf{elif}\;b \le 4.1199128263687574 \cdot 10^{46}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.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}{\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}} - b}\\

\end{array}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r50088 = b;
        double r50089 = 0.0;
        bool r50090 = r50088 >= r50089;
        double r50091 = -r50088;
        double r50092 = r50088 * r50088;
        double r50093 = 4.0;
        double r50094 = a;
        double r50095 = r50093 * r50094;
        double r50096 = c;
        double r50097 = r50095 * r50096;
        double r50098 = r50092 - r50097;
        double r50099 = sqrt(r50098);
        double r50100 = r50091 - r50099;
        double r50101 = 2.0;
        double r50102 = r50101 * r50094;
        double r50103 = r50100 / r50102;
        double r50104 = r50101 * r50096;
        double r50105 = r50091 + r50099;
        double r50106 = r50104 / r50105;
        double r50107 = r50090 ? r50103 : r50106;
        return r50107;
}

double f(double a, double b, double c) {
        double r50108 = b;
        double r50109 = -3.505198499083171e+136;
        bool r50110 = r50108 <= r50109;
        double r50111 = 0.0;
        bool r50112 = r50108 >= r50111;
        double r50113 = -r50108;
        double r50114 = r50108 * r50108;
        double r50115 = 4.0;
        double r50116 = a;
        double r50117 = r50115 * r50116;
        double r50118 = c;
        double r50119 = r50117 * r50118;
        double r50120 = r50114 - r50119;
        double r50121 = sqrt(r50120);
        double r50122 = r50113 - r50121;
        double r50123 = 2.0;
        double r50124 = r50123 * r50116;
        double r50125 = r50122 / r50124;
        double r50126 = r50123 * r50118;
        double r50127 = -r50126;
        double r50128 = cbrt(r50108);
        double r50129 = r50128 * r50128;
        double r50130 = r50116 / r50129;
        double r50131 = cbrt(r50118);
        double r50132 = r50131 * r50131;
        double r50133 = cbrt(r50128);
        double r50134 = r50133 * r50133;
        double r50135 = r50132 / r50134;
        double r50136 = r50130 * r50135;
        double r50137 = r50131 / r50133;
        double r50138 = r50136 * r50137;
        double r50139 = -2.0;
        double r50140 = r50108 * r50139;
        double r50141 = fma(r50123, r50138, r50140);
        double r50142 = -r50141;
        double r50143 = r50127 / r50142;
        double r50144 = r50112 ? r50125 : r50143;
        double r50145 = 4.1199128263687574e+46;
        bool r50146 = r50108 <= r50145;
        double r50147 = sqrt(r50121);
        double r50148 = r50147 * r50147;
        double r50149 = r50148 - r50108;
        double r50150 = r50126 / r50149;
        double r50151 = r50112 ? r50125 : r50150;
        double r50152 = r50116 * r50118;
        double r50153 = r50152 / r50108;
        double r50154 = r50123 * r50153;
        double r50155 = r50108 - r50154;
        double r50156 = r50113 - r50155;
        double r50157 = r50156 / r50124;
        double r50158 = r50121 - r50108;
        double r50159 = r50126 / r50158;
        double r50160 = r50112 ? r50157 : r50159;
        double r50161 = r50146 ? r50151 : r50160;
        double r50162 = r50110 ? r50144 : r50161;
        return r50162;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -3.505198499083171e+136

    1. Initial program 34.4

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.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. Simplified34.4

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0.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}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Taylor expanded around -inf 5.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\color{blue}{2 \cdot c}}{\left(2 \cdot \frac{a \cdot c}{b} - b\right) - b}\\ \end{array}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt5.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.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(2 \cdot \frac{a \cdot c}{\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}} - b\right) - b}\\ \end{array}\]
    6. Applied times-frac1.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.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(2 \cdot \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{c}{\sqrt[3]{b}}\right) - b\right) - b}\\ \end{array}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt1.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.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(2 \cdot \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{c}{\left(\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}\right) \cdot \sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\]
    9. Applied add-cube-cbrt1.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.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(2 \cdot \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \sqrt[3]{c}}{\left(\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}\right) \cdot \sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\]
    10. Applied times-frac1.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.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(2 \cdot \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \left(\frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}} \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right)\right) - b\right) - b}\\ \end{array}\]
    11. Applied associate-*r*1.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.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(2 \cdot \left(\left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\]
    12. Using strategy rm
    13. Applied frac-2neg1.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.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(\left(2 \cdot \left(\left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b\right)}\\ \end{array}\]
    14. Simplified1.8

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

    if -3.505198499083171e+136 < b < 4.1199128263687574e+46

    1. Initial program 9.2

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.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. Simplified9.2

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0.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}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt9.2

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\color{blue}{2 \cdot c}}{\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}} - b}\\ \end{array}\]

    if 4.1199128263687574e+46 < b

    1. Initial program 36.8

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.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.8

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0.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}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Taylor expanded around inf 10.1

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

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

Reproduce

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