Average Error: 28.8 → 16.4
Time: 7.9s
Precision: 64
\[1.05367121277235087 \cdot 10^{-8} \lt a \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt b \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt c \lt 94906265.6242515594\]
\[\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 228.26278739030357:\\ \;\;\;\;\frac{\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(4 \cdot a\right) \cdot c\right)}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{2}}{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 228.26278739030357:\\
\;\;\;\;\frac{\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(4 \cdot a\right) \cdot c\right)}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{2}}{a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r22588 = b;
        double r22589 = -r22588;
        double r22590 = r22588 * r22588;
        double r22591 = 4.0;
        double r22592 = a;
        double r22593 = r22591 * r22592;
        double r22594 = c;
        double r22595 = r22593 * r22594;
        double r22596 = r22590 - r22595;
        double r22597 = sqrt(r22596);
        double r22598 = r22589 + r22597;
        double r22599 = 2.0;
        double r22600 = r22599 * r22592;
        double r22601 = r22598 / r22600;
        return r22601;
}

double f(double a, double b, double c) {
        double r22602 = b;
        double r22603 = 228.26278739030357;
        bool r22604 = r22602 <= r22603;
        double r22605 = r22602 * r22602;
        double r22606 = 4.0;
        double r22607 = a;
        double r22608 = r22606 * r22607;
        double r22609 = c;
        double r22610 = r22608 * r22609;
        double r22611 = fma(r22602, r22602, r22610);
        double r22612 = r22605 - r22611;
        double r22613 = r22605 - r22610;
        double r22614 = sqrt(r22613);
        double r22615 = r22614 + r22602;
        double r22616 = r22612 / r22615;
        double r22617 = 2.0;
        double r22618 = r22616 / r22617;
        double r22619 = r22618 / r22607;
        double r22620 = -1.0;
        double r22621 = r22609 / r22602;
        double r22622 = r22620 * r22621;
        double r22623 = r22604 ? r22619 : r22622;
        return r22623;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 16.2

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

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

      \[\leadsto \frac{\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}}{a}\]
    5. Simplified15.4

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

    if 228.26278739030357 < b

    1. Initial program 35.3

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

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

      \[\leadsto \frac{\frac{\color{blue}{-2 \cdot \frac{a \cdot c}{b}}}{2}}{a}\]
    4. Using strategy rm
    5. Applied associate-/l*17.0

      \[\leadsto \frac{\frac{-2 \cdot \color{blue}{\frac{a}{\frac{b}{c}}}}{2}}{a}\]
    6. Taylor expanded around 0 16.9

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

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

Reproduce

herbie shell --seed 2020045 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :precision binary64
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))