Average Error: 43.8 → 11.0
Time: 13.0s
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 3.648715584836924622977316623462229472352 \cdot 10^{-4}:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(c, 4 \cdot a, b \cdot b\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 3.648715584836924622977316623462229472352 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(c, 4 \cdot a, b \cdot b\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 r31300 = b;
        double r31301 = -r31300;
        double r31302 = r31300 * r31300;
        double r31303 = 4.0;
        double r31304 = a;
        double r31305 = r31303 * r31304;
        double r31306 = c;
        double r31307 = r31305 * r31306;
        double r31308 = r31302 - r31307;
        double r31309 = sqrt(r31308);
        double r31310 = r31301 + r31309;
        double r31311 = 2.0;
        double r31312 = r31311 * r31304;
        double r31313 = r31310 / r31312;
        return r31313;
}

double f(double a, double b, double c) {
        double r31314 = b;
        double r31315 = 0.00036487155848369246;
        bool r31316 = r31314 <= r31315;
        double r31317 = r31314 * r31314;
        double r31318 = c;
        double r31319 = 4.0;
        double r31320 = a;
        double r31321 = r31319 * r31320;
        double r31322 = fma(r31318, r31321, r31317);
        double r31323 = r31317 - r31322;
        double r31324 = r31321 * r31318;
        double r31325 = r31317 - r31324;
        double r31326 = sqrt(r31325);
        double r31327 = r31326 + r31314;
        double r31328 = r31323 / r31327;
        double r31329 = 2.0;
        double r31330 = r31329 * r31320;
        double r31331 = r31328 / r31330;
        double r31332 = -1.0;
        double r31333 = r31318 / r31314;
        double r31334 = r31332 * r31333;
        double r31335 = r31316 ? r31331 : r31334;
        return r31335;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 19.0

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

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

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

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

    if 0.00036487155848369246 < b

    1. Initial program 45.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 3.648715584836924622977316623462229472352 \cdot 10^{-4}:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(c, 4 \cdot a, b \cdot b\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 2019212 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e15) (< 1.11022e-16 b 9.0072e15) (< 1.11022e-16 c 9.0072e15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))