Average Error: 32.6 → 9.6
Time: 22.0s
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 -6.90131991727783 \cdot 10^{-39}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 4.012768074517757 \cdot 10^{+87}:\\ \;\;\;\;\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 -6.90131991727783 \cdot 10^{-39}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 4.012768074517757 \cdot 10^{+87}:\\
\;\;\;\;\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 r641166 = b_2;
        double r641167 = -r641166;
        double r641168 = r641166 * r641166;
        double r641169 = a;
        double r641170 = c;
        double r641171 = r641169 * r641170;
        double r641172 = r641168 - r641171;
        double r641173 = sqrt(r641172);
        double r641174 = r641167 - r641173;
        double r641175 = r641174 / r641169;
        return r641175;
}

double f(double a, double b_2, double c) {
        double r641176 = b_2;
        double r641177 = -6.90131991727783e-39;
        bool r641178 = r641176 <= r641177;
        double r641179 = -0.5;
        double r641180 = c;
        double r641181 = r641180 / r641176;
        double r641182 = r641179 * r641181;
        double r641183 = 4.012768074517757e+87;
        bool r641184 = r641176 <= r641183;
        double r641185 = 1.0;
        double r641186 = a;
        double r641187 = -r641176;
        double r641188 = r641176 * r641176;
        double r641189 = r641180 * r641186;
        double r641190 = r641188 - r641189;
        double r641191 = sqrt(r641190);
        double r641192 = r641187 - r641191;
        double r641193 = r641186 / r641192;
        double r641194 = r641185 / r641193;
        double r641195 = -2.0;
        double r641196 = r641176 / r641186;
        double r641197 = r641195 * r641196;
        double r641198 = r641184 ? r641194 : r641197;
        double r641199 = r641178 ? r641182 : r641198;
        return r641199;
}

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 < -6.90131991727783e-39

    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 7.9

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

    if -6.90131991727783e-39 < b_2 < 4.012768074517757e+87

    1. Initial program 13.2

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity13.2

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

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}\]
    7. Applied associate-/l*13.3

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

    if 4.012768074517757e+87 < b_2

    1. Initial program 41.3

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity41.3

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

      \[\leadsto \frac{\left(-\color{blue}{1 \cdot b_2}\right) - 1 \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    5. Applied distribute-rgt-neg-in41.3

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

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}\]
    7. Applied associate-/l*41.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -6.90131991727783 \cdot 10^{-39}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 4.012768074517757 \cdot 10^{+87}:\\ \;\;\;\;\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 2019132 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))