Average Error: 43.7 → 11.6
Time: 43.4s
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}\;b \le 0.01334404880395557:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)} \cdot \mathsf{fma}\left(c \cdot a, -4, b \cdot b\right) - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}, b + \sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}, b \cdot b\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \mathsf{expm1}\left(\sqrt{\mathsf{log1p}\left(\frac{c \cdot a}{b}\right)} \cdot \sqrt{\mathsf{log1p}\left(\frac{c \cdot a}{b}\right)}\right)}{2 \cdot a}\\ \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.01334404880395557:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)} \cdot \mathsf{fma}\left(c \cdot a, -4, b \cdot b\right) - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}, b + \sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}, b \cdot b\right)}}{2 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \mathsf{expm1}\left(\sqrt{\mathsf{log1p}\left(\frac{c \cdot a}{b}\right)} \cdot \sqrt{\mathsf{log1p}\left(\frac{c \cdot a}{b}\right)}\right)}{2 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r2033393 = b;
        double r2033394 = -r2033393;
        double r2033395 = r2033393 * r2033393;
        double r2033396 = 4.0;
        double r2033397 = a;
        double r2033398 = r2033396 * r2033397;
        double r2033399 = c;
        double r2033400 = r2033398 * r2033399;
        double r2033401 = r2033395 - r2033400;
        double r2033402 = sqrt(r2033401);
        double r2033403 = r2033394 + r2033402;
        double r2033404 = 2.0;
        double r2033405 = r2033404 * r2033397;
        double r2033406 = r2033403 / r2033405;
        return r2033406;
}

double f(double a, double b, double c) {
        double r2033407 = b;
        double r2033408 = 0.01334404880395557;
        bool r2033409 = r2033407 <= r2033408;
        double r2033410 = c;
        double r2033411 = a;
        double r2033412 = r2033410 * r2033411;
        double r2033413 = -4.0;
        double r2033414 = r2033407 * r2033407;
        double r2033415 = fma(r2033412, r2033413, r2033414);
        double r2033416 = sqrt(r2033415);
        double r2033417 = r2033416 * r2033415;
        double r2033418 = r2033414 * r2033407;
        double r2033419 = r2033417 - r2033418;
        double r2033420 = r2033407 + r2033416;
        double r2033421 = fma(r2033416, r2033420, r2033414);
        double r2033422 = r2033419 / r2033421;
        double r2033423 = 2.0;
        double r2033424 = r2033423 * r2033411;
        double r2033425 = r2033422 / r2033424;
        double r2033426 = -2.0;
        double r2033427 = r2033412 / r2033407;
        double r2033428 = log1p(r2033427);
        double r2033429 = sqrt(r2033428);
        double r2033430 = r2033429 * r2033429;
        double r2033431 = expm1(r2033430);
        double r2033432 = r2033426 * r2033431;
        double r2033433 = r2033432 / r2033424;
        double r2033434 = r2033409 ? r2033425 : r2033433;
        return r2033434;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 22.1

      \[\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-+22.2

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

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)} \cdot \mathsf{fma}\left(c \cdot a, -4, b \cdot b\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.5

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

    if 0.01334404880395557 < b

    1. Initial program 46.5

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

      \[\leadsto \frac{\color{blue}{-2 \cdot \frac{a \cdot c}{b}}}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied expm1-log1p-u10.2

      \[\leadsto \frac{-2 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{a \cdot c}{b}\right)\right)}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt10.4

      \[\leadsto \frac{-2 \cdot \mathsf{expm1}\left(\color{blue}{\sqrt{\mathsf{log1p}\left(\frac{a \cdot c}{b}\right)} \cdot \sqrt{\mathsf{log1p}\left(\frac{a \cdot c}{b}\right)}}\right)}{2 \cdot a}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification11.6

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

Reproduce

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