Average Error: 34.4 → 8.8
Time: 10.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 -5.10985616674947893 \cdot 10^{57}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -2.57120366754749 \cdot 10^{-295}:\\ \;\;\;\;\frac{\frac{a \cdot c}{a}}{\sqrt{{b_2}^{2} - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 2.09453346119227227 \cdot 10^{90}:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{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.10985616674947893 \cdot 10^{57}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -2.57120366754749 \cdot 10^{-295}:\\
\;\;\;\;\frac{\frac{a \cdot c}{a}}{\sqrt{{b_2}^{2} - a \cdot c} - b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r20007 = b_2;
        double r20008 = -r20007;
        double r20009 = r20007 * r20007;
        double r20010 = a;
        double r20011 = c;
        double r20012 = r20010 * r20011;
        double r20013 = r20009 - r20012;
        double r20014 = sqrt(r20013);
        double r20015 = r20008 - r20014;
        double r20016 = r20015 / r20010;
        return r20016;
}

double f(double a, double b_2, double c) {
        double r20017 = b_2;
        double r20018 = -5.109856166749479e+57;
        bool r20019 = r20017 <= r20018;
        double r20020 = -0.5;
        double r20021 = c;
        double r20022 = r20021 / r20017;
        double r20023 = r20020 * r20022;
        double r20024 = -2.57120366754749e-295;
        bool r20025 = r20017 <= r20024;
        double r20026 = a;
        double r20027 = r20026 * r20021;
        double r20028 = r20027 / r20026;
        double r20029 = 2.0;
        double r20030 = pow(r20017, r20029);
        double r20031 = r20030 - r20027;
        double r20032 = sqrt(r20031);
        double r20033 = r20032 - r20017;
        double r20034 = r20028 / r20033;
        double r20035 = 2.0945334611922723e+90;
        bool r20036 = r20017 <= r20035;
        double r20037 = -r20017;
        double r20038 = r20017 * r20017;
        double r20039 = r20038 - r20027;
        double r20040 = sqrt(r20039);
        double r20041 = r20037 - r20040;
        double r20042 = 1.0;
        double r20043 = r20042 / r20026;
        double r20044 = r20041 * r20043;
        double r20045 = -2.0;
        double r20046 = r20017 / r20026;
        double r20047 = r20045 * r20046;
        double r20048 = r20036 ? r20044 : r20047;
        double r20049 = r20025 ? r20034 : r20048;
        double r20050 = r20019 ? r20023 : r20049;
        return r20050;
}

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.109856166749479e+57

    1. Initial program 58.1

      \[\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.109856166749479e+57 < b_2 < -2.57120366754749e-295

    1. Initial program 30.9

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

      \[\leadsto \frac{\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}}}}{a}\]
    4. Simplified17.1

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

      \[\leadsto \frac{\frac{b_2 \cdot \left(b_2 - b_2\right) + a \cdot c}{\color{blue}{\sqrt{{b_2}^{2} - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity17.1

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

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

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

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{\mathsf{fma}\left(c, a, 0\right)}{a \cdot \left(\sqrt{{b_2}^{2} - a \cdot c} - b_2\right)}}\]
    14. Using strategy rm
    15. Applied associate-/r*16.7

      \[\leadsto 1 \cdot \color{blue}{\frac{\frac{\mathsf{fma}\left(c, a, 0\right)}{a}}{\sqrt{{b_2}^{2} - a \cdot c} - b_2}}\]
    16. Simplified16.7

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

    if -2.57120366754749e-295 < b_2 < 2.0945334611922723e+90

    1. Initial program 9.2

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

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

    if 2.0945334611922723e+90 < b_2

    1. Initial program 45.6

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

      \[\leadsto \frac{\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}}}}{a}\]
    4. Simplified61.8

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

      \[\leadsto \frac{\frac{b_2 \cdot \left(b_2 - b_2\right) + a \cdot c}{\color{blue}{\sqrt{{b_2}^{2} - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity61.8

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

      \[\leadsto \frac{\frac{b_2 \cdot \left(b_2 - b_2\right) + a \cdot c}{\color{blue}{1 \cdot \left(\sqrt{{b_2}^{2} - a \cdot c} - b_2\right)}}}{1 \cdot a}\]
    9. Applied *-un-lft-identity61.8

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot \left(b_2 \cdot \left(b_2 - b_2\right) + a \cdot c\right)}}{1 \cdot \left(\sqrt{{b_2}^{2} - a \cdot c} - b_2\right)}}{1 \cdot a}\]
    10. Applied times-frac61.8

      \[\leadsto \frac{\color{blue}{\frac{1}{1} \cdot \frac{b_2 \cdot \left(b_2 - b_2\right) + a \cdot c}{\sqrt{{b_2}^{2} - a \cdot c} - b_2}}}{1 \cdot a}\]
    11. Applied times-frac61.8

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{\mathsf{fma}\left(c, a, 0\right)}{a \cdot \left(\sqrt{{b_2}^{2} - a \cdot c} - b_2\right)}}\]
    14. Taylor expanded around 0 4.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -5.10985616674947893 \cdot 10^{57}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -2.57120366754749 \cdot 10^{-295}:\\ \;\;\;\;\frac{\frac{a \cdot c}{a}}{\sqrt{{b_2}^{2} - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 2.09453346119227227 \cdot 10^{90}:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

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