Average Error: 34.4 → 6.7
Time: 18.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{\left(-b_2\right) - \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{\left(-b_2\right) - \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 r3297283 = b_2;
        double r3297284 = -r3297283;
        double r3297285 = r3297283 * r3297283;
        double r3297286 = a;
        double r3297287 = c;
        double r3297288 = r3297286 * r3297287;
        double r3297289 = r3297285 - r3297288;
        double r3297290 = sqrt(r3297289);
        double r3297291 = r3297284 - r3297290;
        double r3297292 = r3297291 / r3297286;
        return r3297292;
}

double f(double a, double b_2, double c) {
        double r3297293 = b_2;
        double r3297294 = -1.7633154797394035e+89;
        bool r3297295 = r3297293 <= r3297294;
        double r3297296 = -0.5;
        double r3297297 = c;
        double r3297298 = r3297297 / r3297293;
        double r3297299 = r3297296 * r3297298;
        double r3297300 = -1.0850002786366243e-297;
        bool r3297301 = r3297293 <= r3297300;
        double r3297302 = r3297293 * r3297293;
        double r3297303 = a;
        double r3297304 = r3297303 * r3297297;
        double r3297305 = r3297302 - r3297304;
        double r3297306 = sqrt(r3297305);
        double r3297307 = -r3297293;
        double r3297308 = r3297306 + r3297307;
        double r3297309 = r3297297 / r3297308;
        double r3297310 = 3.355858625783055e+101;
        bool r3297311 = r3297293 <= r3297310;
        double r3297312 = r3297307 - r3297306;
        double r3297313 = r3297312 / r3297303;
        double r3297314 = 0.5;
        double r3297315 = -2.0;
        double r3297316 = r3297293 * r3297315;
        double r3297317 = r3297316 / r3297303;
        double r3297318 = fma(r3297298, r3297314, r3297317);
        double r3297319 = r3297311 ? r3297313 : r3297318;
        double r3297320 = r3297301 ? r3297309 : r3297319;
        double r3297321 = r3297295 ? r3297299 : r3297320;
        return r3297321;
}

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 un-div-inv9.5

      \[\leadsto \color{blue}{\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{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{\left(-b_2\right) - \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))