Average Error: 20.0 → 13.2
Time: 27.8s
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 3.188391854507535 \cdot 10^{+149}:\\ \;\;\;\;\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]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}} \cdot \sqrt{\sqrt[3]{\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}} \cdot \sqrt[3]{\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)}}}}}\\ \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 3.188391854507535 \cdot 10^{+149}:\\
\;\;\;\;\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]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}} \cdot \sqrt{\sqrt[3]{\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}} \cdot \sqrt[3]{\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)}}}}}\\

\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 r1023584 = b;
        double r1023585 = 0.0;
        bool r1023586 = r1023584 >= r1023585;
        double r1023587 = 2.0;
        double r1023588 = c;
        double r1023589 = r1023587 * r1023588;
        double r1023590 = -r1023584;
        double r1023591 = r1023584 * r1023584;
        double r1023592 = 4.0;
        double r1023593 = a;
        double r1023594 = r1023592 * r1023593;
        double r1023595 = r1023594 * r1023588;
        double r1023596 = r1023591 - r1023595;
        double r1023597 = sqrt(r1023596);
        double r1023598 = r1023590 - r1023597;
        double r1023599 = r1023589 / r1023598;
        double r1023600 = r1023590 + r1023597;
        double r1023601 = r1023587 * r1023593;
        double r1023602 = r1023600 / r1023601;
        double r1023603 = r1023586 ? r1023599 : r1023602;
        return r1023603;
}

double f(double a, double b, double c) {
        double r1023604 = b;
        double r1023605 = 3.188391854507535e+149;
        bool r1023606 = r1023604 <= r1023605;
        double r1023607 = 0.0;
        bool r1023608 = r1023604 >= r1023607;
        double r1023609 = 2.0;
        double r1023610 = c;
        double r1023611 = r1023609 * r1023610;
        double r1023612 = -r1023604;
        double r1023613 = -4.0;
        double r1023614 = a;
        double r1023615 = r1023614 * r1023610;
        double r1023616 = r1023604 * r1023604;
        double r1023617 = fma(r1023613, r1023615, r1023616);
        double r1023618 = sqrt(r1023617);
        double r1023619 = sqrt(r1023618);
        double r1023620 = cbrt(r1023617);
        double r1023621 = r1023620 * r1023620;
        double r1023622 = sqrt(r1023621);
        double r1023623 = cbrt(r1023620);
        double r1023624 = cbrt(r1023621);
        double r1023625 = r1023623 * r1023624;
        double r1023626 = sqrt(r1023625);
        double r1023627 = r1023622 * r1023626;
        double r1023628 = sqrt(r1023627);
        double r1023629 = r1023619 * r1023628;
        double r1023630 = r1023612 - r1023629;
        double r1023631 = r1023611 / r1023630;
        double r1023632 = r1023618 - r1023604;
        double r1023633 = r1023632 / r1023609;
        double r1023634 = r1023633 / r1023614;
        double r1023635 = r1023608 ? r1023631 : r1023634;
        double r1023636 = r1023612 - r1023604;
        double r1023637 = r1023611 / r1023636;
        double r1023638 = r1023608 ? r1023637 : r1023634;
        double r1023639 = r1023606 ? r1023635 : r1023638;
        return r1023639;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 3.188391854507535e+149

    1. Initial program 15.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. Simplified15.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. Using strategy rm
    4. Applied add-sqr-sqrt15.7

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

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

      \[\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-cube-cbrt15.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\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]{\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}\]
    10. Applied cbrt-prod15.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\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{\color{blue}{\sqrt[3]{\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[3]{\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 3.188391854507535e+149 < b

    1. Initial program 39.4

      \[\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. Simplified39.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 3.188391854507535 \cdot 10^{+149}:\\ \;\;\;\;\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]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}} \cdot \sqrt{\sqrt[3]{\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}} \cdot \sqrt[3]{\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)}}}}}\\ \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 2019139 +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))))