Average Error: 28.6 → 16.6
Time: 19.1s
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 77.85350311081474217189679620787501335144:\\ \;\;\;\;\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 77.85350311081474217189679620787501335144:\\
\;\;\;\;\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 r1976929 = b;
        double r1976930 = -r1976929;
        double r1976931 = r1976929 * r1976929;
        double r1976932 = 4.0;
        double r1976933 = a;
        double r1976934 = r1976932 * r1976933;
        double r1976935 = c;
        double r1976936 = r1976934 * r1976935;
        double r1976937 = r1976931 - r1976936;
        double r1976938 = sqrt(r1976937);
        double r1976939 = r1976930 + r1976938;
        double r1976940 = 2.0;
        double r1976941 = r1976940 * r1976933;
        double r1976942 = r1976939 / r1976941;
        return r1976942;
}

double f(double a, double b, double c) {
        double r1976943 = b;
        double r1976944 = 77.85350311081474;
        bool r1976945 = r1976943 <= r1976944;
        double r1976946 = r1976943 * r1976943;
        double r1976947 = 4.0;
        double r1976948 = c;
        double r1976949 = a;
        double r1976950 = r1976948 * r1976949;
        double r1976951 = r1976947 * r1976950;
        double r1976952 = r1976946 - r1976951;
        double r1976953 = sqrt(r1976952);
        double r1976954 = r1976952 * r1976953;
        double r1976955 = r1976946 * r1976943;
        double r1976956 = r1976954 - r1976955;
        double r1976957 = fma(r1976943, r1976953, r1976946);
        double r1976958 = r1976957 + r1976952;
        double r1976959 = r1976956 / r1976958;
        double r1976960 = 2.0;
        double r1976961 = r1976959 / r1976960;
        double r1976962 = r1976961 / r1976949;
        double r1976963 = -1.0;
        double r1976964 = r1976948 / r1976943;
        double r1976965 = r1976963 * r1976964;
        double r1976966 = r1976945 ? r1976962 : r1976965;
        return r1976966;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 14.9

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

      \[\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--15.0

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

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

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

    1. Initial program 34.5

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

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

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

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