Average Error: 28.8 → 16.8
Time: 7.8s
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 5060.8354328326695:\\ \;\;\;\;\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 5060.8354328326695:\\
\;\;\;\;\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 r32261 = b;
        double r32262 = -r32261;
        double r32263 = r32261 * r32261;
        double r32264 = 4.0;
        double r32265 = a;
        double r32266 = r32264 * r32265;
        double r32267 = c;
        double r32268 = r32266 * r32267;
        double r32269 = r32263 - r32268;
        double r32270 = sqrt(r32269);
        double r32271 = r32262 + r32270;
        double r32272 = 2.0;
        double r32273 = r32272 * r32265;
        double r32274 = r32271 / r32273;
        return r32274;
}

double f(double a, double b, double c) {
        double r32275 = b;
        double r32276 = 5060.8354328326695;
        bool r32277 = r32275 <= r32276;
        double r32278 = r32275 * r32275;
        double r32279 = 4.0;
        double r32280 = a;
        double r32281 = r32279 * r32280;
        double r32282 = c;
        double r32283 = r32281 * r32282;
        double r32284 = fma(r32275, r32275, r32283);
        double r32285 = r32278 - r32284;
        double r32286 = r32278 - r32283;
        double r32287 = sqrt(r32286);
        double r32288 = r32287 + r32275;
        double r32289 = r32285 / r32288;
        double r32290 = 2.0;
        double r32291 = r32289 / r32290;
        double r32292 = r32291 / r32280;
        double r32293 = -1.0;
        double r32294 = r32282 / r32275;
        double r32295 = r32293 * r32294;
        double r32296 = r32277 ? r32292 : r32295;
        return r32296;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 19.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified19.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--19.3

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

      \[\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 5060.8354328326695 < b

    1. Initial program 37.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 5060.8354328326695:\\ \;\;\;\;\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 2020043 +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)))