Average Error: 33.6 → 9.3
Time: 1.4m
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 -9.240807674268867 \cdot 10^{+23}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -6.7222348411288265 \cdot 10^{-49}:\\ \;\;\;\;\frac{-c \cdot a}{a \cdot \left(b_2 - \sqrt{b_2 \cdot b_2 - c \cdot a}\right)}\\ \mathbf{elif}\;b_2 \le -1.853957975167164 \cdot 10^{-67}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 4.778966372232416 \cdot 10^{+96}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot 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 -9.240807674268867 \cdot 10^{+23}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r2535992 = b_2;
        double r2535993 = -r2535992;
        double r2535994 = r2535992 * r2535992;
        double r2535995 = a;
        double r2535996 = c;
        double r2535997 = r2535995 * r2535996;
        double r2535998 = r2535994 - r2535997;
        double r2535999 = sqrt(r2535998);
        double r2536000 = r2535993 - r2535999;
        double r2536001 = r2536000 / r2535995;
        return r2536001;
}

double f(double a, double b_2, double c) {
        double r2536002 = b_2;
        double r2536003 = -9.240807674268867e+23;
        bool r2536004 = r2536002 <= r2536003;
        double r2536005 = -0.5;
        double r2536006 = c;
        double r2536007 = r2536006 / r2536002;
        double r2536008 = r2536005 * r2536007;
        double r2536009 = -6.7222348411288265e-49;
        bool r2536010 = r2536002 <= r2536009;
        double r2536011 = a;
        double r2536012 = r2536006 * r2536011;
        double r2536013 = -r2536012;
        double r2536014 = r2536002 * r2536002;
        double r2536015 = r2536014 - r2536012;
        double r2536016 = sqrt(r2536015);
        double r2536017 = r2536002 - r2536016;
        double r2536018 = r2536011 * r2536017;
        double r2536019 = r2536013 / r2536018;
        double r2536020 = -1.853957975167164e-67;
        bool r2536021 = r2536002 <= r2536020;
        double r2536022 = 4.778966372232416e+96;
        bool r2536023 = r2536002 <= r2536022;
        double r2536024 = 1.0;
        double r2536025 = -r2536002;
        double r2536026 = r2536025 - r2536016;
        double r2536027 = r2536011 / r2536026;
        double r2536028 = r2536024 / r2536027;
        double r2536029 = -2.0;
        double r2536030 = r2536002 / r2536011;
        double r2536031 = r2536029 * r2536030;
        double r2536032 = r2536023 ? r2536028 : r2536031;
        double r2536033 = r2536021 ? r2536008 : r2536032;
        double r2536034 = r2536010 ? r2536019 : r2536033;
        double r2536035 = r2536004 ? r2536008 : r2536034;
        return r2536035;
}

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 < -9.240807674268867e+23 or -6.7222348411288265e-49 < b_2 < -1.853957975167164e-67

    1. Initial program 55.2

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

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

    if -9.240807674268867e+23 < b_2 < -6.7222348411288265e-49

    1. Initial program 44.1

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    4. Using strategy rm
    5. Applied div-inv44.2

      \[\leadsto \frac{1}{\color{blue}{a \cdot \frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    6. Applied *-un-lft-identity44.2

      \[\leadsto \frac{\color{blue}{1 \cdot 1}}{a \cdot \frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    7. Applied times-frac44.2

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

      \[\leadsto \frac{1}{a} \cdot \color{blue}{\left(-\left(b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)\right)}\]
    9. Using strategy rm
    10. Applied flip-+44.2

      \[\leadsto \frac{1}{a} \cdot \left(-\color{blue}{\frac{b_2 \cdot b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\right)\]
    11. Applied distribute-neg-frac44.2

      \[\leadsto \frac{1}{a} \cdot \color{blue}{\frac{-\left(b_2 \cdot b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    12. Applied frac-times46.2

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

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

    if -1.853957975167164e-67 < b_2 < 4.778966372232416e+96

    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 clear-num12.7

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

    if 4.778966372232416e+96 < b_2

    1. Initial program 43.5

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    4. Using strategy rm
    5. Applied div-inv43.6

      \[\leadsto \frac{1}{\color{blue}{a \cdot \frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    6. Applied *-un-lft-identity43.6

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -9.240807674268867 \cdot 10^{+23}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -6.7222348411288265 \cdot 10^{-49}:\\ \;\;\;\;\frac{-c \cdot a}{a \cdot \left(b_2 - \sqrt{b_2 \cdot b_2 - c \cdot a}\right)}\\ \mathbf{elif}\;b_2 \le -1.853957975167164 \cdot 10^{-67}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 4.778966372232416 \cdot 10^{+96}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

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