Average Error: 28.6 → 16.3
Time: 19.6s
Precision: 64
\[1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt a \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt b \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt c \lt 94906265.62425155937671661376953125\]
\[\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 6015.720092576997558353468775749206542969:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}, b \cdot b\right) + \left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right)}}{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 6015.720092576997558353468775749206542969:\\
\;\;\;\;\frac{\frac{\frac{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}, b \cdot b\right) + \left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right)}}{2}}{a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1966829 = b;
        double r1966830 = -r1966829;
        double r1966831 = r1966829 * r1966829;
        double r1966832 = 4.0;
        double r1966833 = a;
        double r1966834 = r1966832 * r1966833;
        double r1966835 = c;
        double r1966836 = r1966834 * r1966835;
        double r1966837 = r1966831 - r1966836;
        double r1966838 = sqrt(r1966837);
        double r1966839 = r1966830 + r1966838;
        double r1966840 = 2.0;
        double r1966841 = r1966840 * r1966833;
        double r1966842 = r1966839 / r1966841;
        return r1966842;
}

double f(double a, double b, double c) {
        double r1966843 = b;
        double r1966844 = 6015.720092576998;
        bool r1966845 = r1966843 <= r1966844;
        double r1966846 = r1966843 * r1966843;
        double r1966847 = 4.0;
        double r1966848 = c;
        double r1966849 = a;
        double r1966850 = r1966848 * r1966849;
        double r1966851 = r1966847 * r1966850;
        double r1966852 = r1966846 - r1966851;
        double r1966853 = sqrt(r1966852);
        double r1966854 = r1966852 * r1966853;
        double r1966855 = r1966846 * r1966843;
        double r1966856 = r1966854 - r1966855;
        double r1966857 = fma(r1966843, r1966853, r1966846);
        double r1966858 = r1966857 + r1966852;
        double r1966859 = r1966856 / r1966858;
        double r1966860 = 2.0;
        double r1966861 = r1966859 / r1966860;
        double r1966862 = r1966861 / r1966849;
        double r1966863 = -1.0;
        double r1966864 = r1966848 / r1966843;
        double r1966865 = r1966863 * r1966864;
        double r1966866 = r1966845 ? r1966862 : r1966865;
        return r1966866;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 18.6

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

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

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

      \[\leadsto \frac{\frac{\frac{\color{blue}{\left(b \cdot b - \left(c \cdot a\right) \cdot 4\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b \cdot \left(b \cdot b\right)}}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} + \left(b \cdot b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} \cdot b\right)}}{2}}{a}\]
    6. Simplified17.9

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

    if 6015.720092576998 < b

    1. Initial program 38.2

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

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

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

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

Reproduce

herbie shell --seed 2019169 +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.0 a) c)))) (* 2.0 a)))