Average Error: 43.8 → 10.6
Time: 14.2s
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 -0.09832362615184849:\\ \;\;\;\;\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 -0.09832362615184849:\\
\;\;\;\;\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 r1304403 = b;
        double r1304404 = -r1304403;
        double r1304405 = r1304403 * r1304403;
        double r1304406 = 4.0;
        double r1304407 = a;
        double r1304408 = r1304406 * r1304407;
        double r1304409 = c;
        double r1304410 = r1304408 * r1304409;
        double r1304411 = r1304405 - r1304410;
        double r1304412 = sqrt(r1304411);
        double r1304413 = r1304404 + r1304412;
        double r1304414 = 2.0;
        double r1304415 = r1304414 * r1304407;
        double r1304416 = r1304413 / r1304415;
        return r1304416;
}

double f(double a, double b, double c) {
        double r1304417 = b;
        double r1304418 = r1304417 * r1304417;
        double r1304419 = 4.0;
        double r1304420 = a;
        double r1304421 = r1304419 * r1304420;
        double r1304422 = c;
        double r1304423 = r1304421 * r1304422;
        double r1304424 = r1304418 - r1304423;
        double r1304425 = sqrt(r1304424);
        double r1304426 = -r1304417;
        double r1304427 = r1304425 + r1304426;
        double r1304428 = 2.0;
        double r1304429 = r1304428 * r1304420;
        double r1304430 = r1304427 / r1304429;
        double r1304431 = -0.09832362615184849;
        bool r1304432 = r1304430 <= r1304431;
        double r1304433 = r1304422 * r1304420;
        double r1304434 = -4.0;
        double r1304435 = r1304433 * r1304434;
        double r1304436 = fma(r1304417, r1304417, r1304435);
        double r1304437 = sqrt(r1304436);
        double r1304438 = r1304436 * r1304437;
        double r1304439 = r1304417 * r1304418;
        double r1304440 = r1304438 - r1304439;
        double r1304441 = r1304417 * r1304437;
        double r1304442 = fma(r1304417, r1304417, r1304436);
        double r1304443 = r1304441 + r1304442;
        double r1304444 = r1304440 / r1304443;
        double r1304445 = r1304444 / r1304429;
        double r1304446 = -r1304422;
        double r1304447 = r1304446 / r1304417;
        double r1304448 = r1304432 ? r1304445 : r1304447;
        return r1304448;
}

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)) < -0.09832362615184849

    1. Initial program 20.9

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

      \[\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. Simplified20.3

      \[\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. Simplified20.3

      \[\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 -0.09832362615184849 < (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))

    1. Initial program 48.5

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

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

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

    \[\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 -0.09832362615184849:\\ \;\;\;\;\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 2019164 +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)))