Average Error: 34.4 → 6.7
Time: 20.4s
Precision: 64
\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -1.763315479739403460017265344144602342789 \cdot 10^{89}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.085000278636624341855070450537604684134 \cdot 10^{-297}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le 3.355858625783055094237525774982320834143 \cdot 10^{101}:\\ \;\;\;\;-\frac{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2 \cdot -2}{a}\right)\\ \end{array}\]
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \le -1.763315479739403460017265344144602342789 \cdot 10^{89}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -1.085000278636624341855070450537604684134 \cdot 10^{-297}:\\
\;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}\\

\mathbf{elif}\;b_2 \le 3.355858625783055094237525774982320834143 \cdot 10^{101}:\\
\;\;\;\;-\frac{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2 \cdot -2}{a}\right)\\

\end{array}
double f(double a, double b_2, double c) {
        double r804033 = b_2;
        double r804034 = -r804033;
        double r804035 = r804033 * r804033;
        double r804036 = a;
        double r804037 = c;
        double r804038 = r804036 * r804037;
        double r804039 = r804035 - r804038;
        double r804040 = sqrt(r804039);
        double r804041 = r804034 - r804040;
        double r804042 = r804041 / r804036;
        return r804042;
}

double f(double a, double b_2, double c) {
        double r804043 = b_2;
        double r804044 = -1.7633154797394035e+89;
        bool r804045 = r804043 <= r804044;
        double r804046 = -0.5;
        double r804047 = c;
        double r804048 = r804047 / r804043;
        double r804049 = r804046 * r804048;
        double r804050 = -1.0850002786366243e-297;
        bool r804051 = r804043 <= r804050;
        double r804052 = r804043 * r804043;
        double r804053 = a;
        double r804054 = r804053 * r804047;
        double r804055 = r804052 - r804054;
        double r804056 = sqrt(r804055);
        double r804057 = -r804043;
        double r804058 = r804056 + r804057;
        double r804059 = r804047 / r804058;
        double r804060 = 3.355858625783055e+101;
        bool r804061 = r804043 <= r804060;
        double r804062 = r804043 + r804056;
        double r804063 = r804062 / r804053;
        double r804064 = -r804063;
        double r804065 = 0.5;
        double r804066 = -2.0;
        double r804067 = r804043 * r804066;
        double r804068 = r804067 / r804053;
        double r804069 = fma(r804048, r804065, r804068);
        double r804070 = r804061 ? r804064 : r804069;
        double r804071 = r804051 ? r804059 : r804070;
        double r804072 = r804045 ? r804049 : r804071;
        return r804072;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -1.7633154797394035e+89

    1. Initial program 59.1

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around -inf 2.7

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b_2}}\]

    if -1.7633154797394035e+89 < b_2 < -1.0850002786366243e-297

    1. Initial program 32.0

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied div-inv32.1

      \[\leadsto \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
    4. Using strategy rm
    5. Applied flip--32.1

      \[\leadsto \color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}} \cdot \frac{1}{a}\]
    6. Applied associate-*l/32.1

      \[\leadsto \color{blue}{\frac{\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    7. Simplified15.7

      \[\leadsto \frac{\color{blue}{\frac{\left(b_2 \cdot b_2 - b_2 \cdot b_2\right) + c \cdot a}{a}}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\]
    8. Taylor expanded around 0 8.3

      \[\leadsto \frac{\color{blue}{c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\]

    if -1.0850002786366243e-297 < b_2 < 3.355858625783055e+101

    1. Initial program 9.5

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied div-inv9.6

      \[\leadsto \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
    4. Using strategy rm
    5. Applied associate-*r/9.5

      \[\leadsto \color{blue}{\frac{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot 1}{a}}\]
    6. Simplified9.5

      \[\leadsto \frac{\color{blue}{-\left(b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}\right)}}{a}\]

    if 3.355858625783055e+101 < b_2

    1. Initial program 46.6

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied div-inv46.7

      \[\leadsto \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
    4. Taylor expanded around inf 4.5

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]
    5. Simplified4.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2 \cdot -2}{a}\right)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.763315479739403460017265344144602342789 \cdot 10^{89}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.085000278636624341855070450537604684134 \cdot 10^{-297}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le 3.355858625783055094237525774982320834143 \cdot 10^{101}:\\ \;\;\;\;-\frac{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2 \cdot -2}{a}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019172 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))