Average Error: 28.5 → 17.0
Time: 21.2s
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 53.72772989939689125549193704500794410706:\\ \;\;\;\;\frac{\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) - \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{elif}\;b \le 250.8081548127311179996468126773834228516:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le 2125.07914601017046152264811098575592041:\\ \;\;\;\;\frac{\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) - \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}:\\ \;\;\;\;-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 53.72772989939689125549193704500794410706:\\
\;\;\;\;\frac{\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) - \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{elif}\;b \le 250.8081548127311179996468126773834228516:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\

\mathbf{elif}\;b \le 2125.07914601017046152264811098575592041:\\
\;\;\;\;\frac{\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) - \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}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r2686701 = b;
        double r2686702 = -r2686701;
        double r2686703 = r2686701 * r2686701;
        double r2686704 = 4.0;
        double r2686705 = a;
        double r2686706 = r2686704 * r2686705;
        double r2686707 = c;
        double r2686708 = r2686706 * r2686707;
        double r2686709 = r2686703 - r2686708;
        double r2686710 = sqrt(r2686709);
        double r2686711 = r2686702 + r2686710;
        double r2686712 = 2.0;
        double r2686713 = r2686712 * r2686705;
        double r2686714 = r2686711 / r2686713;
        return r2686714;
}

double f(double a, double b, double c) {
        double r2686715 = b;
        double r2686716 = 53.72772989939689;
        bool r2686717 = r2686715 <= r2686716;
        double r2686718 = r2686715 * r2686715;
        double r2686719 = 4.0;
        double r2686720 = a;
        double r2686721 = r2686719 * r2686720;
        double r2686722 = c;
        double r2686723 = r2686721 * r2686722;
        double r2686724 = r2686718 - r2686723;
        double r2686725 = sqrt(r2686724);
        double r2686726 = r2686725 * r2686724;
        double r2686727 = r2686718 * r2686715;
        double r2686728 = r2686726 - r2686727;
        double r2686729 = r2686715 + r2686725;
        double r2686730 = fma(r2686715, r2686729, r2686724);
        double r2686731 = r2686728 / r2686730;
        double r2686732 = 2.0;
        double r2686733 = r2686731 / r2686732;
        double r2686734 = r2686733 / r2686720;
        double r2686735 = 250.80815481273112;
        bool r2686736 = r2686715 <= r2686735;
        double r2686737 = -1.0;
        double r2686738 = r2686722 / r2686715;
        double r2686739 = r2686737 * r2686738;
        double r2686740 = 2125.0791460101705;
        bool r2686741 = r2686715 <= r2686740;
        double r2686742 = r2686741 ? r2686734 : r2686739;
        double r2686743 = r2686736 ? r2686739 : r2686742;
        double r2686744 = r2686717 ? r2686734 : r2686743;
        return r2686744;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 53.72772989939689 or 250.80815481273112 < b < 2125.0791460101705

    1. Initial program 17.3

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

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

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

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

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

    if 53.72772989939689 < b < 250.80815481273112 or 2125.0791460101705 < b

    1. Initial program 35.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 53.72772989939689125549193704500794410706:\\ \;\;\;\;\frac{\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) - \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{elif}\;b \le 250.8081548127311179996468126773834228516:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le 2125.07914601017046152264811098575592041:\\ \;\;\;\;\frac{\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) - \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}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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