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

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

\end{array}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r1340742 = b;
        double r1340743 = 0.0;
        bool r1340744 = r1340742 >= r1340743;
        double r1340745 = 2.0;
        double r1340746 = c;
        double r1340747 = r1340745 * r1340746;
        double r1340748 = -r1340742;
        double r1340749 = r1340742 * r1340742;
        double r1340750 = 4.0;
        double r1340751 = a;
        double r1340752 = r1340750 * r1340751;
        double r1340753 = r1340752 * r1340746;
        double r1340754 = r1340749 - r1340753;
        double r1340755 = sqrt(r1340754);
        double r1340756 = r1340748 - r1340755;
        double r1340757 = r1340747 / r1340756;
        double r1340758 = r1340748 + r1340755;
        double r1340759 = r1340745 * r1340751;
        double r1340760 = r1340758 / r1340759;
        double r1340761 = r1340744 ? r1340757 : r1340760;
        return r1340761;
}

double f(double a, double b, double c) {
        double r1340762 = b;
        double r1340763 = 1.3980645719974047e+42;
        bool r1340764 = r1340762 <= r1340763;
        double r1340765 = 0.0;
        bool r1340766 = r1340762 >= r1340765;
        double r1340767 = 2.0;
        double r1340768 = c;
        double r1340769 = r1340767 * r1340768;
        double r1340770 = -r1340762;
        double r1340771 = -4.0;
        double r1340772 = a;
        double r1340773 = r1340772 * r1340768;
        double r1340774 = r1340762 * r1340762;
        double r1340775 = fma(r1340771, r1340773, r1340774);
        double r1340776 = sqrt(r1340775);
        double r1340777 = sqrt(r1340776);
        double r1340778 = r1340777 * r1340777;
        double r1340779 = r1340770 - r1340778;
        double r1340780 = r1340769 / r1340779;
        double r1340781 = r1340762 + r1340770;
        double r1340782 = r1340771 * r1340772;
        double r1340783 = fma(r1340782, r1340768, r1340774);
        double r1340784 = sqrt(r1340783);
        double r1340785 = r1340784 - r1340762;
        double r1340786 = r1340781 + r1340785;
        double r1340787 = r1340767 * r1340772;
        double r1340788 = r1340786 / r1340787;
        double r1340789 = r1340766 ? r1340780 : r1340788;
        double r1340790 = r1340770 - r1340762;
        double r1340791 = r1340769 / r1340790;
        double r1340792 = r1340766 ? r1340791 : r1340788;
        double r1340793 = r1340764 ? r1340789 : r1340792;
        return r1340793;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 1.3980645719974047e+42

    1. Initial program 17.5

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt{\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)} - b\right) + \mathsf{fma}\left(\left(-b\right), 1, \left(b \cdot 1\right)\right)}{2 \cdot a}\\ \end{array}\]
    8. Simplified17.5

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

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

    if 1.3980645719974047e+42 < b

    1. Initial program 24.9

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

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

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

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

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

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

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

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

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

Reproduce

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