Average Error: 28.4 → 16.4
Time: 17.4s
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 835.2343651472419878700748085975646972656:\\ \;\;\;\;\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} - \left(b \cdot b\right) \cdot b}{\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)}}{a}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{a}{\frac{b}{c}}}{a} \cdot -2}{2}\\ \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 835.2343651472419878700748085975646972656:\\
\;\;\;\;\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} - \left(b \cdot b\right) \cdot b}{\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)}}{a}}{2}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1686097 = b;
        double r1686098 = -r1686097;
        double r1686099 = r1686097 * r1686097;
        double r1686100 = 4.0;
        double r1686101 = a;
        double r1686102 = r1686100 * r1686101;
        double r1686103 = c;
        double r1686104 = r1686102 * r1686103;
        double r1686105 = r1686099 - r1686104;
        double r1686106 = sqrt(r1686105);
        double r1686107 = r1686098 + r1686106;
        double r1686108 = 2.0;
        double r1686109 = r1686108 * r1686101;
        double r1686110 = r1686107 / r1686109;
        return r1686110;
}

double f(double a, double b, double c) {
        double r1686111 = b;
        double r1686112 = 835.234365147242;
        bool r1686113 = r1686111 <= r1686112;
        double r1686114 = r1686111 * r1686111;
        double r1686115 = c;
        double r1686116 = a;
        double r1686117 = r1686115 * r1686116;
        double r1686118 = 4.0;
        double r1686119 = r1686117 * r1686118;
        double r1686120 = r1686114 - r1686119;
        double r1686121 = sqrt(r1686120);
        double r1686122 = r1686120 * r1686121;
        double r1686123 = r1686114 * r1686111;
        double r1686124 = r1686122 - r1686123;
        double r1686125 = fma(r1686111, r1686121, r1686114);
        double r1686126 = r1686125 + r1686120;
        double r1686127 = r1686124 / r1686126;
        double r1686128 = r1686127 / r1686116;
        double r1686129 = 2.0;
        double r1686130 = r1686128 / r1686129;
        double r1686131 = r1686111 / r1686115;
        double r1686132 = r1686116 / r1686131;
        double r1686133 = r1686132 / r1686116;
        double r1686134 = -2.0;
        double r1686135 = r1686133 * r1686134;
        double r1686136 = r1686135 / r1686129;
        double r1686137 = r1686113 ? r1686130 : r1686136;
        return r1686137;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 16.7

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

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

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

      \[\leadsto \frac{\frac{\frac{\color{blue}{\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}}{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} \cdot \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} + \left(b \cdot b + \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} \cdot b\right)}}{a}}{2}\]
    6. Simplified16.1

      \[\leadsto \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}{\color{blue}{\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)}}}{a}}{2}\]

    if 835.234365147242 < b

    1. Initial program 36.1

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

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

      \[\leadsto \frac{\frac{\color{blue}{-2 \cdot \frac{a \cdot c}{b}}}{a}}{2}\]
    4. Using strategy rm
    5. Applied div-inv16.6

      \[\leadsto \frac{\color{blue}{\left(-2 \cdot \frac{a \cdot c}{b}\right) \cdot \frac{1}{a}}}{2}\]
    6. Using strategy rm
    7. Applied associate-*l*16.6

      \[\leadsto \frac{\color{blue}{-2 \cdot \left(\frac{a \cdot c}{b} \cdot \frac{1}{a}\right)}}{2}\]
    8. Simplified16.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 835.2343651472419878700748085975646972656:\\ \;\;\;\;\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} - \left(b \cdot b\right) \cdot b}{\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)}}{a}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{a}{\frac{b}{c}}}{a} \cdot -2}{2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019171 +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)))