Average Error: 28.6 → 14.8
Time: 11.1s
Precision: 64
\[1.0536712127723509 \cdot 10^{-08} \lt a \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt b \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt c \lt 94906265.62425156\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -8.652160590586469 \cdot 10^{-06}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right) \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)} - b \cdot \left(b \cdot b\right)}{b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)} + \mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-\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}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -8.652160590586469 \cdot 10^{-06}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right) \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)} - b \cdot \left(b \cdot b\right)}{b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)} + \mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)\right)}}{2 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1077576 = b;
        double r1077577 = -r1077576;
        double r1077578 = r1077576 * r1077576;
        double r1077579 = 4.0;
        double r1077580 = a;
        double r1077581 = r1077579 * r1077580;
        double r1077582 = c;
        double r1077583 = r1077581 * r1077582;
        double r1077584 = r1077578 - r1077583;
        double r1077585 = sqrt(r1077584);
        double r1077586 = r1077577 + r1077585;
        double r1077587 = 2.0;
        double r1077588 = r1077587 * r1077580;
        double r1077589 = r1077586 / r1077588;
        return r1077589;
}

double f(double a, double b, double c) {
        double r1077590 = b;
        double r1077591 = r1077590 * r1077590;
        double r1077592 = 4.0;
        double r1077593 = a;
        double r1077594 = r1077592 * r1077593;
        double r1077595 = c;
        double r1077596 = r1077594 * r1077595;
        double r1077597 = r1077591 - r1077596;
        double r1077598 = sqrt(r1077597);
        double r1077599 = -r1077590;
        double r1077600 = r1077598 + r1077599;
        double r1077601 = 2.0;
        double r1077602 = r1077601 * r1077593;
        double r1077603 = r1077600 / r1077602;
        double r1077604 = -8.652160590586469e-06;
        bool r1077605 = r1077603 <= r1077604;
        double r1077606 = r1077595 * r1077593;
        double r1077607 = -4.0;
        double r1077608 = r1077606 * r1077607;
        double r1077609 = fma(r1077590, r1077590, r1077608);
        double r1077610 = sqrt(r1077609);
        double r1077611 = r1077609 * r1077610;
        double r1077612 = r1077590 * r1077591;
        double r1077613 = r1077611 - r1077612;
        double r1077614 = r1077590 * r1077610;
        double r1077615 = fma(r1077590, r1077590, r1077609);
        double r1077616 = r1077614 + r1077615;
        double r1077617 = r1077613 / r1077616;
        double r1077618 = r1077617 / r1077602;
        double r1077619 = r1077595 / r1077590;
        double r1077620 = -r1077619;
        double r1077621 = r1077605 ? r1077618 : r1077620;
        return r1077621;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) < -8.652160590586469e-06

    1. Initial program 17.2

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

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

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

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

    if -8.652160590586469e-06 < (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))

    1. Initial program 40.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Taylor expanded around inf 12.9

      \[\leadsto \frac{\color{blue}{-2 \cdot \frac{a \cdot c}{b}}}{2 \cdot a}\]
    3. Taylor expanded around 0 12.8

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    4. Simplified12.8

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

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

Reproduce

herbie shell --seed 2019163 +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 a) c)))) (* 2 a)))