Average Error: 34.5 → 10.9
Time: 13.6s
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 -2.615257373542238721197930661559276546696 \cdot 10^{153}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\right)\\ \mathbf{elif}\;b_2 \le 1.388070047225937856958905133202240499626 \cdot 10^{-143}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \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 -2.615257373542238721197930661559276546696 \cdot 10^{153}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\right)\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r15889 = b_2;
        double r15890 = -r15889;
        double r15891 = r15889 * r15889;
        double r15892 = a;
        double r15893 = c;
        double r15894 = r15892 * r15893;
        double r15895 = r15891 - r15894;
        double r15896 = sqrt(r15895);
        double r15897 = r15890 + r15896;
        double r15898 = r15897 / r15892;
        return r15898;
}

double f(double a, double b_2, double c) {
        double r15899 = b_2;
        double r15900 = -2.6152573735422387e+153;
        bool r15901 = r15899 <= r15900;
        double r15902 = c;
        double r15903 = r15902 / r15899;
        double r15904 = 0.5;
        double r15905 = a;
        double r15906 = r15899 / r15905;
        double r15907 = -2.0;
        double r15908 = r15906 * r15907;
        double r15909 = fma(r15903, r15904, r15908);
        double r15910 = 1.3880700472259379e-143;
        bool r15911 = r15899 <= r15910;
        double r15912 = r15899 * r15899;
        double r15913 = r15905 * r15902;
        double r15914 = r15912 - r15913;
        double r15915 = sqrt(r15914);
        double r15916 = r15915 - r15899;
        double r15917 = r15916 / r15905;
        double r15918 = -0.5;
        double r15919 = r15918 * r15903;
        double r15920 = r15911 ? r15917 : r15919;
        double r15921 = r15901 ? r15909 : r15920;
        return r15921;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b_2 < -2.6152573735422387e+153

    1. Initial program 63.8

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified63.8

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied clear-num63.8

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity63.8

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    9. Applied add-cube-cbrt63.8

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    13. Taylor expanded around -inf 2.1

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

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

    if -2.6152573735422387e+153 < b_2 < 1.3880700472259379e-143

    1. Initial program 11.4

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified11.4

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied clear-num11.6

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity11.6

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    9. Applied add-cube-cbrt11.6

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{1}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    11. Simplified11.6

      \[\leadsto \color{blue}{1} \cdot \frac{\sqrt[3]{1}}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\]
    12. Simplified11.4

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

    if 1.3880700472259379e-143 < b_2

    1. Initial program 50.2

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified50.2

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied clear-num50.2

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity50.2

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{1}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    11. Simplified50.2

      \[\leadsto \color{blue}{1} \cdot \frac{\sqrt[3]{1}}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\]
    12. Simplified50.2

      \[\leadsto 1 \cdot \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    13. Using strategy rm
    14. Applied div-inv50.2

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

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{-1}{2} \cdot \frac{c}{b_2}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.615257373542238721197930661559276546696 \cdot 10^{153}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\right)\\ \mathbf{elif}\;b_2 \le 1.388070047225937856958905133202240499626 \cdot 10^{-143}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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