Average Error: 28.8 → 16.6
Time: 16.0s
Precision: 64
\[1.0536712127723509 \cdot 10^{-08} \lt a \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt b \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt c \lt 94906265.62425156\]
\[\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 6959.325006529954:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right) - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\left(\sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right), \left(b + \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right), \left(b \cdot b\right)\right)}}{2 \cdot a}\\ \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}\;b \le 6959.325006529954:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right) - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\left(\sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right), \left(b + \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right), \left(b \cdot b\right)\right)}}{2 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1346358 = b;
        double r1346359 = -r1346358;
        double r1346360 = r1346358 * r1346358;
        double r1346361 = 4.0;
        double r1346362 = a;
        double r1346363 = r1346361 * r1346362;
        double r1346364 = c;
        double r1346365 = r1346363 * r1346364;
        double r1346366 = r1346360 - r1346365;
        double r1346367 = sqrt(r1346366);
        double r1346368 = r1346359 + r1346367;
        double r1346369 = 2.0;
        double r1346370 = r1346369 * r1346362;
        double r1346371 = r1346368 / r1346370;
        return r1346371;
}

double f(double a, double b, double c) {
        double r1346372 = b;
        double r1346373 = 6959.325006529954;
        bool r1346374 = r1346372 <= r1346373;
        double r1346375 = -4.0;
        double r1346376 = c;
        double r1346377 = a;
        double r1346378 = r1346376 * r1346377;
        double r1346379 = r1346372 * r1346372;
        double r1346380 = fma(r1346375, r1346378, r1346379);
        double r1346381 = sqrt(r1346380);
        double r1346382 = r1346381 * r1346380;
        double r1346383 = r1346379 * r1346372;
        double r1346384 = r1346382 - r1346383;
        double r1346385 = r1346372 + r1346381;
        double r1346386 = fma(r1346381, r1346385, r1346379);
        double r1346387 = r1346384 / r1346386;
        double r1346388 = 2.0;
        double r1346389 = r1346388 * r1346377;
        double r1346390 = r1346387 / r1346389;
        double r1346391 = r1346376 / r1346372;
        double r1346392 = -r1346391;
        double r1346393 = r1346374 ? r1346390 : r1346392;
        return r1346393;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 19.0

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

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

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

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

    if 6959.325006529954 < b

    1. Initial program 38.1

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

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

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

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

Reproduce

herbie shell --seed 2019130 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :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)))