Average Error: 29.0 → 16.3
Time: 12.7s
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}\;b \le 759.6594316796017:\\ \;\;\;\;\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}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)}, b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)}, b \cdot b\right)}}{a \cdot 2}\\ \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}\;b \le 759.6594316796017:\\
\;\;\;\;\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}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)}, b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)}, b \cdot b\right)}}{a \cdot 2}\\

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

\end{array}
double f(double a, double b, double c) {
        double r741685 = b;
        double r741686 = -r741685;
        double r741687 = r741685 * r741685;
        double r741688 = 4.0;
        double r741689 = a;
        double r741690 = r741688 * r741689;
        double r741691 = c;
        double r741692 = r741690 * r741691;
        double r741693 = r741687 - r741692;
        double r741694 = sqrt(r741693);
        double r741695 = r741686 + r741694;
        double r741696 = 2.0;
        double r741697 = r741696 * r741689;
        double r741698 = r741695 / r741697;
        return r741698;
}

double f(double a, double b, double c) {
        double r741699 = b;
        double r741700 = 759.6594316796017;
        bool r741701 = r741699 <= r741700;
        double r741702 = c;
        double r741703 = a;
        double r741704 = r741702 * r741703;
        double r741705 = -4.0;
        double r741706 = r741704 * r741705;
        double r741707 = fma(r741699, r741699, r741706);
        double r741708 = sqrt(r741707);
        double r741709 = r741708 * r741707;
        double r741710 = r741699 * r741699;
        double r741711 = r741710 * r741699;
        double r741712 = r741709 - r741711;
        double r741713 = r741699 + r741708;
        double r741714 = fma(r741708, r741713, r741710);
        double r741715 = r741712 / r741714;
        double r741716 = 2.0;
        double r741717 = r741703 * r741716;
        double r741718 = r741715 / r741717;
        double r741719 = -r741702;
        double r741720 = r741719 / r741699;
        double r741721 = r741701 ? r741718 : r741720;
        return r741721;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 17.3

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

      \[\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(\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)}, \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)} + b, b \cdot b\right)}}}{2 \cdot a}\]

    if 759.6594316796017 < b

    1. Initial program 36.5

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    3. Simplified16.1

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

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

Reproduce

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