Average Error: 19.1 → 12.3
Time: 17.1s
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.340270116328134 \cdot 10^{+83}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(-\sqrt{b}, \sqrt{b}, \sqrt{\sqrt{\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)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}} \cdot \left(-\sqrt{\sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}\right)\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(\frac{a}{\frac{b}{c}} - b\right) \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)} - b} \cdot \sqrt{\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.340270116328134 \cdot 10^{+83}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(-\sqrt{b}, \sqrt{b}, \sqrt{\sqrt{\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)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}} \cdot \left(-\sqrt{\sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}\right)\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(\frac{a}{\frac{b}{c}} - b\right) \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sqrt{\sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)} - b} \cdot \sqrt{\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 r395585 = b;
        double r395586 = 0.0;
        bool r395587 = r395585 >= r395586;
        double r395588 = 2.0;
        double r395589 = c;
        double r395590 = r395588 * r395589;
        double r395591 = -r395585;
        double r395592 = r395585 * r395585;
        double r395593 = 4.0;
        double r395594 = a;
        double r395595 = r395593 * r395594;
        double r395596 = r395595 * r395589;
        double r395597 = r395592 - r395596;
        double r395598 = sqrt(r395597);
        double r395599 = r395591 - r395598;
        double r395600 = r395590 / r395599;
        double r395601 = r395591 + r395598;
        double r395602 = r395588 * r395594;
        double r395603 = r395601 / r395602;
        double r395604 = r395587 ? r395600 : r395603;
        return r395604;
}

double f(double a, double b, double c) {
        double r395605 = b;
        double r395606 = 3.340270116328134e+83;
        bool r395607 = r395605 <= r395606;
        double r395608 = 0.0;
        bool r395609 = r395605 >= r395608;
        double r395610 = 2.0;
        double r395611 = c;
        double r395612 = r395610 * r395611;
        double r395613 = sqrt(r395605);
        double r395614 = -r395613;
        double r395615 = -4.0;
        double r395616 = a;
        double r395617 = r395616 * r395611;
        double r395618 = r395605 * r395605;
        double r395619 = fma(r395615, r395617, r395618);
        double r395620 = cbrt(r395619);
        double r395621 = sqrt(r395620);
        double r395622 = r395620 * r395620;
        double r395623 = sqrt(r395622);
        double r395624 = r395621 * r395623;
        double r395625 = sqrt(r395624);
        double r395626 = sqrt(r395619);
        double r395627 = sqrt(r395626);
        double r395628 = -r395627;
        double r395629 = r395625 * r395628;
        double r395630 = fma(r395614, r395613, r395629);
        double r395631 = r395612 / r395630;
        double r395632 = r395626 - r395605;
        double r395633 = r395632 / r395610;
        double r395634 = r395633 / r395616;
        double r395635 = r395609 ? r395631 : r395634;
        double r395636 = r395605 / r395611;
        double r395637 = r395616 / r395636;
        double r395638 = r395637 - r395605;
        double r395639 = r395638 * r395610;
        double r395640 = r395612 / r395639;
        double r395641 = sqrt(r395632);
        double r395642 = r395641 * r395641;
        double r395643 = r395642 / r395610;
        double r395644 = r395643 / r395616;
        double r395645 = r395609 ? r395640 : r395644;
        double r395646 = r395607 ? r395635 : r395645;
        return r395646;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 3.340270116328134e+83

    1. Initial program 15.7

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

      \[\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) - \sqrt{\color{blue}{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} \cdot \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. Applied sqrt-prod15.8

      \[\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}\]
    6. Applied add-sqr-sqrt15.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-\color{blue}{\sqrt{b} \cdot \sqrt{b}}\right) - \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}\]
    7. Applied distribute-lft-neg-in15.8

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(-\sqrt{b}, \sqrt{b}, -\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)}}\right) + \color{blue}{0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\]
    10. Using strategy rm
    11. Applied add-cube-cbrt15.8

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

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

    if 3.340270116328134e+83 < b

    1. Initial program 28.8

      \[\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. Simplified28.8

      \[\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-sqrt28.8

      \[\leadsto \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{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - b} \cdot \sqrt{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - b}}{2}}{a}\\ \end{array}\]
    5. Taylor expanded around inf 6.8

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{\left(\frac{a}{\frac{b}{c}} - b\right) \cdot 2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - b} \cdot \sqrt{\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 simplification12.3

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

Reproduce

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