Average Error: 34.2 → 8.6
Time: 1.3m
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 -5.99946224548089213456388959139204668765 \cdot 10^{73}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -4.296272708131498829504916428849430668856 \cdot 10^{-127}:\\ \;\;\;\;\frac{\frac{a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{elif}\;b_2 \le 5.748502676649782580252214156933339561376 \cdot 10^{143}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\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 -5.99946224548089213456388959139204668765 \cdot 10^{73}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

\mathbf{elif}\;b_2 \le 5.748502676649782580252214156933339561376 \cdot 10^{143}:\\
\;\;\;\;\frac{-b_2}{a} - \frac{\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 r828993 = b_2;
        double r828994 = -r828993;
        double r828995 = r828993 * r828993;
        double r828996 = a;
        double r828997 = c;
        double r828998 = r828996 * r828997;
        double r828999 = r828995 - r828998;
        double r829000 = sqrt(r828999);
        double r829001 = r828994 - r829000;
        double r829002 = r829001 / r828996;
        return r829002;
}

double f(double a, double b_2, double c) {
        double r829003 = b_2;
        double r829004 = -5.999462245480892e+73;
        bool r829005 = r829003 <= r829004;
        double r829006 = -0.5;
        double r829007 = c;
        double r829008 = r829007 / r829003;
        double r829009 = r829006 * r829008;
        double r829010 = -4.296272708131499e-127;
        bool r829011 = r829003 <= r829010;
        double r829012 = a;
        double r829013 = r829012 * r829007;
        double r829014 = r829003 * r829003;
        double r829015 = r829014 - r829014;
        double r829016 = r829013 + r829015;
        double r829017 = r829016 / r829012;
        double r829018 = -r829003;
        double r829019 = r829014 - r829013;
        double r829020 = sqrt(r829019);
        double r829021 = r829018 + r829020;
        double r829022 = r829017 / r829021;
        double r829023 = 5.748502676649783e+143;
        bool r829024 = r829003 <= r829023;
        double r829025 = r829018 / r829012;
        double r829026 = r829020 / r829012;
        double r829027 = r829025 - r829026;
        double r829028 = -2.0;
        double r829029 = r829003 / r829012;
        double r829030 = r829028 * r829029;
        double r829031 = r829024 ? r829027 : r829030;
        double r829032 = r829011 ? r829022 : r829031;
        double r829033 = r829005 ? r829009 : r829032;
        return r829033;
}

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 < -5.999462245480892e+73

    1. Initial program 58.3

      \[\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 -5.999462245480892e+73 < b_2 < -4.296272708131499e-127

    1. Initial program 40.0

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied div-inv40.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 flip--40.0

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

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

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

    if -4.296272708131499e-127 < b_2 < 5.748502676649783e+143

    1. Initial program 11.3

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

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

    if 5.748502676649783e+143 < b_2

    1. Initial program 59.9

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied div-inv59.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 flip--63.9

      \[\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/63.9

      \[\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. Simplified63.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -5.99946224548089213456388959139204668765 \cdot 10^{73}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -4.296272708131498829504916428849430668856 \cdot 10^{-127}:\\ \;\;\;\;\frac{\frac{a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{elif}\;b_2 \le 5.748502676649782580252214156933339561376 \cdot 10^{143}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

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