Average Error: 44.1 → 10.0
Time: 15.0s
Precision: 64
\[1.1102230246251565 \cdot 10^{-16} \lt a \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt b \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt c \lt 9007199254740992.0\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -5.921074145804786 \cdot 10^{-07}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right) \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)} - b \cdot \left(b \cdot b\right)}{b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)} + \mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\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}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -5.921074145804786 \cdot 10^{-07}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right) \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)} - b \cdot \left(b \cdot b\right)}{b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)} + \mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)\right)}}{2 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1766141 = b;
        double r1766142 = -r1766141;
        double r1766143 = r1766141 * r1766141;
        double r1766144 = 4.0;
        double r1766145 = a;
        double r1766146 = r1766144 * r1766145;
        double r1766147 = c;
        double r1766148 = r1766146 * r1766147;
        double r1766149 = r1766143 - r1766148;
        double r1766150 = sqrt(r1766149);
        double r1766151 = r1766142 + r1766150;
        double r1766152 = 2.0;
        double r1766153 = r1766152 * r1766145;
        double r1766154 = r1766151 / r1766153;
        return r1766154;
}

double f(double a, double b, double c) {
        double r1766155 = b;
        double r1766156 = r1766155 * r1766155;
        double r1766157 = 4.0;
        double r1766158 = a;
        double r1766159 = r1766157 * r1766158;
        double r1766160 = c;
        double r1766161 = r1766159 * r1766160;
        double r1766162 = r1766156 - r1766161;
        double r1766163 = sqrt(r1766162);
        double r1766164 = -r1766155;
        double r1766165 = r1766163 + r1766164;
        double r1766166 = 2.0;
        double r1766167 = r1766166 * r1766158;
        double r1766168 = r1766165 / r1766167;
        double r1766169 = -5.921074145804786e-07;
        bool r1766170 = r1766168 <= r1766169;
        double r1766171 = r1766160 * r1766158;
        double r1766172 = -4.0;
        double r1766173 = r1766171 * r1766172;
        double r1766174 = fma(r1766155, r1766155, r1766173);
        double r1766175 = sqrt(r1766174);
        double r1766176 = r1766174 * r1766175;
        double r1766177 = r1766155 * r1766156;
        double r1766178 = r1766176 - r1766177;
        double r1766179 = r1766155 * r1766175;
        double r1766180 = fma(r1766155, r1766155, r1766174);
        double r1766181 = r1766179 + r1766180;
        double r1766182 = r1766178 / r1766181;
        double r1766183 = r1766182 / r1766167;
        double r1766184 = -r1766160;
        double r1766185 = r1766184 / r1766155;
        double r1766186 = r1766170 ? r1766183 : r1766185;
        return r1766186;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) < -5.921074145804786e-07

    1. Initial program 21.8

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

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

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

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

    if -5.921074145804786e-07 < (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))

    1. Initial program 53.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Taylor expanded around inf 5.1

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    3. Simplified5.1

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

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

Reproduce

herbie shell --seed 2019158 +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 a) c)))) (* 2 a)))