Average Error: 34.0 → 10.6
Time: 19.9s
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.76351621427461392823177571966952670558 \cdot 10^{80}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -4.040808270363289407530177841363912501793 \cdot 10^{-132}:\\ \;\;\;\;\frac{c \cdot a}{a \cdot \left(\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2\right)}\\ \mathbf{elif}\;b_2 \le 2098867031.934578418731689453125:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot 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 -1.76351621427461392823177571966952670558 \cdot 10^{80}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -4.040808270363289407530177841363912501793 \cdot 10^{-132}:\\
\;\;\;\;\frac{c \cdot a}{a \cdot \left(\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2\right)}\\

\mathbf{elif}\;b_2 \le 2098867031.934578418731689453125:\\
\;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot 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 r79328 = b_2;
        double r79329 = -r79328;
        double r79330 = r79328 * r79328;
        double r79331 = a;
        double r79332 = c;
        double r79333 = r79331 * r79332;
        double r79334 = r79330 - r79333;
        double r79335 = sqrt(r79334);
        double r79336 = r79329 - r79335;
        double r79337 = r79336 / r79331;
        return r79337;
}

double f(double a, double b_2, double c) {
        double r79338 = b_2;
        double r79339 = -1.763516214274614e+80;
        bool r79340 = r79338 <= r79339;
        double r79341 = -0.5;
        double r79342 = c;
        double r79343 = r79342 / r79338;
        double r79344 = r79341 * r79343;
        double r79345 = -4.0408082703632894e-132;
        bool r79346 = r79338 <= r79345;
        double r79347 = a;
        double r79348 = r79342 * r79347;
        double r79349 = -r79342;
        double r79350 = r79338 * r79338;
        double r79351 = fma(r79349, r79347, r79350);
        double r79352 = sqrt(r79351);
        double r79353 = r79352 - r79338;
        double r79354 = r79347 * r79353;
        double r79355 = r79348 / r79354;
        double r79356 = 2098867031.9345784;
        bool r79357 = r79338 <= r79356;
        double r79358 = 1.0;
        double r79359 = -r79338;
        double r79360 = r79350 - r79348;
        double r79361 = sqrt(r79360);
        double r79362 = r79359 - r79361;
        double r79363 = r79347 / r79362;
        double r79364 = r79358 / r79363;
        double r79365 = 0.5;
        double r79366 = -2.0;
        double r79367 = r79338 / r79347;
        double r79368 = r79366 * r79367;
        double r79369 = fma(r79365, r79343, r79368);
        double r79370 = r79357 ? r79364 : r79369;
        double r79371 = r79346 ? r79355 : r79370;
        double r79372 = r79340 ? r79344 : r79371;
        return r79372;
}

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.763516214274614e+80

    1. Initial program 58.0

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

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

    if -1.763516214274614e+80 < b_2 < -4.0408082703632894e-132

    1. Initial program 39.7

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

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

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

      \[\leadsto \frac{\frac{0 + c \cdot a}{\color{blue}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied sub-neg15.3

      \[\leadsto \frac{\frac{0 + c \cdot a}{\color{blue}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} + \left(-b_2\right)}}}{a}\]
    8. Using strategy rm
    9. Applied div-inv15.3

      \[\leadsto \frac{\color{blue}{\left(0 + c \cdot a\right) \cdot \frac{1}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} + \left(-b_2\right)}}}{a}\]
    10. Applied associate-/l*18.6

      \[\leadsto \color{blue}{\frac{0 + c \cdot a}{\frac{a}{\frac{1}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} + \left(-b_2\right)}}}}\]
    11. Simplified18.6

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

    if -4.0408082703632894e-132 < b_2 < 2098867031.9345784

    1. Initial program 14.3

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

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

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

    if 2098867031.9345784 < b_2

    1. Initial program 32.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.76351621427461392823177571966952670558 \cdot 10^{80}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -4.040808270363289407530177841363912501793 \cdot 10^{-132}:\\ \;\;\;\;\frac{c \cdot a}{a \cdot \left(\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2\right)}\\ \mathbf{elif}\;b_2 \le 2098867031.934578418731689453125:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot 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 2019209 +o rules:numerics
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))