Average Error: 34.4 → 9.6
Time: 22.8s
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 -2726755826697749371122441483452416:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.220863356651405551526191855483353869404 \cdot 10^{-93}:\\ \;\;\;\;\left(c \cdot a\right) \cdot \frac{1}{a \cdot \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)}\\ \mathbf{elif}\;b_2 \le 5.878879592304488221733339437168429062361 \cdot 10^{101}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-2, \frac{b_2}{a}, \frac{c}{b_2} \cdot \frac{1}{2}\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 -2726755826697749371122441483452416:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -1.220863356651405551526191855483353869404 \cdot 10^{-93}:\\
\;\;\;\;\left(c \cdot a\right) \cdot \frac{1}{a \cdot \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r3008344 = b_2;
        double r3008345 = -r3008344;
        double r3008346 = r3008344 * r3008344;
        double r3008347 = a;
        double r3008348 = c;
        double r3008349 = r3008347 * r3008348;
        double r3008350 = r3008346 - r3008349;
        double r3008351 = sqrt(r3008350);
        double r3008352 = r3008345 - r3008351;
        double r3008353 = r3008352 / r3008347;
        return r3008353;
}

double f(double a, double b_2, double c) {
        double r3008354 = b_2;
        double r3008355 = -2.7267558266977494e+33;
        bool r3008356 = r3008354 <= r3008355;
        double r3008357 = -0.5;
        double r3008358 = c;
        double r3008359 = r3008358 / r3008354;
        double r3008360 = r3008357 * r3008359;
        double r3008361 = -1.2208633566514056e-93;
        bool r3008362 = r3008354 <= r3008361;
        double r3008363 = a;
        double r3008364 = r3008358 * r3008363;
        double r3008365 = 1.0;
        double r3008366 = r3008354 * r3008354;
        double r3008367 = r3008366 - r3008364;
        double r3008368 = sqrt(r3008367);
        double r3008369 = r3008368 - r3008354;
        double r3008370 = r3008363 * r3008369;
        double r3008371 = r3008365 / r3008370;
        double r3008372 = r3008364 * r3008371;
        double r3008373 = 5.878879592304488e+101;
        bool r3008374 = r3008354 <= r3008373;
        double r3008375 = -r3008354;
        double r3008376 = r3008375 - r3008368;
        double r3008377 = r3008376 / r3008363;
        double r3008378 = -2.0;
        double r3008379 = r3008354 / r3008363;
        double r3008380 = 0.5;
        double r3008381 = r3008359 * r3008380;
        double r3008382 = fma(r3008378, r3008379, r3008381);
        double r3008383 = r3008374 ? r3008377 : r3008382;
        double r3008384 = r3008362 ? r3008372 : r3008383;
        double r3008385 = r3008356 ? r3008360 : r3008384;
        return r3008385;
}

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.7267558266977494e+33

    1. Initial program 56.5

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

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

    if -2.7267558266977494e+33 < b_2 < -1.2208633566514056e-93

    1. Initial program 41.1

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

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

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

      \[\leadsto \frac{\frac{0 + 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.7

      \[\leadsto \frac{\frac{0 + a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied div-inv16.8

      \[\leadsto \frac{\color{blue}{\left(0 + a \cdot c\right) \cdot \frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{1 \cdot a}\]
    9. Applied times-frac20.3

      \[\leadsto \color{blue}{\frac{0 + a \cdot c}{1} \cdot \frac{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}}\]
    10. Simplified20.3

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

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

    if -1.2208633566514056e-93 < b_2 < 5.878879592304488e+101

    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.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-inv12.5

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

    if 5.878879592304488e+101 < b_2

    1. Initial program 46.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2726755826697749371122441483452416:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.220863356651405551526191855483353869404 \cdot 10^{-93}:\\ \;\;\;\;\left(c \cdot a\right) \cdot \frac{1}{a \cdot \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)}\\ \mathbf{elif}\;b_2 \le 5.878879592304488221733339437168429062361 \cdot 10^{101}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-2, \frac{b_2}{a}, \frac{c}{b_2} \cdot \frac{1}{2}\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))