Average Error: 43.0 → 11.7
Time: 19.7s
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 1.143841598112384838194601800742677966127 \cdot 10^{-6}:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}, b \cdot b\right) + \left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right)}}{2}}{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 1.143841598112384838194601800742677966127 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{\frac{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}, b \cdot b\right) + \left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right)}}{2}}{a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1929711 = b;
        double r1929712 = -r1929711;
        double r1929713 = r1929711 * r1929711;
        double r1929714 = 4.0;
        double r1929715 = a;
        double r1929716 = r1929714 * r1929715;
        double r1929717 = c;
        double r1929718 = r1929716 * r1929717;
        double r1929719 = r1929713 - r1929718;
        double r1929720 = sqrt(r1929719);
        double r1929721 = r1929712 + r1929720;
        double r1929722 = 2.0;
        double r1929723 = r1929722 * r1929715;
        double r1929724 = r1929721 / r1929723;
        return r1929724;
}

double f(double a, double b, double c) {
        double r1929725 = b;
        double r1929726 = 1.1438415981123848e-06;
        bool r1929727 = r1929725 <= r1929726;
        double r1929728 = r1929725 * r1929725;
        double r1929729 = 4.0;
        double r1929730 = c;
        double r1929731 = a;
        double r1929732 = r1929730 * r1929731;
        double r1929733 = r1929729 * r1929732;
        double r1929734 = r1929728 - r1929733;
        double r1929735 = sqrt(r1929734);
        double r1929736 = r1929734 * r1929735;
        double r1929737 = r1929728 * r1929725;
        double r1929738 = r1929736 - r1929737;
        double r1929739 = fma(r1929725, r1929735, r1929728);
        double r1929740 = r1929739 + r1929734;
        double r1929741 = r1929738 / r1929740;
        double r1929742 = 2.0;
        double r1929743 = r1929741 / r1929742;
        double r1929744 = r1929743 / r1929731;
        double r1929745 = -1.0;
        double r1929746 = r1929730 / r1929725;
        double r1929747 = r1929745 * r1929746;
        double r1929748 = r1929727 ? r1929744 : r1929747;
        return r1929748;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 1.1438415981123848e-06

    1. Initial program 14.4

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

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

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

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

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

    if 1.1438415981123848e-06 < b

    1. Initial program 44.2

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

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

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

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

Reproduce

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