Average Error: 19.4 → 13.6
Time: 52.7s
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 4.965076354638055 \cdot 10^{+62}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(\sqrt{b}, -\sqrt{b}, \left(-\sqrt{\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}\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)}}\right) + \mathsf{fma}\left(-\sqrt{\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}, \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)}}, \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)}}\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{\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 4.965076354638055 \cdot 10^{+62}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(\sqrt{b}, -\sqrt{b}, \left(-\sqrt{\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}\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)}}\right) + \mathsf{fma}\left(-\sqrt{\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}, \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)}}, \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)}}\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{\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 r827592 = b;
        double r827593 = 0.0;
        bool r827594 = r827592 >= r827593;
        double r827595 = 2.0;
        double r827596 = c;
        double r827597 = r827595 * r827596;
        double r827598 = -r827592;
        double r827599 = r827592 * r827592;
        double r827600 = 4.0;
        double r827601 = a;
        double r827602 = r827600 * r827601;
        double r827603 = r827602 * r827596;
        double r827604 = r827599 - r827603;
        double r827605 = sqrt(r827604);
        double r827606 = r827598 - r827605;
        double r827607 = r827597 / r827606;
        double r827608 = r827598 + r827605;
        double r827609 = r827595 * r827601;
        double r827610 = r827608 / r827609;
        double r827611 = r827594 ? r827607 : r827610;
        return r827611;
}

double f(double a, double b, double c) {
        double r827612 = b;
        double r827613 = 4.965076354638055e+62;
        bool r827614 = r827612 <= r827613;
        double r827615 = 0.0;
        bool r827616 = r827612 >= r827615;
        double r827617 = 2.0;
        double r827618 = c;
        double r827619 = r827617 * r827618;
        double r827620 = sqrt(r827612);
        double r827621 = -r827620;
        double r827622 = -4.0;
        double r827623 = a;
        double r827624 = r827623 * r827618;
        double r827625 = r827612 * r827612;
        double r827626 = fma(r827622, r827624, r827625);
        double r827627 = cbrt(r827626);
        double r827628 = sqrt(r827627);
        double r827629 = -r827628;
        double r827630 = r827627 * r827627;
        double r827631 = sqrt(r827630);
        double r827632 = r827629 * r827631;
        double r827633 = fma(r827620, r827621, r827632);
        double r827634 = r827628 * r827631;
        double r827635 = fma(r827629, r827631, r827634);
        double r827636 = r827633 + r827635;
        double r827637 = r827619 / r827636;
        double r827638 = sqrt(r827626);
        double r827639 = r827638 - r827612;
        double r827640 = r827639 / r827617;
        double r827641 = r827640 / r827623;
        double r827642 = r827616 ? r827637 : r827641;
        double r827643 = r827612 / r827618;
        double r827644 = r827623 / r827643;
        double r827645 = r827644 - r827612;
        double r827646 = r827645 * r827617;
        double r827647 = r827619 / r827646;
        double r827648 = r827616 ? r827647 : r827641;
        double r827649 = r827614 ? r827642 : r827648;
        return r827649;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 4.965076354638055e+62

    1. Initial program 17.0

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

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

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

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

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

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

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

    if 4.965076354638055e+62 < b

    1. Initial program 25.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. 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 inf 7.7

      \[\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{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\]
    4. Simplified4.1

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

Reproduce

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