Average Error: 33.7 → 9.7
Time: 5.4s
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 -4.8621678288459276 \cdot 10^{80}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -5.07965843072761894 \cdot 10^{-161}:\\ \;\;\;\;\frac{1}{a} \cdot \frac{0 + a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 1.2919983862558445 \cdot 10^{30}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_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 -4.8621678288459276 \cdot 10^{80}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -5.07965843072761894 \cdot 10^{-161}:\\
\;\;\;\;\frac{1}{a} \cdot \frac{0 + a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r73704 = b_2;
        double r73705 = -r73704;
        double r73706 = r73704 * r73704;
        double r73707 = a;
        double r73708 = c;
        double r73709 = r73707 * r73708;
        double r73710 = r73706 - r73709;
        double r73711 = sqrt(r73710);
        double r73712 = r73705 - r73711;
        double r73713 = r73712 / r73707;
        return r73713;
}

double f(double a, double b_2, double c) {
        double r73714 = b_2;
        double r73715 = -4.862167828845928e+80;
        bool r73716 = r73714 <= r73715;
        double r73717 = -0.5;
        double r73718 = c;
        double r73719 = r73718 / r73714;
        double r73720 = r73717 * r73719;
        double r73721 = -5.079658430727619e-161;
        bool r73722 = r73714 <= r73721;
        double r73723 = 1.0;
        double r73724 = a;
        double r73725 = r73723 / r73724;
        double r73726 = 0.0;
        double r73727 = r73724 * r73718;
        double r73728 = r73726 + r73727;
        double r73729 = r73714 * r73714;
        double r73730 = r73729 - r73727;
        double r73731 = sqrt(r73730);
        double r73732 = r73731 - r73714;
        double r73733 = r73728 / r73732;
        double r73734 = r73725 * r73733;
        double r73735 = 1.2919983862558445e+30;
        bool r73736 = r73714 <= r73735;
        double r73737 = -r73714;
        double r73738 = r73737 - r73731;
        double r73739 = r73724 / r73738;
        double r73740 = r73723 / r73739;
        double r73741 = 0.5;
        double r73742 = r73741 * r73719;
        double r73743 = 2.0;
        double r73744 = r73714 / r73724;
        double r73745 = r73743 * r73744;
        double r73746 = r73742 - r73745;
        double r73747 = r73736 ? r73740 : r73746;
        double r73748 = r73722 ? r73734 : r73747;
        double r73749 = r73716 ? r73720 : r73748;
        return r73749;
}

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 < -4.862167828845928e+80

    1. Initial program 58.0

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

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

    if -4.862167828845928e+80 < b_2 < -5.079658430727619e-161

    1. Initial program 36.9

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

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

      \[\leadsto \frac{1}{\color{blue}{a \cdot \frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    6. Applied add-cube-cbrt36.9

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{a \cdot \frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    7. Applied times-frac36.9

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

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

      \[\leadsto \frac{1}{a} \cdot \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}\]
    10. Using strategy rm
    11. Applied add-exp-log40.7

      \[\leadsto \frac{1}{a} \cdot \left(\left(-b_2\right) - \color{blue}{e^{\log \left(\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\right)\]
    12. Using strategy rm
    13. Applied flip--40.7

      \[\leadsto \frac{1}{a} \cdot \color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - e^{\log \left(\sqrt{b_2 \cdot b_2 - a \cdot c}\right)} \cdot e^{\log \left(\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{\left(-b_2\right) + e^{\log \left(\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}}\]
    14. Simplified18.7

      \[\leadsto \frac{1}{a} \cdot \frac{\color{blue}{0 + a \cdot c}}{\left(-b_2\right) + e^{\log \left(\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\]
    15. Simplified16.2

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

    if -5.079658430727619e-161 < b_2 < 1.2919983862558445e+30

    1. Initial program 12.6

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

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

    if 1.2919983862558445e+30 < b_2

    1. Initial program 34.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -4.8621678288459276 \cdot 10^{80}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -5.07965843072761894 \cdot 10^{-161}:\\ \;\;\;\;\frac{1}{a} \cdot \frac{0 + a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 1.2919983862558445 \cdot 10^{30}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020100 +o rules:numerics
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))