Average Error: 43.0 → 11.7
Time: 18.2s
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 1.143841598112384838194601800742677966127 \cdot 10^{-6}:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 4\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}, b \cdot b\right) + \left(b \cdot b - \left(c \cdot a\right) \cdot 4\right)}}{a}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \frac{c}{b}}{2}\\ \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 1.143841598112384838194601800742677966127 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 4\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}, b \cdot b\right) + \left(b \cdot b - \left(c \cdot a\right) \cdot 4\right)}}{a}}{2}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1510659 = b;
        double r1510660 = -r1510659;
        double r1510661 = r1510659 * r1510659;
        double r1510662 = 4.0;
        double r1510663 = a;
        double r1510664 = r1510662 * r1510663;
        double r1510665 = c;
        double r1510666 = r1510664 * r1510665;
        double r1510667 = r1510661 - r1510666;
        double r1510668 = sqrt(r1510667);
        double r1510669 = r1510660 + r1510668;
        double r1510670 = 2.0;
        double r1510671 = r1510670 * r1510663;
        double r1510672 = r1510669 / r1510671;
        return r1510672;
}

double f(double a, double b, double c) {
        double r1510673 = b;
        double r1510674 = 1.1438415981123848e-06;
        bool r1510675 = r1510673 <= r1510674;
        double r1510676 = r1510673 * r1510673;
        double r1510677 = c;
        double r1510678 = a;
        double r1510679 = r1510677 * r1510678;
        double r1510680 = 4.0;
        double r1510681 = r1510679 * r1510680;
        double r1510682 = r1510676 - r1510681;
        double r1510683 = sqrt(r1510682);
        double r1510684 = r1510682 * r1510683;
        double r1510685 = r1510676 * r1510673;
        double r1510686 = r1510684 - r1510685;
        double r1510687 = fma(r1510673, r1510683, r1510676);
        double r1510688 = r1510687 + r1510682;
        double r1510689 = r1510686 / r1510688;
        double r1510690 = r1510689 / r1510678;
        double r1510691 = 2.0;
        double r1510692 = r1510690 / r1510691;
        double r1510693 = -2.0;
        double r1510694 = r1510677 / r1510673;
        double r1510695 = r1510693 * r1510694;
        double r1510696 = r1510695 / r1510691;
        double r1510697 = r1510675 ? r1510692 : r1510696;
        return r1510697;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 1.1438415981123848e-06

    1. Initial program 14.4

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

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

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

      \[\leadsto \frac{\frac{\frac{\color{blue}{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}}{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} \cdot \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} + \left(b \cdot b + \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} \cdot b\right)}}{a}}{2}\]
    6. Simplified13.8

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

    if 1.1438415981123848e-06 < b

    1. Initial program 44.2

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

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

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

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

Reproduce

herbie shell --seed 2019171 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))