Average Error: 32.8 → 6.4
Time: 2.1m
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.1214768270116103 \cdot 10^{+154}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.199441090208904 \cdot 10^{-250}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 3.3389954009657566 \cdot 10^{+124}:\\ \;\;\;\;\left(-\frac{b_2}{a}\right) - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \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.1214768270116103 \cdot 10^{+154}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 1.199441090208904 \cdot 10^{-250}:\\
\;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\

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

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\

\end{array}
double f(double a, double b_2, double c) {
        double r18766242 = b_2;
        double r18766243 = -r18766242;
        double r18766244 = r18766242 * r18766242;
        double r18766245 = a;
        double r18766246 = c;
        double r18766247 = r18766245 * r18766246;
        double r18766248 = r18766244 - r18766247;
        double r18766249 = sqrt(r18766248);
        double r18766250 = r18766243 - r18766249;
        double r18766251 = r18766250 / r18766245;
        return r18766251;
}

double f(double a, double b_2, double c) {
        double r18766252 = b_2;
        double r18766253 = -1.1214768270116103e+154;
        bool r18766254 = r18766252 <= r18766253;
        double r18766255 = -0.5;
        double r18766256 = c;
        double r18766257 = r18766256 / r18766252;
        double r18766258 = r18766255 * r18766257;
        double r18766259 = 1.199441090208904e-250;
        bool r18766260 = r18766252 <= r18766259;
        double r18766261 = r18766252 * r18766252;
        double r18766262 = a;
        double r18766263 = r18766262 * r18766256;
        double r18766264 = r18766261 - r18766263;
        double r18766265 = sqrt(r18766264);
        double r18766266 = r18766265 - r18766252;
        double r18766267 = r18766256 / r18766266;
        double r18766268 = 3.3389954009657566e+124;
        bool r18766269 = r18766252 <= r18766268;
        double r18766270 = r18766252 / r18766262;
        double r18766271 = -r18766270;
        double r18766272 = r18766265 / r18766262;
        double r18766273 = r18766271 - r18766272;
        double r18766274 = -2.0;
        double r18766275 = r18766274 * r18766270;
        double r18766276 = r18766269 ? r18766273 : r18766275;
        double r18766277 = r18766260 ? r18766267 : r18766276;
        double r18766278 = r18766254 ? r18766258 : r18766277;
        return r18766278;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -1.1214768270116103e+154

    1. Initial program 62.9

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

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

    if -1.1214768270116103e+154 < b_2 < 1.199441090208904e-250

    1. Initial program 32.2

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

      \[\leadsto \frac{\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}}}}{a}\]
    4. Simplified16.2

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

      \[\leadsto \frac{\frac{a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity16.2

      \[\leadsto \frac{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied *-un-lft-identity16.2

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{1 \cdot a}\]
    9. Applied times-frac16.2

      \[\leadsto \color{blue}{\frac{1}{1} \cdot \frac{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}}\]
    10. Simplified16.2

      \[\leadsto \color{blue}{1} \cdot \frac{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}\]
    11. Simplified8.4

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

    if 1.199441090208904e-250 < b_2 < 3.3389954009657566e+124

    1. Initial program 7.8

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

      \[\leadsto \color{blue}{\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}\]

    if 3.3389954009657566e+124 < b_2

    1. Initial program 50.6

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

      \[\leadsto \frac{\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}}}}{a}\]
    4. Simplified62.0

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

      \[\leadsto \frac{\frac{a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Taylor expanded around 0 3.5

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.1214768270116103 \cdot 10^{+154}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.199441090208904 \cdot 10^{-250}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 3.3389954009657566 \cdot 10^{+124}:\\ \;\;\;\;\left(-\frac{b_2}{a}\right) - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019128 +o rules:numerics
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))