Average Error: 43.9 → 11.4
Time: 20.6s
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 6.961131476357276728544534868600712762543 \cdot 10^{-8}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-c \cdot a\right) \cdot 4\right)} - b}{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 6.961131476357276728544534868600712762543 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-c \cdot a\right) \cdot 4\right)} - b}{2}}{a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1589032 = b;
        double r1589033 = -r1589032;
        double r1589034 = r1589032 * r1589032;
        double r1589035 = 4.0;
        double r1589036 = a;
        double r1589037 = r1589035 * r1589036;
        double r1589038 = c;
        double r1589039 = r1589037 * r1589038;
        double r1589040 = r1589034 - r1589039;
        double r1589041 = sqrt(r1589040);
        double r1589042 = r1589033 + r1589041;
        double r1589043 = 2.0;
        double r1589044 = r1589043 * r1589036;
        double r1589045 = r1589042 / r1589044;
        return r1589045;
}

double f(double a, double b, double c) {
        double r1589046 = b;
        double r1589047 = 6.961131476357277e-08;
        bool r1589048 = r1589046 <= r1589047;
        double r1589049 = c;
        double r1589050 = a;
        double r1589051 = r1589049 * r1589050;
        double r1589052 = -r1589051;
        double r1589053 = 4.0;
        double r1589054 = r1589052 * r1589053;
        double r1589055 = fma(r1589046, r1589046, r1589054);
        double r1589056 = sqrt(r1589055);
        double r1589057 = r1589056 - r1589046;
        double r1589058 = 2.0;
        double r1589059 = r1589057 / r1589058;
        double r1589060 = r1589059 / r1589050;
        double r1589061 = -1.0;
        double r1589062 = r1589049 / r1589046;
        double r1589063 = r1589061 * r1589062;
        double r1589064 = r1589048 ? r1589060 : r1589063;
        return r1589064;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 6.961131476357277e-08

    1. Initial program 12.8

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

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

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

    if 6.961131476357277e-08 < b

    1. Initial program 44.7

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

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

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

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

Reproduce

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