Average Error: 19.7 → 13.6
Time: 31.5s
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 2.6656023684116586 \cdot 10^{+55}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}} \cdot \sqrt{\sqrt{\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)} \cdot \sqrt[3]{\left(\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}} \cdot \sqrt{\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)} - b}{2}}{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 2.6656023684116586 \cdot 10^{+55}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}} \cdot \sqrt{\sqrt{\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)} \cdot \sqrt[3]{\left(\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}} \cdot \sqrt{\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}}}\\

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

\end{array}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r1196342 = b;
        double r1196343 = 0.0;
        bool r1196344 = r1196342 >= r1196343;
        double r1196345 = 2.0;
        double r1196346 = c;
        double r1196347 = r1196345 * r1196346;
        double r1196348 = -r1196342;
        double r1196349 = r1196342 * r1196342;
        double r1196350 = 4.0;
        double r1196351 = a;
        double r1196352 = r1196350 * r1196351;
        double r1196353 = r1196352 * r1196346;
        double r1196354 = r1196349 - r1196353;
        double r1196355 = sqrt(r1196354);
        double r1196356 = r1196348 - r1196355;
        double r1196357 = r1196347 / r1196356;
        double r1196358 = r1196348 + r1196355;
        double r1196359 = r1196345 * r1196351;
        double r1196360 = r1196358 / r1196359;
        double r1196361 = r1196344 ? r1196357 : r1196360;
        return r1196361;
}

double f(double a, double b, double c) {
        double r1196362 = b;
        double r1196363 = 2.6656023684116586e+55;
        bool r1196364 = r1196362 <= r1196363;
        double r1196365 = 0.0;
        bool r1196366 = r1196362 >= r1196365;
        double r1196367 = 2.0;
        double r1196368 = c;
        double r1196369 = r1196367 * r1196368;
        double r1196370 = -r1196362;
        double r1196371 = -4.0;
        double r1196372 = a;
        double r1196373 = r1196372 * r1196368;
        double r1196374 = r1196362 * r1196362;
        double r1196375 = fma(r1196371, r1196373, r1196374);
        double r1196376 = sqrt(r1196375);
        double r1196377 = sqrt(r1196376);
        double r1196378 = cbrt(r1196375);
        double r1196379 = r1196378 * r1196378;
        double r1196380 = r1196379 * r1196378;
        double r1196381 = cbrt(r1196380);
        double r1196382 = r1196378 * r1196381;
        double r1196383 = sqrt(r1196382);
        double r1196384 = sqrt(r1196378);
        double r1196385 = r1196383 * r1196384;
        double r1196386 = sqrt(r1196385);
        double r1196387 = r1196377 * r1196386;
        double r1196388 = r1196370 - r1196387;
        double r1196389 = r1196369 / r1196388;
        double r1196390 = r1196376 - r1196362;
        double r1196391 = r1196390 / r1196367;
        double r1196392 = r1196391 / r1196372;
        double r1196393 = r1196366 ? r1196389 : r1196392;
        double r1196394 = r1196370 - r1196362;
        double r1196395 = r1196369 / r1196394;
        double r1196396 = r1196366 ? r1196395 : r1196392;
        double r1196397 = r1196364 ? r1196393 : r1196396;
        return r1196397;
}

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 17.3

      \[\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. Simplified17.2

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\sqrt{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt17.3

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{\sqrt{\sqrt[3]{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}} \cdot \sqrt{\sqrt[3]{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\]
    8. Using strategy rm
    9. Applied add-cbrt-cube17.3

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

    if 2.6656023684116586e+55 < b

    1. Initial program 25.6

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

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

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

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

Reproduce

herbie shell --seed 2019141 +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))))