Average Error: 34.3 → 9.2
Time: 4.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 -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 r14904 = b_2;
        double r14905 = -r14904;
        double r14906 = r14904 * r14904;
        double r14907 = a;
        double r14908 = c;
        double r14909 = r14907 * r14908;
        double r14910 = r14906 - r14909;
        double r14911 = sqrt(r14910);
        double r14912 = r14905 - r14911;
        double r14913 = r14912 / r14907;
        return r14913;
}

double f(double a, double b_2, double c) {
        double r14914 = b_2;
        double r14915 = -2.503976408825374e+60;
        bool r14916 = r14914 <= r14915;
        double r14917 = -0.5;
        double r14918 = c;
        double r14919 = r14918 / r14914;
        double r14920 = r14917 * r14919;
        double r14921 = -1.041303973732452e-77;
        bool r14922 = r14914 <= r14921;
        double r14923 = a;
        double r14924 = r14923 * r14918;
        double r14925 = 0.0;
        double r14926 = r14924 + r14925;
        double r14927 = r14914 * r14914;
        double r14928 = r14927 - r14924;
        double r14929 = sqrt(r14928);
        double r14930 = r14929 - r14914;
        double r14931 = r14926 / r14930;
        double r14932 = r14931 / r14923;
        double r14933 = 3.098027387382756e+93;
        bool r14934 = r14914 <= r14933;
        double r14935 = -r14914;
        double r14936 = r14935 - r14929;
        double r14937 = r14936 / r14923;
        double r14938 = 0.5;
        double r14939 = r14938 * r14919;
        double r14940 = 2.0;
        double r14941 = r14914 / r14923;
        double r14942 = r14940 * r14941;
        double r14943 = r14939 - r14942;
        double r14944 = r14934 ? r14937 : r14943;
        double r14945 = r14922 ? r14932 : r14944;
        double r14946 = r14916 ? r14920 : r14945;
        return r14946;
}

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 "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))