Average Error: 34.1 → 8.9
Time: 21.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 -2.122942397323538653087473965252285768999 \cdot 10^{137}:\\ \;\;\;\;\frac{\frac{-1}{2} \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \le -3.408354642852288642375909774932644593067 \cdot 10^{-45}:\\ \;\;\;\;\frac{\frac{a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)}{a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le -5.546621280225112292650318866994441138678 \cdot 10^{-56}:\\ \;\;\;\;\frac{\frac{-1}{2} \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.823335453796603439248590818149160856749 \cdot 10^{131}:\\ \;\;\;\;\frac{-\left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, -2 \cdot \frac{b_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 -2.122942397323538653087473965252285768999 \cdot 10^{137}:\\
\;\;\;\;\frac{\frac{-1}{2} \cdot c}{b_2}\\

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

\mathbf{elif}\;b_2 \le -5.546621280225112292650318866994441138678 \cdot 10^{-56}:\\
\;\;\;\;\frac{\frac{-1}{2} \cdot c}{b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r25282 = b_2;
        double r25283 = -r25282;
        double r25284 = r25282 * r25282;
        double r25285 = a;
        double r25286 = c;
        double r25287 = r25285 * r25286;
        double r25288 = r25284 - r25287;
        double r25289 = sqrt(r25288);
        double r25290 = r25283 - r25289;
        double r25291 = r25290 / r25285;
        return r25291;
}

double f(double a, double b_2, double c) {
        double r25292 = b_2;
        double r25293 = -2.1229423973235387e+137;
        bool r25294 = r25292 <= r25293;
        double r25295 = -0.5;
        double r25296 = c;
        double r25297 = r25295 * r25296;
        double r25298 = r25297 / r25292;
        double r25299 = -3.4083546428522886e-45;
        bool r25300 = r25292 <= r25299;
        double r25301 = a;
        double r25302 = r25301 * r25296;
        double r25303 = r25292 * r25292;
        double r25304 = r25303 - r25303;
        double r25305 = r25302 + r25304;
        double r25306 = r25305 / r25301;
        double r25307 = r25303 - r25302;
        double r25308 = sqrt(r25307);
        double r25309 = -r25292;
        double r25310 = r25308 + r25309;
        double r25311 = r25306 / r25310;
        double r25312 = -5.546621280225112e-56;
        bool r25313 = r25292 <= r25312;
        double r25314 = 2.8233354537966034e+131;
        bool r25315 = r25292 <= r25314;
        double r25316 = r25308 + r25292;
        double r25317 = -r25316;
        double r25318 = r25317 / r25301;
        double r25319 = 0.5;
        double r25320 = r25296 / r25292;
        double r25321 = -2.0;
        double r25322 = r25292 / r25301;
        double r25323 = r25321 * r25322;
        double r25324 = fma(r25319, r25320, r25323);
        double r25325 = r25315 ? r25318 : r25324;
        double r25326 = r25313 ? r25298 : r25325;
        double r25327 = r25300 ? r25311 : r25326;
        double r25328 = r25294 ? r25298 : r25327;
        return r25328;
}

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 < -2.1229423973235387e+137 or -3.4083546428522886e-45 < b_2 < -5.546621280225112e-56

    1. Initial program 61.6

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

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

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

    if -2.1229423973235387e+137 < b_2 < -3.4083546428522886e-45

    1. Initial program 45.1

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied div-inv45.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--45.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/45.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. Simplified11.6

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

    if -5.546621280225112e-56 < b_2 < 2.8233354537966034e+131

    1. Initial program 12.5

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

      \[\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-lft-identity12.7

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

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

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

    if 2.8233354537966034e+131 < b_2

    1. Initial program 56.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.122942397323538653087473965252285768999 \cdot 10^{137}:\\ \;\;\;\;\frac{\frac{-1}{2} \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \le -3.408354642852288642375909774932644593067 \cdot 10^{-45}:\\ \;\;\;\;\frac{\frac{a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)}{a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le -5.546621280225112292650318866994441138678 \cdot 10^{-56}:\\ \;\;\;\;\frac{\frac{-1}{2} \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.823335453796603439248590818149160856749 \cdot 10^{131}:\\ \;\;\;\;\frac{-\left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019174 +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))