Average Error: 43.8 → 11.2
Time: 13.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 0.003147622297084620886231665082277686451562:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(c, 4 \cdot a, b \cdot b\right)}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{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 0.003147622297084620886231665082277686451562:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(c, 4 \cdot a, b \cdot b\right)}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{2 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r33122 = b;
        double r33123 = -r33122;
        double r33124 = r33122 * r33122;
        double r33125 = 4.0;
        double r33126 = a;
        double r33127 = r33125 * r33126;
        double r33128 = c;
        double r33129 = r33127 * r33128;
        double r33130 = r33124 - r33129;
        double r33131 = sqrt(r33130);
        double r33132 = r33123 + r33131;
        double r33133 = 2.0;
        double r33134 = r33133 * r33126;
        double r33135 = r33132 / r33134;
        return r33135;
}

double f(double a, double b, double c) {
        double r33136 = b;
        double r33137 = 0.003147622297084621;
        bool r33138 = r33136 <= r33137;
        double r33139 = r33136 * r33136;
        double r33140 = c;
        double r33141 = 4.0;
        double r33142 = a;
        double r33143 = r33141 * r33142;
        double r33144 = fma(r33140, r33143, r33139);
        double r33145 = r33139 - r33144;
        double r33146 = r33143 * r33140;
        double r33147 = r33139 - r33146;
        double r33148 = sqrt(r33147);
        double r33149 = r33148 + r33136;
        double r33150 = r33145 / r33149;
        double r33151 = 2.0;
        double r33152 = r33151 * r33142;
        double r33153 = r33150 / r33152;
        double r33154 = -1.0;
        double r33155 = r33140 / r33136;
        double r33156 = r33154 * r33155;
        double r33157 = r33138 ? r33153 : r33156;
        return r33157;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 0.003147622297084621

    1. Initial program 21.1

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

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

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

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

    if 0.003147622297084621 < b

    1. Initial program 46.2

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

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

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

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

Reproduce

herbie shell --seed 2019305 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e15) (< 1.11022e-16 b 9.0072e15) (< 1.11022e-16 c 9.0072e15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))