Average Error: 34.5 → 6.9
Time: 9.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.52829345465496796 \cdot 10^{148}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -7.5932715112131794 \cdot 10^{-252}:\\ \;\;\;\;\frac{\frac{1}{\frac{1}{c}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 9.9656763960867421 \cdot 10^{45}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 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.52829345465496796 \cdot 10^{148}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -7.5932715112131794 \cdot 10^{-252}:\\
\;\;\;\;\frac{\frac{1}{\frac{1}{c}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r72984 = b_2;
        double r72985 = -r72984;
        double r72986 = r72984 * r72984;
        double r72987 = a;
        double r72988 = c;
        double r72989 = r72987 * r72988;
        double r72990 = r72986 - r72989;
        double r72991 = sqrt(r72990);
        double r72992 = r72985 - r72991;
        double r72993 = r72992 / r72987;
        return r72993;
}

double f(double a, double b_2, double c) {
        double r72994 = b_2;
        double r72995 = -1.528293454654968e+148;
        bool r72996 = r72994 <= r72995;
        double r72997 = -0.5;
        double r72998 = c;
        double r72999 = r72998 / r72994;
        double r73000 = r72997 * r72999;
        double r73001 = -7.593271511213179e-252;
        bool r73002 = r72994 <= r73001;
        double r73003 = 1.0;
        double r73004 = r73003 / r72998;
        double r73005 = r73003 / r73004;
        double r73006 = r72994 * r72994;
        double r73007 = a;
        double r73008 = r73007 * r72998;
        double r73009 = r73006 - r73008;
        double r73010 = sqrt(r73009);
        double r73011 = r73010 - r72994;
        double r73012 = r73005 / r73011;
        double r73013 = 9.965676396086742e+45;
        bool r73014 = r72994 <= r73013;
        double r73015 = -r72994;
        double r73016 = r73015 / r73007;
        double r73017 = r73010 / r73007;
        double r73018 = r73016 - r73017;
        double r73019 = 0.5;
        double r73020 = r73019 * r72999;
        double r73021 = 2.0;
        double r73022 = r72994 / r73007;
        double r73023 = r73021 * r73022;
        double r73024 = r73020 - r73023;
        double r73025 = r73014 ? r73018 : r73024;
        double r73026 = r73002 ? r73012 : r73025;
        double r73027 = r72996 ? r73000 : r73026;
        return r73027;
}

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.528293454654968e+148

    1. Initial program 63.4

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

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

    if -1.528293454654968e+148 < b_2 < -7.593271511213179e-252

    1. Initial program 36.5

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

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

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

      \[\leadsto \frac{\frac{a \cdot c + 0}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied div-inv16.1

      \[\leadsto \color{blue}{\frac{a \cdot c + 0}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2} \cdot \frac{1}{a}}\]
    8. Using strategy rm
    9. Applied associate-*l/14.3

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

      \[\leadsto \frac{\color{blue}{\frac{a \cdot c}{a}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\]
    11. Using strategy rm
    12. Applied clear-num14.3

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

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

    if -7.593271511213179e-252 < b_2 < 9.965676396086742e+45

    1. Initial program 10.6

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

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

    if 9.965676396086742e+45 < b_2

    1. Initial program 36.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.52829345465496796 \cdot 10^{148}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -7.5932715112131794 \cdot 10^{-252}:\\ \;\;\;\;\frac{\frac{1}{\frac{1}{c}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 9.9656763960867421 \cdot 10^{45}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020046 
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))