Average Error: 33.4 → 9.7
Time: 35.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.852138444177435 \cdot 10^{-54}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 7.803671648955123 \cdot 10^{+137}:\\ \;\;\;\;-\left(\frac{b_2}{a} + \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\right)\\ \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 -2.852138444177435 \cdot 10^{-54}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r839910 = b_2;
        double r839911 = -r839910;
        double r839912 = r839910 * r839910;
        double r839913 = a;
        double r839914 = c;
        double r839915 = r839913 * r839914;
        double r839916 = r839912 - r839915;
        double r839917 = sqrt(r839916);
        double r839918 = r839911 - r839917;
        double r839919 = r839918 / r839913;
        return r839919;
}

double f(double a, double b_2, double c) {
        double r839920 = b_2;
        double r839921 = -2.852138444177435e-54;
        bool r839922 = r839920 <= r839921;
        double r839923 = -0.5;
        double r839924 = c;
        double r839925 = r839924 / r839920;
        double r839926 = r839923 * r839925;
        double r839927 = 7.803671648955123e+137;
        bool r839928 = r839920 <= r839927;
        double r839929 = a;
        double r839930 = r839920 / r839929;
        double r839931 = r839920 * r839920;
        double r839932 = r839924 * r839929;
        double r839933 = r839931 - r839932;
        double r839934 = sqrt(r839933);
        double r839935 = r839934 / r839929;
        double r839936 = r839930 + r839935;
        double r839937 = -r839936;
        double r839938 = -2.0;
        double r839939 = r839938 * r839930;
        double r839940 = r839928 ? r839937 : r839939;
        double r839941 = r839922 ? r839926 : r839940;
        return r839941;
}

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 3 regimes
  2. if b_2 < -2.852138444177435e-54

    1. Initial program 53.4

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

      \[\leadsto \color{blue}{\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}\]
    4. Taylor expanded around -inf 8.3

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

    if -2.852138444177435e-54 < b_2 < 7.803671648955123e+137

    1. Initial program 12.6

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

      \[\leadsto \color{blue}{\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity12.6

      \[\leadsto \frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{\color{blue}{1 \cdot a}}\]
    6. Applied add-sqr-sqrt12.6

      \[\leadsto \frac{-b_2}{a} - \frac{\sqrt{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{1 \cdot a}\]
    7. Applied sqrt-prod12.8

      \[\leadsto \frac{-b_2}{a} - \frac{\color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}}{1 \cdot a}\]
    8. Applied times-frac12.8

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

      \[\leadsto \frac{-b_2}{a} - \color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}} \cdot \frac{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    10. Using strategy rm
    11. Applied sub-neg12.8

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

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

    if 7.803671648955123e+137 < b_2

    1. Initial program 53.1

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

      \[\leadsto \color{blue}{\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}\]
    4. Using strategy rm
    5. Applied div-inv53.2

      \[\leadsto \frac{-b_2}{a} - \color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \frac{1}{a}}\]
    6. Applied div-inv53.2

      \[\leadsto \color{blue}{\left(-b_2\right) \cdot \frac{1}{a}} - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \frac{1}{a}\]
    7. Applied distribute-rgt-out--53.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.852138444177435 \cdot 10^{-54}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 7.803671648955123 \cdot 10^{+137}:\\ \;\;\;\;-\left(\frac{b_2}{a} + \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019143 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))