Average Error: 32.8 → 6.4
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 -1.1214768270116103 \cdot 10^{+154}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.199441090208904 \cdot 10^{-250}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 3.3389954009657566 \cdot 10^{+124}:\\ \;\;\;\;\left(-\frac{b_2}{a}\right) - \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 -1.1214768270116103 \cdot 10^{+154}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 1.199441090208904 \cdot 10^{-250}:\\
\;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\

\mathbf{elif}\;b_2 \le 3.3389954009657566 \cdot 10^{+124}:\\
\;\;\;\;\left(-\frac{b_2}{a}\right) - \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 r7770766 = b_2;
        double r7770767 = -r7770766;
        double r7770768 = r7770766 * r7770766;
        double r7770769 = a;
        double r7770770 = c;
        double r7770771 = r7770769 * r7770770;
        double r7770772 = r7770768 - r7770771;
        double r7770773 = sqrt(r7770772);
        double r7770774 = r7770767 - r7770773;
        double r7770775 = r7770774 / r7770769;
        return r7770775;
}

double f(double a, double b_2, double c) {
        double r7770776 = b_2;
        double r7770777 = -1.1214768270116103e+154;
        bool r7770778 = r7770776 <= r7770777;
        double r7770779 = -0.5;
        double r7770780 = c;
        double r7770781 = r7770780 / r7770776;
        double r7770782 = r7770779 * r7770781;
        double r7770783 = 1.199441090208904e-250;
        bool r7770784 = r7770776 <= r7770783;
        double r7770785 = r7770776 * r7770776;
        double r7770786 = a;
        double r7770787 = r7770786 * r7770780;
        double r7770788 = r7770785 - r7770787;
        double r7770789 = sqrt(r7770788);
        double r7770790 = r7770789 - r7770776;
        double r7770791 = r7770780 / r7770790;
        double r7770792 = 3.3389954009657566e+124;
        bool r7770793 = r7770776 <= r7770792;
        double r7770794 = r7770776 / r7770786;
        double r7770795 = -r7770794;
        double r7770796 = r7770789 / r7770786;
        double r7770797 = r7770795 - r7770796;
        double r7770798 = -2.0;
        double r7770799 = r7770798 * r7770794;
        double r7770800 = r7770793 ? r7770797 : r7770799;
        double r7770801 = r7770784 ? r7770791 : r7770800;
        double r7770802 = r7770778 ? r7770782 : r7770801;
        return r7770802;
}

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 < -1.1214768270116103e+154

    1. Initial program 62.9

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

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

    if -1.1214768270116103e+154 < b_2 < 1.199441090208904e-250

    1. Initial program 32.2

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--32.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. Simplified16.2

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

      \[\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 *-un-lft-identity16.2

      \[\leadsto \frac{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied *-un-lft-identity16.2

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{1 \cdot a}\]
    9. Applied times-frac16.2

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

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

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

    if 1.199441090208904e-250 < b_2 < 3.3389954009657566e+124

    1. Initial program 7.8

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

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

    if 3.3389954009657566e+124 < b_2

    1. Initial program 50.6

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

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

      \[\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-in50.6

      \[\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--50.6

      \[\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*50.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.1214768270116103 \cdot 10^{+154}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.199441090208904 \cdot 10^{-250}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 3.3389954009657566 \cdot 10^{+124}:\\ \;\;\;\;\left(-\frac{b_2}{a}\right) - \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 2019128 
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))