Average Error: 34.3 → 9.2
Time: 4.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.5039764088253741 \cdot 10^{60}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.04130397373245191 \cdot 10^{-77}:\\ \;\;\;\;\frac{\frac{a \cdot c + 0}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}\\ \mathbf{elif}\;b_2 \le 3.0980273873827559 \cdot 10^{93}:\\ \;\;\;\;\frac{\left(-b_2\right) - \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 -2.5039764088253741 \cdot 10^{60}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -1.04130397373245191 \cdot 10^{-77}:\\
\;\;\;\;\frac{\frac{a \cdot c + 0}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}\\

\mathbf{elif}\;b_2 \le 3.0980273873827559 \cdot 10^{93}:\\
\;\;\;\;\frac{\left(-b_2\right) - \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 r90202 = b_2;
        double r90203 = -r90202;
        double r90204 = r90202 * r90202;
        double r90205 = a;
        double r90206 = c;
        double r90207 = r90205 * r90206;
        double r90208 = r90204 - r90207;
        double r90209 = sqrt(r90208);
        double r90210 = r90203 - r90209;
        double r90211 = r90210 / r90205;
        return r90211;
}

double f(double a, double b_2, double c) {
        double r90212 = b_2;
        double r90213 = -2.503976408825374e+60;
        bool r90214 = r90212 <= r90213;
        double r90215 = -0.5;
        double r90216 = c;
        double r90217 = r90216 / r90212;
        double r90218 = r90215 * r90217;
        double r90219 = -1.041303973732452e-77;
        bool r90220 = r90212 <= r90219;
        double r90221 = a;
        double r90222 = r90221 * r90216;
        double r90223 = 0.0;
        double r90224 = r90222 + r90223;
        double r90225 = r90212 * r90212;
        double r90226 = r90225 - r90222;
        double r90227 = sqrt(r90226);
        double r90228 = r90227 - r90212;
        double r90229 = r90224 / r90228;
        double r90230 = r90229 / r90221;
        double r90231 = 3.098027387382756e+93;
        bool r90232 = r90212 <= r90231;
        double r90233 = -r90212;
        double r90234 = r90233 - r90227;
        double r90235 = r90234 / r90221;
        double r90236 = 0.5;
        double r90237 = r90236 * r90217;
        double r90238 = 2.0;
        double r90239 = r90212 / r90221;
        double r90240 = r90238 * r90239;
        double r90241 = r90237 - r90240;
        double r90242 = r90232 ? r90235 : r90241;
        double r90243 = r90220 ? r90230 : r90242;
        double r90244 = r90214 ? r90218 : r90243;
        return r90244;
}

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 < -2.503976408825374e+60

    1. Initial program 57.8

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

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

    if -2.503976408825374e+60 < b_2 < -1.041303973732452e-77

    1. Initial program 42.9

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt42.9

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Applied sqrt-prod44.0

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    5. Using strategy rm
    6. Applied flip--44.0

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

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

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

    if -1.041303973732452e-77 < b_2 < 3.098027387382756e+93

    1. Initial program 12.8

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

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

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

    if 3.098027387382756e+93 < b_2

    1. Initial program 46.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.5039764088253741 \cdot 10^{60}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.04130397373245191 \cdot 10^{-77}:\\ \;\;\;\;\frac{\frac{a \cdot c + 0}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}\\ \mathbf{elif}\;b_2 \le 3.0980273873827559 \cdot 10^{93}:\\ \;\;\;\;\frac{\left(-b_2\right) - \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 2020027 +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))