Average Error: 32.9 → 11.0
Time: 29.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 -1.515406138267436 \cdot 10^{+130}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 30831695.97060173:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{1}{2} - 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 -1.515406138267436 \cdot 10^{+130}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r1178972 = b_2;
        double r1178973 = -r1178972;
        double r1178974 = r1178972 * r1178972;
        double r1178975 = a;
        double r1178976 = c;
        double r1178977 = r1178975 * r1178976;
        double r1178978 = r1178974 - r1178977;
        double r1178979 = sqrt(r1178978);
        double r1178980 = r1178973 - r1178979;
        double r1178981 = r1178980 / r1178975;
        return r1178981;
}

double f(double a, double b_2, double c) {
        double r1178982 = b_2;
        double r1178983 = -1.515406138267436e+130;
        bool r1178984 = r1178982 <= r1178983;
        double r1178985 = -0.5;
        double r1178986 = c;
        double r1178987 = r1178986 / r1178982;
        double r1178988 = r1178985 * r1178987;
        double r1178989 = 30831695.97060173;
        bool r1178990 = r1178982 <= r1178989;
        double r1178991 = r1178982 * r1178982;
        double r1178992 = a;
        double r1178993 = r1178992 * r1178986;
        double r1178994 = r1178991 - r1178993;
        double r1178995 = sqrt(r1178994);
        double r1178996 = -r1178982;
        double r1178997 = r1178995 + r1178996;
        double r1178998 = r1178986 / r1178997;
        double r1178999 = 0.5;
        double r1179000 = r1178987 * r1178999;
        double r1179001 = 2.0;
        double r1179002 = r1178982 / r1178992;
        double r1179003 = r1179001 * r1179002;
        double r1179004 = r1179000 - r1179003;
        double r1179005 = r1178990 ? r1178998 : r1179004;
        double r1179006 = r1178984 ? r1178988 : r1179005;
        return r1179006;
}

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 < -1.515406138267436e+130

    1. Initial program 60.2

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

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

    if -1.515406138267436e+130 < b_2 < 30831695.97060173

    1. Initial program 24.4

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

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{{b_2}^{2} - a \cdot c}}}{a}\]
    3. Simplified24.4

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

      \[\leadsto \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
    6. Using strategy rm
    7. Applied flip--30.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}\]
    8. Applied associate-*l/31.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}}}\]
    9. Simplified19.6

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

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

    if 30831695.97060173 < b_2

    1. Initial program 30.5

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

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{{b_2}^{2} - a \cdot c}}}{a}\]
    3. Simplified30.5

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

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

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

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

Reproduce

herbie shell --seed 2019121 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))