Average Error: 43.8 → 11.2
Time: 7.3s
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 9.210093240442333720544021424814218335086 \cdot 10^{-4}:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 4 \cdot \left(a \cdot c\right)\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 9.210093240442333720544021424814218335086 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 4 \cdot \left(a \cdot c\right)\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 r19752 = b;
        double r19753 = -r19752;
        double r19754 = r19752 * r19752;
        double r19755 = 4.0;
        double r19756 = a;
        double r19757 = r19755 * r19756;
        double r19758 = c;
        double r19759 = r19757 * r19758;
        double r19760 = r19754 - r19759;
        double r19761 = sqrt(r19760);
        double r19762 = r19753 + r19761;
        double r19763 = 2.0;
        double r19764 = r19763 * r19756;
        double r19765 = r19762 / r19764;
        return r19765;
}

double f(double a, double b, double c) {
        double r19766 = b;
        double r19767 = 0.0009210093240442334;
        bool r19768 = r19766 <= r19767;
        double r19769 = r19766 * r19766;
        double r19770 = 4.0;
        double r19771 = a;
        double r19772 = c;
        double r19773 = r19771 * r19772;
        double r19774 = r19770 * r19773;
        double r19775 = fma(r19766, r19766, r19774);
        double r19776 = r19769 - r19775;
        double r19777 = r19770 * r19771;
        double r19778 = r19777 * r19772;
        double r19779 = r19769 - r19778;
        double r19780 = sqrt(r19779);
        double r19781 = r19780 + r19766;
        double r19782 = r19776 / r19781;
        double r19783 = 2.0;
        double r19784 = r19783 * r19771;
        double r19785 = r19782 / r19784;
        double r19786 = -1.0;
        double r19787 = r19772 / r19766;
        double r19788 = r19786 * r19787;
        double r19789 = r19768 ? r19785 : r19788;
        return r19789;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 20.3

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

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

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

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

    if 0.0009210093240442334 < b

    1. Initial program 45.8

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

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

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

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