Average Error: 33.9 → 11.0
Time: 5.2s
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 -524848456042.22467:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -2.374474662067348 \cdot 10^{-33}:\\ \;\;\;\;\frac{\frac{{b_2}^{2}}{a} - \frac{b_2 \cdot b_2 - a \cdot c}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{elif}\;b_2 \le -8.63724924767252634 \cdot 10^{-116}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 5.57925007375450966 \cdot 10^{51}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;-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 -524848456042.22467:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -2.374474662067348 \cdot 10^{-33}:\\
\;\;\;\;\frac{\frac{{b_2}^{2}}{a} - \frac{b_2 \cdot b_2 - a \cdot c}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\

\mathbf{elif}\;b_2 \le -8.63724924767252634 \cdot 10^{-116}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r15880 = b_2;
        double r15881 = -r15880;
        double r15882 = r15880 * r15880;
        double r15883 = a;
        double r15884 = c;
        double r15885 = r15883 * r15884;
        double r15886 = r15882 - r15885;
        double r15887 = sqrt(r15886);
        double r15888 = r15881 - r15887;
        double r15889 = r15888 / r15883;
        return r15889;
}

double f(double a, double b_2, double c) {
        double r15890 = b_2;
        double r15891 = -524848456042.2247;
        bool r15892 = r15890 <= r15891;
        double r15893 = -0.5;
        double r15894 = c;
        double r15895 = r15894 / r15890;
        double r15896 = r15893 * r15895;
        double r15897 = -2.374474662067348e-33;
        bool r15898 = r15890 <= r15897;
        double r15899 = 2.0;
        double r15900 = pow(r15890, r15899);
        double r15901 = a;
        double r15902 = r15900 / r15901;
        double r15903 = r15890 * r15890;
        double r15904 = r15901 * r15894;
        double r15905 = r15903 - r15904;
        double r15906 = r15905 / r15901;
        double r15907 = r15902 - r15906;
        double r15908 = -r15890;
        double r15909 = sqrt(r15905);
        double r15910 = r15908 + r15909;
        double r15911 = r15907 / r15910;
        double r15912 = -8.637249247672526e-116;
        bool r15913 = r15890 <= r15912;
        double r15914 = 5.5792500737545097e+51;
        bool r15915 = r15890 <= r15914;
        double r15916 = r15908 - r15909;
        double r15917 = r15916 / r15901;
        double r15918 = -2.0;
        double r15919 = r15890 / r15901;
        double r15920 = r15918 * r15919;
        double r15921 = r15915 ? r15917 : r15920;
        double r15922 = r15913 ? r15896 : r15921;
        double r15923 = r15898 ? r15911 : r15922;
        double r15924 = r15892 ? r15896 : r15923;
        return r15924;
}

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 < -524848456042.2247 or -2.374474662067348e-33 < b_2 < -8.637249247672526e-116

    1. Initial program 52.4

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

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

    if -524848456042.2247 < b_2 < -2.374474662067348e-33

    1. Initial program 40.3

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

      \[\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 flip--40.4

      \[\leadsto \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}}} \cdot \frac{1}{a}\]
    6. Applied associate-*l/40.4

      \[\leadsto \color{blue}{\frac{\left(\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}\right) \cdot \frac{1}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    7. Simplified40.3

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

    if -8.637249247672526e-116 < b_2 < 5.5792500737545097e+51

    1. Initial program 12.3

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

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

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

    if 5.5792500737545097e+51 < b_2

    1. Initial program 38.1

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

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

      \[\leadsto \color{blue}{\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}\]
    6. Using strategy rm
    7. Applied clear-num38.2

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    8. Taylor expanded around 0 5.8

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification11.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -524848456042.22467:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -2.374474662067348 \cdot 10^{-33}:\\ \;\;\;\;\frac{\frac{{b_2}^{2}}{a} - \frac{b_2 \cdot b_2 - a \cdot c}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{elif}\;b_2 \le -8.63724924767252634 \cdot 10^{-116}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 5.57925007375450966 \cdot 10^{51}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020018 +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))