Average Error: 33.8 → 6.7
Time: 16.5s
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 -5.0629549698067062 \cdot 10^{105}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 1.6905899892511143 \cdot 10^{-305}:\\ \;\;\;\;\frac{\left(-b_2\right) + \sqrt{{b_2}^{2} - c \cdot a}}{a}\\ \mathbf{elif}\;b_2 \le 1.183295134100389 \cdot 10^{134}:\\ \;\;\;\;\frac{1}{\frac{\left(-b_2\right) - \sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)}}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \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 -5.0629549698067062 \cdot 10^{105}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\

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

\mathbf{elif}\;b_2 \le 1.183295134100389 \cdot 10^{134}:\\
\;\;\;\;\frac{1}{\frac{\left(-b_2\right) - \sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)}}{c}}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r29863 = b_2;
        double r29864 = -r29863;
        double r29865 = r29863 * r29863;
        double r29866 = a;
        double r29867 = c;
        double r29868 = r29866 * r29867;
        double r29869 = r29865 - r29868;
        double r29870 = sqrt(r29869);
        double r29871 = r29864 + r29870;
        double r29872 = r29871 / r29866;
        return r29872;
}

double f(double a, double b_2, double c) {
        double r29873 = b_2;
        double r29874 = -5.062954969806706e+105;
        bool r29875 = r29873 <= r29874;
        double r29876 = 0.5;
        double r29877 = c;
        double r29878 = r29877 / r29873;
        double r29879 = r29876 * r29878;
        double r29880 = 2.0;
        double r29881 = a;
        double r29882 = r29873 / r29881;
        double r29883 = r29880 * r29882;
        double r29884 = r29879 - r29883;
        double r29885 = 1.6905899892511143e-305;
        bool r29886 = r29873 <= r29885;
        double r29887 = -r29873;
        double r29888 = pow(r29873, r29880);
        double r29889 = r29877 * r29881;
        double r29890 = r29888 - r29889;
        double r29891 = sqrt(r29890);
        double r29892 = r29887 + r29891;
        double r29893 = r29892 / r29881;
        double r29894 = 1.183295134100389e+134;
        bool r29895 = r29873 <= r29894;
        double r29896 = 1.0;
        double r29897 = -r29889;
        double r29898 = fma(r29873, r29873, r29897);
        double r29899 = sqrt(r29898);
        double r29900 = r29887 - r29899;
        double r29901 = r29900 / r29877;
        double r29902 = r29896 / r29901;
        double r29903 = -0.5;
        double r29904 = r29903 * r29878;
        double r29905 = r29895 ? r29902 : r29904;
        double r29906 = r29886 ? r29893 : r29905;
        double r29907 = r29875 ? r29884 : r29906;
        return r29907;
}

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 < -5.062954969806706e+105

    1. Initial program 49.1

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

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

      \[\leadsto \frac{\frac{\color{blue}{0 + c \cdot a}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. Using strategy rm
    6. Applied clear-num62.5

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

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

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

    if -5.062954969806706e+105 < b_2 < 1.6905899892511143e-305

    1. Initial program 9.0

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

      \[\leadsto \frac{\left(-b_2\right) + \sqrt{\color{blue}{{b_2}^{2} - a \cdot c}}}{a}\]
    3. Simplified9.0

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

    if 1.6905899892511143e-305 < b_2 < 1.183295134100389e+134

    1. Initial program 33.5

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

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

      \[\leadsto \frac{\frac{\color{blue}{0 + c \cdot a}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. Using strategy rm
    6. Applied clear-num16.7

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot 1}}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a \cdot c}}}{a}\]
    11. Applied times-frac16.8

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

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

      \[\leadsto \frac{\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{\color{blue}{\frac{1}{c}}}\]
    14. Using strategy rm
    15. Applied *-un-lft-identity8.9

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

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

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

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

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

    if 1.183295134100389e+134 < b_2

    1. Initial program 62.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -5.0629549698067062 \cdot 10^{105}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 1.6905899892511143 \cdot 10^{-305}:\\ \;\;\;\;\frac{\left(-b_2\right) + \sqrt{{b_2}^{2} - c \cdot a}}{a}\\ \mathbf{elif}\;b_2 \le 1.183295134100389 \cdot 10^{134}:\\ \;\;\;\;\frac{1}{\frac{\left(-b_2\right) - \sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)}}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019195 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))