Average Error: 52.4 → 6.1
Time: 14.4s
Precision: 64
\[4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt a \lt 20282409603651670423947251286016 \land 4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt b \lt 20282409603651670423947251286016 \land 4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt c \lt 20282409603651670423947251286016\]
\[\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 3.054798768406738353528696346741077845707 \cdot 10^{-17}:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 4 \cdot \left(a \cdot c\right)\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 3.054798768406738353528696346741077845707 \cdot 10^{-17}:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 4 \cdot \left(a \cdot c\right)\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 r15526 = b;
        double r15527 = -r15526;
        double r15528 = r15526 * r15526;
        double r15529 = 4.0;
        double r15530 = a;
        double r15531 = r15529 * r15530;
        double r15532 = c;
        double r15533 = r15531 * r15532;
        double r15534 = r15528 - r15533;
        double r15535 = sqrt(r15534);
        double r15536 = r15527 + r15535;
        double r15537 = 2.0;
        double r15538 = r15537 * r15530;
        double r15539 = r15536 / r15538;
        return r15539;
}

double f(double a, double b, double c) {
        double r15540 = b;
        double r15541 = 3.0547987684067384e-17;
        bool r15542 = r15540 <= r15541;
        double r15543 = r15540 * r15540;
        double r15544 = 4.0;
        double r15545 = a;
        double r15546 = c;
        double r15547 = r15545 * r15546;
        double r15548 = r15544 * r15547;
        double r15549 = fma(r15540, r15540, r15548);
        double r15550 = r15543 - r15549;
        double r15551 = r15544 * r15545;
        double r15552 = r15551 * r15546;
        double r15553 = r15543 - r15552;
        double r15554 = sqrt(r15553);
        double r15555 = r15554 + r15540;
        double r15556 = r15550 / r15555;
        double r15557 = 2.0;
        double r15558 = r15557 * r15545;
        double r15559 = r15556 / r15558;
        double r15560 = -1.0;
        double r15561 = r15546 / r15540;
        double r15562 = r15560 * r15561;
        double r15563 = r15542 ? r15559 : r15562;
        return r15563;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 3.0547987684067384e-17

    1. Initial program 21.3

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

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

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

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

    if 3.0547987684067384e-17 < b

    1. Initial program 53.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 3.054798768406738353528696346741077845707 \cdot 10^{-17}:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 4 \cdot \left(a \cdot c\right)\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 2019306 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, wide range"
  :precision binary64
  :pre (and (< 4.93038e-32 a 2.02824e31) (< 4.93038e-32 b 2.02824e31) (< 4.93038e-32 c 2.02824e31))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))