Average Error: 33.8 → 10.1
Time: 5.5s
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 -4.825330629057740564739189793323147405328 \cdot 10^{-58}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.295909507922486729244255700447297235864 \cdot 10^{107}:\\ \;\;\;\;{\left(\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)}^{1}\\ \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 -4.825330629057740564739189793323147405328 \cdot 10^{-58}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

\mathbf{else}:\\
\;\;\;\;{\left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)}^{1}\\

\end{array}
double f(double a, double b_2, double c) {
        double r15870 = b_2;
        double r15871 = -r15870;
        double r15872 = r15870 * r15870;
        double r15873 = a;
        double r15874 = c;
        double r15875 = r15873 * r15874;
        double r15876 = r15872 - r15875;
        double r15877 = sqrt(r15876);
        double r15878 = r15871 - r15877;
        double r15879 = r15878 / r15873;
        return r15879;
}

double f(double a, double b_2, double c) {
        double r15880 = b_2;
        double r15881 = -4.8253306290577406e-58;
        bool r15882 = r15880 <= r15881;
        double r15883 = -0.5;
        double r15884 = c;
        double r15885 = r15884 / r15880;
        double r15886 = r15883 * r15885;
        double r15887 = 1.2959095079224867e+107;
        bool r15888 = r15880 <= r15887;
        double r15889 = -r15880;
        double r15890 = r15880 * r15880;
        double r15891 = a;
        double r15892 = r15891 * r15884;
        double r15893 = r15890 - r15892;
        double r15894 = sqrt(r15893);
        double r15895 = r15889 - r15894;
        double r15896 = r15895 / r15891;
        double r15897 = 1.0;
        double r15898 = pow(r15896, r15897);
        double r15899 = 0.5;
        double r15900 = r15899 * r15885;
        double r15901 = 2.0;
        double r15902 = r15880 / r15891;
        double r15903 = r15901 * r15902;
        double r15904 = r15900 - r15903;
        double r15905 = pow(r15904, r15897);
        double r15906 = r15888 ? r15898 : r15905;
        double r15907 = r15882 ? r15886 : r15906;
        return r15907;
}

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 < -4.8253306290577406e-58

    1. Initial program 53.0

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

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

    if -4.8253306290577406e-58 < b_2 < 1.2959095079224867e+107

    1. Initial program 13.5

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

      \[\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 pow113.6

      \[\leadsto \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \color{blue}{{\left(\frac{1}{a}\right)}^{1}}\]
    6. Applied pow113.6

      \[\leadsto \color{blue}{{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}^{1}} \cdot {\left(\frac{1}{a}\right)}^{1}\]
    7. Applied pow-prod-down13.6

      \[\leadsto \color{blue}{{\left(\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\right)}^{1}}\]
    8. Simplified13.5

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

    if 1.2959095079224867e+107 < b_2

    1. Initial program 47.9

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

      \[\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 pow148.0

      \[\leadsto \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \color{blue}{{\left(\frac{1}{a}\right)}^{1}}\]
    6. Applied pow148.0

      \[\leadsto \color{blue}{{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}^{1}} \cdot {\left(\frac{1}{a}\right)}^{1}\]
    7. Applied pow-prod-down48.0

      \[\leadsto \color{blue}{{\left(\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\right)}^{1}}\]
    8. Simplified47.9

      \[\leadsto {\color{blue}{\left(\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\right)}}^{1}\]
    9. Taylor expanded around inf 3.5

      \[\leadsto {\color{blue}{\left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)}}^{1}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -4.825330629057740564739189793323147405328 \cdot 10^{-58}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.295909507922486729244255700447297235864 \cdot 10^{107}:\\ \;\;\;\;{\left(\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)}^{1}\\ \end{array}\]

Reproduce

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