Average Error: 19.4 → 8.9
Time: 9.6s
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 -2.2572095326645574 \cdot 10^{165}:\\ \;\;\;\;\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) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}\\ \end{array}\\ \mathbf{elif}\;b \le 7.98976121086484385 \cdot 10^{108}:\\ \;\;\;\;\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{\left(\sqrt[3]{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt[3]{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right) \cdot \sqrt[3]{\sqrt[3]{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}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{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 \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 -2.2572095326645574 \cdot 10^{165}:\\
\;\;\;\;\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) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}\\

\end{array}\\

\mathbf{elif}\;b \le 7.98976121086484385 \cdot 10^{108}:\\
\;\;\;\;\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{\left(\sqrt[3]{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt[3]{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right) \cdot \sqrt[3]{\sqrt[3]{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}\\

\mathbf{elif}\;b \ge 0.0:\\
\;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{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}
double f(double a, double b, double c) {
        double r46260 = b;
        double r46261 = 0.0;
        bool r46262 = r46260 >= r46261;
        double r46263 = -r46260;
        double r46264 = r46260 * r46260;
        double r46265 = 4.0;
        double r46266 = a;
        double r46267 = r46265 * r46266;
        double r46268 = c;
        double r46269 = r46267 * r46268;
        double r46270 = r46264 - r46269;
        double r46271 = sqrt(r46270);
        double r46272 = r46263 - r46271;
        double r46273 = 2.0;
        double r46274 = r46273 * r46266;
        double r46275 = r46272 / r46274;
        double r46276 = r46273 * r46268;
        double r46277 = r46263 + r46271;
        double r46278 = r46276 / r46277;
        double r46279 = r46262 ? r46275 : r46278;
        return r46279;
}

double f(double a, double b, double c) {
        double r46280 = b;
        double r46281 = -2.2572095326645574e+165;
        bool r46282 = r46280 <= r46281;
        double r46283 = 0.0;
        bool r46284 = r46280 >= r46283;
        double r46285 = -r46280;
        double r46286 = r46280 * r46280;
        double r46287 = 4.0;
        double r46288 = a;
        double r46289 = r46287 * r46288;
        double r46290 = c;
        double r46291 = r46289 * r46290;
        double r46292 = r46286 - r46291;
        double r46293 = sqrt(r46292);
        double r46294 = r46285 - r46293;
        double r46295 = 2.0;
        double r46296 = r46295 * r46288;
        double r46297 = r46294 / r46296;
        double r46298 = r46295 * r46290;
        double r46299 = r46288 * r46290;
        double r46300 = r46299 / r46280;
        double r46301 = r46295 * r46300;
        double r46302 = r46301 - r46280;
        double r46303 = r46285 + r46302;
        double r46304 = r46298 / r46303;
        double r46305 = r46284 ? r46297 : r46304;
        double r46306 = 7.989761210864844e+108;
        bool r46307 = r46280 <= r46306;
        double r46308 = cbrt(r46292);
        double r46309 = fabs(r46308);
        double r46310 = cbrt(r46308);
        double r46311 = r46310 * r46310;
        double r46312 = r46311 * r46310;
        double r46313 = sqrt(r46312);
        double r46314 = r46309 * r46313;
        double r46315 = r46285 - r46314;
        double r46316 = r46315 / r46296;
        double r46317 = r46285 + r46293;
        double r46318 = r46298 / r46317;
        double r46319 = r46284 ? r46316 : r46318;
        double r46320 = 2.0;
        double r46321 = r46320 * r46280;
        double r46322 = r46301 - r46321;
        double r46323 = r46322 / r46296;
        double r46324 = r46284 ? r46323 : r46318;
        double r46325 = r46307 ? r46319 : r46324;
        double r46326 = r46282 ? r46305 : r46325;
        return r46326;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if b < -2.2572095326645574e+165

    1. Initial program 36.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. Taylor expanded around -inf 6.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{2 \cdot c}{\color{blue}{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}}\\ \end{array}\]

    if -2.2572095326645574e+165 < b < 7.989761210864844e+108

    1. Initial program 9.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. Using strategy rm
    3. Applied add-cube-cbrt9.3

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

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

      \[\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}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt9.4

      \[\leadsto \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{\color{blue}{\left(\sqrt[3]{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt[3]{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right) \cdot \sqrt[3]{\sqrt[3]{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}\]

    if 7.989761210864844e+108 < b

    1. Initial program 48.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. Using strategy rm
    3. Applied add-sqr-sqrt48.9

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{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}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification8.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.2572095326645574 \cdot 10^{165}:\\ \;\;\;\;\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) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}\\ \end{array}\\ \mathbf{elif}\;b \le 7.98976121086484385 \cdot 10^{108}:\\ \;\;\;\;\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{\left(\sqrt[3]{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt[3]{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right) \cdot \sqrt[3]{\sqrt[3]{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}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{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}\]

Reproduce

herbie shell --seed 2020047 
(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)))))))