Average Error: 44.3 → 10.3
Time: 48.5s
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.23006184402457236:\\ \;\;\;\;\frac{\frac{b \cdot b - \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) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -7.174313107484387 \cdot 10^{-05}:\\ \;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\log \left(\frac{c \cdot a}{b}\right)}\right)\right) \cdot -2}{2 \cdot a}\\ \mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -7.611140755287658 \cdot 10^{-08}:\\ \;\;\;\;\sqrt[3]{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)} - b}{2 \cdot a} \cdot \left(\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)} - b}{2 \cdot a} \cdot \frac{\sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)} - b}{2 \cdot a}\right)}\\ \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.23006184402457236:\\
\;\;\;\;\frac{\frac{b \cdot b - \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) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\

\mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -7.174313107484387 \cdot 10^{-05}:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\log \left(\frac{c \cdot a}{b}\right)}\right)\right) \cdot -2}{2 \cdot a}\\

\mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -7.611140755287658 \cdot 10^{-08}:\\
\;\;\;\;\sqrt[3]{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)} - b}{2 \cdot a} \cdot \left(\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)} - b}{2 \cdot a} \cdot \frac{\sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)} - b}{2 \cdot a}\right)}\\

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

\end{array}
double f(double a, double b, double c) {
        double r2119372 = b;
        double r2119373 = -r2119372;
        double r2119374 = r2119372 * r2119372;
        double r2119375 = 4.0;
        double r2119376 = a;
        double r2119377 = r2119375 * r2119376;
        double r2119378 = c;
        double r2119379 = r2119377 * r2119378;
        double r2119380 = r2119374 - r2119379;
        double r2119381 = sqrt(r2119380);
        double r2119382 = r2119373 + r2119381;
        double r2119383 = 2.0;
        double r2119384 = r2119383 * r2119376;
        double r2119385 = r2119382 / r2119384;
        return r2119385;
}

double f(double a, double b, double c) {
        double r2119386 = b;
        double r2119387 = r2119386 * r2119386;
        double r2119388 = 4.0;
        double r2119389 = a;
        double r2119390 = r2119388 * r2119389;
        double r2119391 = c;
        double r2119392 = r2119390 * r2119391;
        double r2119393 = r2119387 - r2119392;
        double r2119394 = sqrt(r2119393);
        double r2119395 = -r2119386;
        double r2119396 = r2119394 + r2119395;
        double r2119397 = 2.0;
        double r2119398 = r2119397 * r2119389;
        double r2119399 = r2119396 / r2119398;
        double r2119400 = -0.23006184402457236;
        bool r2119401 = r2119399 <= r2119400;
        double r2119402 = r2119394 * r2119394;
        double r2119403 = r2119387 - r2119402;
        double r2119404 = r2119395 - r2119394;
        double r2119405 = r2119403 / r2119404;
        double r2119406 = r2119405 / r2119398;
        double r2119407 = -7.174313107484387e-05;
        bool r2119408 = r2119399 <= r2119407;
        double r2119409 = r2119391 * r2119389;
        double r2119410 = r2119409 / r2119386;
        double r2119411 = log(r2119410);
        double r2119412 = exp(r2119411);
        double r2119413 = log1p(r2119412);
        double r2119414 = expm1(r2119413);
        double r2119415 = -2.0;
        double r2119416 = r2119414 * r2119415;
        double r2119417 = r2119416 / r2119398;
        double r2119418 = -7.611140755287658e-08;
        bool r2119419 = r2119399 <= r2119418;
        double r2119420 = -4.0;
        double r2119421 = r2119420 * r2119389;
        double r2119422 = r2119421 * r2119391;
        double r2119423 = fma(r2119386, r2119386, r2119422);
        double r2119424 = sqrt(r2119423);
        double r2119425 = r2119424 - r2119386;
        double r2119426 = r2119425 / r2119398;
        double r2119427 = r2119426 * r2119426;
        double r2119428 = r2119426 * r2119427;
        double r2119429 = cbrt(r2119428);
        double r2119430 = -r2119391;
        double r2119431 = r2119430 / r2119386;
        double r2119432 = r2119419 ? r2119429 : r2119431;
        double r2119433 = r2119408 ? r2119417 : r2119432;
        double r2119434 = r2119401 ? r2119406 : r2119433;
        return r2119434;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 20.3

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

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \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) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]

    if -0.23006184402457236 < (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) < -7.174313107484387e-05

    1. Initial program 23.6

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

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

      \[\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-exp-log25.7

      \[\leadsto \frac{-2 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{e^{\log \left(\frac{a \cdot c}{b}\right)}}\right)\right)}{2 \cdot a}\]

    if -7.174313107484387e-05 < (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) < -7.611140755287658e-08

    1. Initial program 25.4

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{\sqrt[3]{\left(\left(2 \cdot 2\right) \cdot 2\right) \cdot \left(\left(a \cdot a\right) \cdot a\right)}}}\]
    6. Applied add-cbrt-cube25.4

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

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

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

    if -7.611140755287658e-08 < (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))

    1. Initial program 54.3

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

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

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

    \[\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.23006184402457236:\\ \;\;\;\;\frac{\frac{b \cdot b - \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) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -7.174313107484387 \cdot 10^{-05}:\\ \;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\log \left(\frac{c \cdot a}{b}\right)}\right)\right) \cdot -2}{2 \cdot a}\\ \mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -7.611140755287658 \cdot 10^{-08}:\\ \;\;\;\;\sqrt[3]{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)} - b}{2 \cdot a} \cdot \left(\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)} - b}{2 \cdot a} \cdot \frac{\sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)} - b}{2 \cdot a}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array}\]

Reproduce

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