Average Error: 34.4 → 6.7
Time: 19.6s
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 r3264267 = b_2;
        double r3264268 = -r3264267;
        double r3264269 = r3264267 * r3264267;
        double r3264270 = a;
        double r3264271 = c;
        double r3264272 = r3264270 * r3264271;
        double r3264273 = r3264269 - r3264272;
        double r3264274 = sqrt(r3264273);
        double r3264275 = r3264268 - r3264274;
        double r3264276 = r3264275 / r3264270;
        return r3264276;
}

double f(double a, double b_2, double c) {
        double r3264277 = b_2;
        double r3264278 = -1.7633154797394035e+89;
        bool r3264279 = r3264277 <= r3264278;
        double r3264280 = -0.5;
        double r3264281 = c;
        double r3264282 = r3264281 / r3264277;
        double r3264283 = r3264280 * r3264282;
        double r3264284 = -1.0850002786366243e-297;
        bool r3264285 = r3264277 <= r3264284;
        double r3264286 = r3264277 * r3264277;
        double r3264287 = a;
        double r3264288 = r3264287 * r3264281;
        double r3264289 = r3264286 - r3264288;
        double r3264290 = sqrt(r3264289);
        double r3264291 = -r3264277;
        double r3264292 = r3264290 + r3264291;
        double r3264293 = r3264281 / r3264292;
        double r3264294 = 3.355858625783055e+101;
        bool r3264295 = r3264277 <= r3264294;
        double r3264296 = r3264277 + r3264290;
        double r3264297 = r3264296 / r3264287;
        double r3264298 = -r3264297;
        double r3264299 = 0.5;
        double r3264300 = -2.0;
        double r3264301 = r3264277 * r3264300;
        double r3264302 = r3264301 / r3264287;
        double r3264303 = fma(r3264282, r3264299, r3264302);
        double r3264304 = r3264295 ? r3264298 : r3264303;
        double r3264305 = r3264285 ? r3264293 : r3264304;
        double r3264306 = r3264279 ? r3264283 : r3264305;
        return r3264306;
}

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 "NMSE problem 3.2.1"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))