Average Error: 43.6 → 11.1
Time: 25.4s
Precision: 64
\[1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt a \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt b \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt c \lt 9007199254740992\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le 8.984490456930243999777996322109174798243 \cdot 10^{-5}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - a \cdot \left(c \cdot 4\right)\right) \cdot \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)} + b, b \cdot b - a \cdot \left(c \cdot 4\right)\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le 8.984490456930243999777996322109174798243 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - a \cdot \left(c \cdot 4\right)\right) \cdot \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)} + b, b \cdot b - a \cdot \left(c \cdot 4\right)\right)}}{2 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r1748748 = b;
        double r1748749 = -r1748748;
        double r1748750 = r1748748 * r1748748;
        double r1748751 = 4.0;
        double r1748752 = a;
        double r1748753 = r1748751 * r1748752;
        double r1748754 = c;
        double r1748755 = r1748753 * r1748754;
        double r1748756 = r1748750 - r1748755;
        double r1748757 = sqrt(r1748756);
        double r1748758 = r1748749 + r1748757;
        double r1748759 = 2.0;
        double r1748760 = r1748759 * r1748752;
        double r1748761 = r1748758 / r1748760;
        return r1748761;
}

double f(double a, double b, double c) {
        double r1748762 = b;
        double r1748763 = 8.984490456930244e-05;
        bool r1748764 = r1748762 <= r1748763;
        double r1748765 = r1748762 * r1748762;
        double r1748766 = a;
        double r1748767 = c;
        double r1748768 = 4.0;
        double r1748769 = r1748767 * r1748768;
        double r1748770 = r1748766 * r1748769;
        double r1748771 = r1748765 - r1748770;
        double r1748772 = sqrt(r1748771);
        double r1748773 = r1748771 * r1748772;
        double r1748774 = r1748765 * r1748762;
        double r1748775 = r1748773 - r1748774;
        double r1748776 = r1748772 + r1748762;
        double r1748777 = fma(r1748762, r1748776, r1748771);
        double r1748778 = r1748775 / r1748777;
        double r1748779 = 2.0;
        double r1748780 = r1748779 * r1748766;
        double r1748781 = r1748778 / r1748780;
        double r1748782 = -1.0;
        double r1748783 = r1748767 / r1748762;
        double r1748784 = r1748782 * r1748783;
        double r1748785 = r1748764 ? r1748781 : r1748784;
        return r1748785;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 8.984490456930244e-05

    1. Initial program 17.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified17.3

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{2 \cdot a}}\]
    3. Using strategy rm
    4. Applied flip3--17.4

      \[\leadsto \frac{\color{blue}{\frac{{\left(\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}\right)}^{3} - {b}^{3}}{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} \cdot \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} + \left(b \cdot b + \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} \cdot b\right)}}}{2 \cdot a}\]
    5. Simplified16.6

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} \cdot \left(b \cdot b - \left(4 \cdot c\right) \cdot a\right) - b \cdot \left(b \cdot b\right)}}{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} \cdot \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} + \left(b \cdot b + \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} \cdot b\right)}}{2 \cdot a}\]
    6. Simplified16.6

      \[\leadsto \frac{\frac{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} \cdot \left(b \cdot b - \left(4 \cdot c\right) \cdot a\right) - b \cdot \left(b \cdot b\right)}{\color{blue}{\mathsf{fma}\left(b, b + \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a}, b \cdot b - \left(4 \cdot c\right) \cdot a\right)}}}{2 \cdot a}\]

    if 8.984490456930244e-05 < b

    1. Initial program 45.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified45.5

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{2 \cdot a}}\]
    3. Taylor expanded around inf 10.7

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification11.1

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

Reproduce

herbie shell --seed 2019200 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))