Average Error: 34.2 → 7.4
Time: 11.2s
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 -84351863079940134392111797632084475904000:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.779221184338331637638800633144967588071 \cdot 10^{-301}:\\ \;\;\;\;\frac{1}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{c}}\\ \mathbf{elif}\;b_2 \le 2.730494439370032074747470763239053019705 \cdot 10^{75}:\\ \;\;\;\;\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 -84351863079940134392111797632084475904000:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 2.779221184338331637638800633144967588071 \cdot 10^{-301}:\\
\;\;\;\;\frac{1}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{c}}\\

\mathbf{elif}\;b_2 \le 2.730494439370032074747470763239053019705 \cdot 10^{75}:\\
\;\;\;\;\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 r85588 = b_2;
        double r85589 = -r85588;
        double r85590 = r85588 * r85588;
        double r85591 = a;
        double r85592 = c;
        double r85593 = r85591 * r85592;
        double r85594 = r85590 - r85593;
        double r85595 = sqrt(r85594);
        double r85596 = r85589 - r85595;
        double r85597 = r85596 / r85591;
        return r85597;
}

double f(double a, double b_2, double c) {
        double r85598 = b_2;
        double r85599 = -8.435186307994013e+40;
        bool r85600 = r85598 <= r85599;
        double r85601 = -0.5;
        double r85602 = c;
        double r85603 = r85602 / r85598;
        double r85604 = r85601 * r85603;
        double r85605 = 2.7792211843383316e-301;
        bool r85606 = r85598 <= r85605;
        double r85607 = 1.0;
        double r85608 = r85598 * r85598;
        double r85609 = a;
        double r85610 = r85609 * r85602;
        double r85611 = r85608 - r85610;
        double r85612 = sqrt(r85611);
        double r85613 = r85612 - r85598;
        double r85614 = r85613 / r85602;
        double r85615 = r85607 / r85614;
        double r85616 = 2.730494439370032e+75;
        bool r85617 = r85598 <= r85616;
        double r85618 = -r85598;
        double r85619 = r85618 / r85609;
        double r85620 = r85612 / r85609;
        double r85621 = r85619 - r85620;
        double r85622 = -2.0;
        double r85623 = r85598 / r85609;
        double r85624 = r85622 * r85623;
        double r85625 = r85617 ? r85621 : r85624;
        double r85626 = r85606 ? r85615 : r85625;
        double r85627 = r85600 ? r85604 : r85626;
        return r85627;
}

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 < -8.435186307994013e+40

    1. Initial program 56.9

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

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

    if -8.435186307994013e+40 < b_2 < 2.7792211843383316e-301

    1. Initial program 28.4

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

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

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

      \[\leadsto \frac{\frac{a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied clear-num17.0

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}}\]
    8. Simplified10.1

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

    if 2.7792211843383316e-301 < b_2 < 2.730494439370032e+75

    1. Initial program 9.5

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

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

    if 2.730494439370032e+75 < b_2

    1. Initial program 43.1

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

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

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

      \[\leadsto \frac{\frac{a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Taylor expanded around 0 5.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -84351863079940134392111797632084475904000:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.779221184338331637638800633144967588071 \cdot 10^{-301}:\\ \;\;\;\;\frac{1}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{c}}\\ \mathbf{elif}\;b_2 \le 2.730494439370032074747470763239053019705 \cdot 10^{75}:\\ \;\;\;\;\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 2019308 
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))