Average Error: 44.1 → 11.1
Time: 11.9s
Precision: 64
\[1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt a \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt b \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt c \lt 9007199254740992\]
\[\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 6.724747266396373623605423053284368961613 \cdot 10^{-6}:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 4 \cdot \left(a \cdot c\right)\right)}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{2 \cdot 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 6.724747266396373623605423053284368961613 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 4 \cdot \left(a \cdot c\right)\right)}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{2 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r28930 = b;
        double r28931 = -r28930;
        double r28932 = r28930 * r28930;
        double r28933 = 4.0;
        double r28934 = a;
        double r28935 = r28933 * r28934;
        double r28936 = c;
        double r28937 = r28935 * r28936;
        double r28938 = r28932 - r28937;
        double r28939 = sqrt(r28938);
        double r28940 = r28931 + r28939;
        double r28941 = 2.0;
        double r28942 = r28941 * r28934;
        double r28943 = r28940 / r28942;
        return r28943;
}

double f(double a, double b, double c) {
        double r28944 = b;
        double r28945 = 6.724747266396374e-06;
        bool r28946 = r28944 <= r28945;
        double r28947 = r28944 * r28944;
        double r28948 = 4.0;
        double r28949 = a;
        double r28950 = c;
        double r28951 = r28949 * r28950;
        double r28952 = r28948 * r28951;
        double r28953 = fma(r28944, r28944, r28952);
        double r28954 = r28947 - r28953;
        double r28955 = r28948 * r28949;
        double r28956 = r28955 * r28950;
        double r28957 = r28947 - r28956;
        double r28958 = sqrt(r28957);
        double r28959 = r28958 + r28944;
        double r28960 = r28954 / r28959;
        double r28961 = 2.0;
        double r28962 = r28961 * r28949;
        double r28963 = r28960 / r28962;
        double r28964 = -1.0;
        double r28965 = r28950 / r28944;
        double r28966 = r28964 * r28965;
        double r28967 = r28946 ? r28963 : r28966;
        return r28967;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 6.724747266396374e-06

    1. Initial program 17.1

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

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

      \[\leadsto \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 \cdot a}\]
    5. Simplified16.3

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

    if 6.724747266396374e-06 < b

    1. Initial program 45.4

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

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

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

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

Reproduce

herbie shell --seed 2019326 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e+15) (< 1.11022e-16 b 9.0072e+15) (< 1.11022e-16 c 9.0072e+15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))