Average Error: 33.2 → 8.7
Time: 18.7s
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 -8.528469058745581 \cdot 10^{+53}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -4.217048722645246 \cdot 10^{-140}:\\ \;\;\;\;\frac{\frac{a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}\\ \mathbf{elif}\;b_2 \le 2.559678284282607 \cdot 10^{+69}:\\ \;\;\;\;-\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-2, \frac{b_2}{a}, \frac{\frac{1}{2}}{\frac{b_2}{c}}\right)\\ \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 -8.528469058745581 \cdot 10^{+53}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

\mathbf{elif}\;b_2 \le 2.559678284282607 \cdot 10^{+69}:\\
\;\;\;\;-\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-2, \frac{b_2}{a}, \frac{\frac{1}{2}}{\frac{b_2}{c}}\right)\\

\end{array}
double f(double a, double b_2, double c) {
        double r2297831 = b_2;
        double r2297832 = -r2297831;
        double r2297833 = r2297831 * r2297831;
        double r2297834 = a;
        double r2297835 = c;
        double r2297836 = r2297834 * r2297835;
        double r2297837 = r2297833 - r2297836;
        double r2297838 = sqrt(r2297837);
        double r2297839 = r2297832 - r2297838;
        double r2297840 = r2297839 / r2297834;
        return r2297840;
}

double f(double a, double b_2, double c) {
        double r2297841 = b_2;
        double r2297842 = -8.528469058745581e+53;
        bool r2297843 = r2297841 <= r2297842;
        double r2297844 = -0.5;
        double r2297845 = c;
        double r2297846 = r2297845 / r2297841;
        double r2297847 = r2297844 * r2297846;
        double r2297848 = -4.217048722645246e-140;
        bool r2297849 = r2297841 <= r2297848;
        double r2297850 = a;
        double r2297851 = r2297850 * r2297845;
        double r2297852 = r2297841 * r2297841;
        double r2297853 = r2297852 - r2297852;
        double r2297854 = r2297851 + r2297853;
        double r2297855 = r2297852 - r2297851;
        double r2297856 = sqrt(r2297855);
        double r2297857 = r2297856 - r2297841;
        double r2297858 = r2297854 / r2297857;
        double r2297859 = r2297858 / r2297850;
        double r2297860 = 2.559678284282607e+69;
        bool r2297861 = r2297841 <= r2297860;
        double r2297862 = r2297856 + r2297841;
        double r2297863 = r2297862 / r2297850;
        double r2297864 = -r2297863;
        double r2297865 = -2.0;
        double r2297866 = r2297841 / r2297850;
        double r2297867 = 0.5;
        double r2297868 = r2297841 / r2297845;
        double r2297869 = r2297867 / r2297868;
        double r2297870 = fma(r2297865, r2297866, r2297869);
        double r2297871 = r2297861 ? r2297864 : r2297870;
        double r2297872 = r2297849 ? r2297859 : r2297871;
        double r2297873 = r2297843 ? r2297847 : r2297872;
        return r2297873;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -8.528469058745581e+53

    1. Initial program 56.5

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

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

    if -8.528469058745581e+53 < b_2 < -4.217048722645246e-140

    1. Initial program 37.1

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

      \[\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. Simplified15.2

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

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

    if -4.217048722645246e-140 < b_2 < 2.559678284282607e+69

    1. Initial program 11.2

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

      \[\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-inv11.3

      \[\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-cbrt11.3

      \[\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-frac11.3

      \[\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. Simplified11.3

      \[\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. Simplified11.3

      \[\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 associate-*l/11.2

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

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

    if 2.559678284282607e+69 < b_2

    1. Initial program 38.9

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]
    3. Simplified4.7

      \[\leadsto \color{blue}{\mathsf{fma}\left(-2, \frac{b_2}{a}, \frac{\frac{1}{2}}{\frac{b_2}{c}}\right)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -8.528469058745581 \cdot 10^{+53}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -4.217048722645246 \cdot 10^{-140}:\\ \;\;\;\;\frac{\frac{a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}\\ \mathbf{elif}\;b_2 \le 2.559678284282607 \cdot 10^{+69}:\\ \;\;\;\;-\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-2, \frac{b_2}{a}, \frac{\frac{1}{2}}{\frac{b_2}{c}}\right)\\ \end{array}\]

Reproduce

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