Average Error: 28.5 → 16.6
Time: 44.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 5152.464935290847279247827827930450439453:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}, b \cdot b - \left(4 \cdot a\right) \cdot c\right)}}{2}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{\frac{a \cdot c}{\sqrt{b}}}{\sqrt{b}} \cdot -2}{2}}{a}\\ \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 5152.464935290847279247827827930450439453:\\
\;\;\;\;\frac{\frac{\frac{\left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}, b \cdot b - \left(4 \cdot a\right) \cdot c\right)}}{2}}{a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r2457178 = b;
        double r2457179 = -r2457178;
        double r2457180 = r2457178 * r2457178;
        double r2457181 = 4.0;
        double r2457182 = a;
        double r2457183 = r2457181 * r2457182;
        double r2457184 = c;
        double r2457185 = r2457183 * r2457184;
        double r2457186 = r2457180 - r2457185;
        double r2457187 = sqrt(r2457186);
        double r2457188 = r2457179 + r2457187;
        double r2457189 = 2.0;
        double r2457190 = r2457189 * r2457182;
        double r2457191 = r2457188 / r2457190;
        return r2457191;
}

double f(double a, double b, double c) {
        double r2457192 = b;
        double r2457193 = 5152.464935290847;
        bool r2457194 = r2457192 <= r2457193;
        double r2457195 = r2457192 * r2457192;
        double r2457196 = 4.0;
        double r2457197 = a;
        double r2457198 = r2457196 * r2457197;
        double r2457199 = c;
        double r2457200 = r2457198 * r2457199;
        double r2457201 = r2457195 - r2457200;
        double r2457202 = sqrt(r2457201);
        double r2457203 = r2457201 * r2457202;
        double r2457204 = r2457195 * r2457192;
        double r2457205 = r2457203 - r2457204;
        double r2457206 = r2457192 + r2457202;
        double r2457207 = fma(r2457192, r2457206, r2457201);
        double r2457208 = r2457205 / r2457207;
        double r2457209 = 2.0;
        double r2457210 = r2457208 / r2457209;
        double r2457211 = r2457210 / r2457197;
        double r2457212 = r2457197 * r2457199;
        double r2457213 = sqrt(r2457192);
        double r2457214 = r2457212 / r2457213;
        double r2457215 = r2457214 / r2457213;
        double r2457216 = -2.0;
        double r2457217 = r2457215 * r2457216;
        double r2457218 = r2457217 / r2457209;
        double r2457219 = r2457218 / r2457197;
        double r2457220 = r2457194 ? r2457211 : r2457219;
        return r2457220;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 18.7

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

      \[\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.9

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

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

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

    if 5152.464935290847 < b

    1. Initial program 37.9

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

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

      \[\leadsto \frac{\frac{\color{blue}{-2 \cdot \frac{a \cdot c}{b}}}{2}}{a}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt15.2

      \[\leadsto \frac{\frac{-2 \cdot \frac{a \cdot c}{\color{blue}{\sqrt{b} \cdot \sqrt{b}}}}{2}}{a}\]
    6. Applied associate-/r*15.2

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

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

Reproduce

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