Average Error: 34.4 → 6.7
Time: 19.5s
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 r804148 = b_2;
        double r804149 = -r804148;
        double r804150 = r804148 * r804148;
        double r804151 = a;
        double r804152 = c;
        double r804153 = r804151 * r804152;
        double r804154 = r804150 - r804153;
        double r804155 = sqrt(r804154);
        double r804156 = r804149 - r804155;
        double r804157 = r804156 / r804151;
        return r804157;
}

double f(double a, double b_2, double c) {
        double r804158 = b_2;
        double r804159 = -1.7633154797394035e+89;
        bool r804160 = r804158 <= r804159;
        double r804161 = -0.5;
        double r804162 = c;
        double r804163 = r804162 / r804158;
        double r804164 = r804161 * r804163;
        double r804165 = -1.0850002786366243e-297;
        bool r804166 = r804158 <= r804165;
        double r804167 = r804158 * r804158;
        double r804168 = a;
        double r804169 = r804168 * r804162;
        double r804170 = r804167 - r804169;
        double r804171 = sqrt(r804170);
        double r804172 = -r804158;
        double r804173 = r804171 + r804172;
        double r804174 = r804162 / r804173;
        double r804175 = 3.355858625783055e+101;
        bool r804176 = r804158 <= r804175;
        double r804177 = r804158 + r804171;
        double r804178 = r804177 / r804168;
        double r804179 = -r804178;
        double r804180 = 0.5;
        double r804181 = -2.0;
        double r804182 = r804158 * r804181;
        double r804183 = r804182 / r804168;
        double r804184 = fma(r804163, r804180, r804183);
        double r804185 = r804176 ? r804179 : r804184;
        double r804186 = r804166 ? r804174 : r804185;
        double r804187 = r804160 ? r804164 : r804186;
        return r804187;
}

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. Taylor expanded around inf 4.5

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{-2 \cdot b_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))