Average Error: 19.6 → 8.1
Time: 18.8s
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 -1.155371142473554149515147323663064434117 \cdot 10^{100}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \left|\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(\left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}}\right) \cdot \left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \frac{c}{\sqrt[3]{b}}\right), 2, -2 \cdot b\right)}\\ \end{array}\\ \mathbf{elif}\;b \le 1.391022219120490870209261122719458055916 \cdot 10^{74}:\\ \;\;\;\;\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(\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}, \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}, -b\right)}\\ \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 -1.155371142473554149515147323663064434117 \cdot 10^{100}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{\left(-b\right) - \left|\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\

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

\end{array}\\

\mathbf{elif}\;b \le 1.391022219120490870209261122719458055916 \cdot 10^{74}:\\
\;\;\;\;\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(\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}, \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}, -b\right)}\\

\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 r39154 = b;
        double r39155 = 0.0;
        bool r39156 = r39154 >= r39155;
        double r39157 = -r39154;
        double r39158 = r39154 * r39154;
        double r39159 = 4.0;
        double r39160 = a;
        double r39161 = r39159 * r39160;
        double r39162 = c;
        double r39163 = r39161 * r39162;
        double r39164 = r39158 - r39163;
        double r39165 = sqrt(r39164);
        double r39166 = r39157 - r39165;
        double r39167 = 2.0;
        double r39168 = r39167 * r39160;
        double r39169 = r39166 / r39168;
        double r39170 = r39167 * r39162;
        double r39171 = r39157 + r39165;
        double r39172 = r39170 / r39171;
        double r39173 = r39156 ? r39169 : r39172;
        return r39173;
}

double f(double a, double b, double c) {
        double r39174 = b;
        double r39175 = -1.1553711424735541e+100;
        bool r39176 = r39174 <= r39175;
        double r39177 = 0.0;
        bool r39178 = r39174 >= r39177;
        double r39179 = -r39174;
        double r39180 = r39174 * r39174;
        double r39181 = 4.0;
        double r39182 = a;
        double r39183 = r39181 * r39182;
        double r39184 = c;
        double r39185 = r39183 * r39184;
        double r39186 = r39180 - r39185;
        double r39187 = cbrt(r39186);
        double r39188 = fabs(r39187);
        double r39189 = sqrt(r39187);
        double r39190 = r39188 * r39189;
        double r39191 = r39179 - r39190;
        double r39192 = 2.0;
        double r39193 = r39192 * r39182;
        double r39194 = r39191 / r39193;
        double r39195 = r39192 * r39184;
        double r39196 = cbrt(r39174);
        double r39197 = r39196 * r39196;
        double r39198 = r39182 / r39197;
        double r39199 = cbrt(r39198);
        double r39200 = r39199 * r39199;
        double r39201 = r39184 / r39196;
        double r39202 = r39199 * r39201;
        double r39203 = r39200 * r39202;
        double r39204 = -2.0;
        double r39205 = r39204 * r39174;
        double r39206 = fma(r39203, r39192, r39205);
        double r39207 = r39195 / r39206;
        double r39208 = r39178 ? r39194 : r39207;
        double r39209 = 1.3910222191204909e+74;
        bool r39210 = r39174 <= r39209;
        double r39211 = sqrt(r39186);
        double r39212 = r39179 - r39211;
        double r39213 = r39212 / r39193;
        double r39214 = sqrt(r39211);
        double r39215 = fma(r39214, r39214, r39179);
        double r39216 = r39195 / r39215;
        double r39217 = r39178 ? r39213 : r39216;
        double r39218 = r39182 * r39184;
        double r39219 = r39218 / r39174;
        double r39220 = r39192 * r39219;
        double r39221 = r39174 - r39220;
        double r39222 = r39179 - r39221;
        double r39223 = r39222 / r39193;
        double r39224 = r39211 - r39174;
        double r39225 = r39195 / r39224;
        double r39226 = r39178 ? r39223 : r39225;
        double r39227 = r39210 ? r39217 : r39226;
        double r39228 = r39176 ? r39208 : r39227;
        return r39228;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -1.1553711424735541e+100

    1. Initial program 30.1

      \[\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. Simplified30.1

      \[\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 6.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}:\\ \;\;\;\;\color{blue}{\frac{2 \cdot c}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}\\ \end{array}\]
    4. Simplified6.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}:\\ \;\;\;\;\color{blue}{\frac{2 \cdot c}{\mathsf{fma}\left(\frac{a \cdot c}{b}, 2, -2 \cdot b\right)}}\\ \end{array}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt6.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{2 \cdot \color{blue}{c}}{\mathsf{fma}\left(\frac{a \cdot c}{\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}}, 2, -2 \cdot b\right)}\\ \end{array}\]
    7. Applied times-frac2.6

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

      \[\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}{\mathsf{fma}\left(\left(\left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}}\right) \cdot \sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}}\right) \cdot \frac{c}{\sqrt[3]{b}}, 2, -2 \cdot b\right)}\\ \end{array}\]
    10. Applied associate-*l*2.6

      \[\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}}{\mathsf{fma}\left(\left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}}\right) \cdot \left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \frac{c}{\sqrt[3]{b}}\right), 2, -2 \cdot b\right)}\\ \end{array}\]
    11. Using strategy rm
    12. Applied add-cube-cbrt2.6

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

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

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

    if -1.1553711424735541e+100 < b < 1.3910222191204909e+74

    1. Initial program 8.9

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

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

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

      \[\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}\]
    6. Applied fma-neg9.0

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

    if 1.3910222191204909e+74 < b

    1. Initial program 41.7

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

      \[\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 12.2

      \[\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 simplification8.1

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