Average Error: 19.2 → 12.5
Time: 16.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.3660304103825555 \cdot 10^{+138}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(\sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)} - b\right) + \mathsf{fma}\left(b, -1, b\right)}{2}}{a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)} - b} \cdot \frac{\frac{\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.3660304103825555 \cdot 10^{+138}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}\\

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

\end{array}\\

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

\mathbf{else}:\\
\;\;\;\;\sqrt{\sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)} - b} \cdot \frac{\frac{\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 r436586 = b;
        double r436587 = 0.0;
        bool r436588 = r436586 >= r436587;
        double r436589 = 2.0;
        double r436590 = c;
        double r436591 = r436589 * r436590;
        double r436592 = -r436586;
        double r436593 = r436586 * r436586;
        double r436594 = 4.0;
        double r436595 = a;
        double r436596 = r436594 * r436595;
        double r436597 = r436596 * r436590;
        double r436598 = r436593 - r436597;
        double r436599 = sqrt(r436598);
        double r436600 = r436592 - r436599;
        double r436601 = r436591 / r436600;
        double r436602 = r436592 + r436599;
        double r436603 = r436589 * r436595;
        double r436604 = r436602 / r436603;
        double r436605 = r436588 ? r436601 : r436604;
        return r436605;
}

double f(double a, double b, double c) {
        double r436606 = b;
        double r436607 = 3.3660304103825555e+138;
        bool r436608 = r436606 <= r436607;
        double r436609 = 0.0;
        bool r436610 = r436606 >= r436609;
        double r436611 = 2.0;
        double r436612 = c;
        double r436613 = r436611 * r436612;
        double r436614 = -r436606;
        double r436615 = -4.0;
        double r436616 = a;
        double r436617 = r436616 * r436612;
        double r436618 = r436606 * r436606;
        double r436619 = fma(r436615, r436617, r436618);
        double r436620 = sqrt(r436619);
        double r436621 = r436614 - r436620;
        double r436622 = r436613 / r436621;
        double r436623 = r436615 * r436616;
        double r436624 = fma(r436623, r436612, r436618);
        double r436625 = sqrt(r436624);
        double r436626 = r436625 - r436606;
        double r436627 = -1.0;
        double r436628 = fma(r436606, r436627, r436606);
        double r436629 = r436626 + r436628;
        double r436630 = r436629 / r436611;
        double r436631 = r436630 / r436616;
        double r436632 = r436610 ? r436622 : r436631;
        double r436633 = r436614 - r436606;
        double r436634 = r436613 / r436633;
        double r436635 = r436620 - r436606;
        double r436636 = sqrt(r436635);
        double r436637 = r436636 / r436611;
        double r436638 = r436637 / r436616;
        double r436639 = r436636 * r436638;
        double r436640 = r436610 ? r436634 : r436639;
        double r436641 = r436608 ? r436632 : r436640;
        return r436641;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 3.3660304103825555e+138

    1. Initial program 15.2

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

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

      \[\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{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - \left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}}{2}}{a}\\ \end{array}\]
    5. Applied add-cube-cbrt15.6

      \[\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{\left(\sqrt[3]{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}} \cdot \sqrt[3]{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}\right) \cdot \sqrt[3]{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}} - \left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}}{2}}{a}\\ \end{array}\]
    6. Applied prod-diff15.6

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

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

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

    if 3.3660304103825555e+138 < b

    1. Initial program 36.2

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

      \[\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}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity1.7

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - 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}}{1 \cdot 2}}{1 \cdot a}\\ \end{array}\]
    8. Applied times-frac1.7

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

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

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

Reproduce

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