Average Error: 15.2 → 0.2
Time: 6.3s
Precision: 64
\[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.002644665746504805490385558996990766900126:\\ \;\;\;\;\frac{e^{\log \left(\mathsf{fma}\left(-0.5, 1 + \sqrt[3]{{\left(\frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}^{3}}, 1 \cdot 1\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \mathbf{elif}\;x \le 1.407700356222629204001883795882577032899 \cdot 10^{-4}:\\ \;\;\;\;\frac{\mathsf{fma}\left(0.25, \frac{{x}^{2}}{{\left(\sqrt{1}\right)}^{3}}, 0.5 - \mathsf{fma}\left(0.5, \frac{1}{\sqrt{1}}, 0.1875 \cdot \frac{{x}^{4}}{{\left(\sqrt{1}\right)}^{5}}\right)\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{\log \left(\log \left(e^{\left(\frac{1}{\mathsf{hypot}\left(1, x\right)} + 1\right) \cdot \left(-0.5\right) + 1 \cdot 1}\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \end{array}\]
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\begin{array}{l}
\mathbf{if}\;x \le -0.002644665746504805490385558996990766900126:\\
\;\;\;\;\frac{e^{\log \left(\mathsf{fma}\left(-0.5, 1 + \sqrt[3]{{\left(\frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}^{3}}, 1 \cdot 1\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\

\mathbf{elif}\;x \le 1.407700356222629204001883795882577032899 \cdot 10^{-4}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.25, \frac{{x}^{2}}{{\left(\sqrt{1}\right)}^{3}}, 0.5 - \mathsf{fma}\left(0.5, \frac{1}{\sqrt{1}}, 0.1875 \cdot \frac{{x}^{4}}{{\left(\sqrt{1}\right)}^{5}}\right)\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{e^{\log \left(\log \left(e^{\left(\frac{1}{\mathsf{hypot}\left(1, x\right)} + 1\right) \cdot \left(-0.5\right) + 1 \cdot 1}\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\

\end{array}
double f(double x) {
        double r289799 = 1.0;
        double r289800 = 0.5;
        double r289801 = x;
        double r289802 = hypot(r289799, r289801);
        double r289803 = r289799 / r289802;
        double r289804 = r289799 + r289803;
        double r289805 = r289800 * r289804;
        double r289806 = sqrt(r289805);
        double r289807 = r289799 - r289806;
        return r289807;
}

double f(double x) {
        double r289808 = x;
        double r289809 = -0.0026446657465048055;
        bool r289810 = r289808 <= r289809;
        double r289811 = 0.5;
        double r289812 = -r289811;
        double r289813 = 1.0;
        double r289814 = hypot(r289813, r289808);
        double r289815 = r289813 / r289814;
        double r289816 = 3.0;
        double r289817 = pow(r289815, r289816);
        double r289818 = cbrt(r289817);
        double r289819 = r289813 + r289818;
        double r289820 = r289813 * r289813;
        double r289821 = fma(r289812, r289819, r289820);
        double r289822 = log(r289821);
        double r289823 = exp(r289822);
        double r289824 = r289813 + r289815;
        double r289825 = r289811 * r289824;
        double r289826 = sqrt(r289825);
        double r289827 = r289813 + r289826;
        double r289828 = r289823 / r289827;
        double r289829 = 0.00014077003562226292;
        bool r289830 = r289808 <= r289829;
        double r289831 = 0.25;
        double r289832 = 2.0;
        double r289833 = pow(r289808, r289832);
        double r289834 = sqrt(r289813);
        double r289835 = pow(r289834, r289816);
        double r289836 = r289833 / r289835;
        double r289837 = 1.0;
        double r289838 = r289837 / r289834;
        double r289839 = 0.1875;
        double r289840 = 4.0;
        double r289841 = pow(r289808, r289840);
        double r289842 = 5.0;
        double r289843 = pow(r289834, r289842);
        double r289844 = r289841 / r289843;
        double r289845 = r289839 * r289844;
        double r289846 = fma(r289811, r289838, r289845);
        double r289847 = r289811 - r289846;
        double r289848 = fma(r289831, r289836, r289847);
        double r289849 = r289848 / r289827;
        double r289850 = r289815 + r289813;
        double r289851 = r289850 * r289812;
        double r289852 = r289851 + r289820;
        double r289853 = exp(r289852);
        double r289854 = log(r289853);
        double r289855 = log(r289854);
        double r289856 = exp(r289855);
        double r289857 = r289856 / r289827;
        double r289858 = r289830 ? r289849 : r289857;
        double r289859 = r289810 ? r289828 : r289858;
        return r289859;
}

Error

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if x < -0.0026446657465048055

    1. Initial program 1.1

      \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
    2. Using strategy rm
    3. Applied flip--1.1

      \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \cdot \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}\]
    4. Simplified0.1

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    5. Using strategy rm
    6. Applied add-exp-log0.1

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)\right)}}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    7. Using strategy rm
    8. Applied add-cbrt-cube0.1

      \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(-0.5, 1 + \frac{1}{\color{blue}{\sqrt[3]{\left(\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)\right) \cdot \mathsf{hypot}\left(1, x\right)}}}, 1 \cdot 1\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    9. Applied add-cbrt-cube0.1

      \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(-0.5, 1 + \frac{\color{blue}{\sqrt[3]{\left(1 \cdot 1\right) \cdot 1}}}{\sqrt[3]{\left(\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)\right) \cdot \mathsf{hypot}\left(1, x\right)}}, 1 \cdot 1\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    10. Applied cbrt-undiv0.1

      \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(-0.5, 1 + \color{blue}{\sqrt[3]{\frac{\left(1 \cdot 1\right) \cdot 1}{\left(\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)\right) \cdot \mathsf{hypot}\left(1, x\right)}}}, 1 \cdot 1\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    11. Simplified0.1

      \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(-0.5, 1 + \sqrt[3]{\color{blue}{{\left(\frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}^{3}}}, 1 \cdot 1\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]

    if -0.0026446657465048055 < x < 0.00014077003562226292

    1. Initial program 30.0

      \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
    2. Using strategy rm
    3. Applied flip--30.0

      \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \cdot \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}\]
    4. Simplified29.9

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    5. Taylor expanded around 0 29.9

      \[\leadsto \frac{\color{blue}{\left(0.25 \cdot \frac{{x}^{2}}{{\left(\sqrt{1}\right)}^{3}} + 0.5\right) - \left(0.5 \cdot \frac{1}{\sqrt{1}} + 0.1875 \cdot \frac{{x}^{4}}{{\left(\sqrt{1}\right)}^{5}}\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    6. Simplified0.3

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(0.25, \frac{{x}^{2}}{{\left(\sqrt{1}\right)}^{3}}, 0.5 - \mathsf{fma}\left(0.5, \frac{1}{\sqrt{1}}, 0.1875 \cdot \frac{{x}^{4}}{{\left(\sqrt{1}\right)}^{5}}\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]

    if 0.00014077003562226292 < x

    1. Initial program 1.2

      \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
    2. Using strategy rm
    3. Applied flip--1.2

      \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \cdot \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}\]
    4. Simplified0.2

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    5. Using strategy rm
    6. Applied add-exp-log0.2

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)\right)}}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    7. Using strategy rm
    8. Applied add-cbrt-cube0.2

      \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(-0.5, 1 + \frac{1}{\color{blue}{\sqrt[3]{\left(\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)\right) \cdot \mathsf{hypot}\left(1, x\right)}}}, 1 \cdot 1\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    9. Applied add-cbrt-cube0.2

      \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(-0.5, 1 + \frac{\color{blue}{\sqrt[3]{\left(1 \cdot 1\right) \cdot 1}}}{\sqrt[3]{\left(\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)\right) \cdot \mathsf{hypot}\left(1, x\right)}}, 1 \cdot 1\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    10. Applied cbrt-undiv0.2

      \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(-0.5, 1 + \color{blue}{\sqrt[3]{\frac{\left(1 \cdot 1\right) \cdot 1}{\left(\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)\right) \cdot \mathsf{hypot}\left(1, x\right)}}}, 1 \cdot 1\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    11. Simplified0.2

      \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(-0.5, 1 + \sqrt[3]{\color{blue}{{\left(\frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}^{3}}}, 1 \cdot 1\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    12. Using strategy rm
    13. Applied add-log-exp0.2

      \[\leadsto \frac{e^{\log \color{blue}{\left(\log \left(e^{\mathsf{fma}\left(-0.5, 1 + \sqrt[3]{{\left(\frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}^{3}}, 1 \cdot 1\right)}\right)\right)}}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    14. Simplified0.2

      \[\leadsto \frac{e^{\log \left(\log \color{blue}{\left(e^{\left(\frac{1}{\mathsf{hypot}\left(1, x\right)} + 1\right) \cdot \left(-0.5\right) + 1 \cdot 1}\right)}\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.002644665746504805490385558996990766900126:\\ \;\;\;\;\frac{e^{\log \left(\mathsf{fma}\left(-0.5, 1 + \sqrt[3]{{\left(\frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}^{3}}, 1 \cdot 1\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \mathbf{elif}\;x \le 1.407700356222629204001883795882577032899 \cdot 10^{-4}:\\ \;\;\;\;\frac{\mathsf{fma}\left(0.25, \frac{{x}^{2}}{{\left(\sqrt{1}\right)}^{3}}, 0.5 - \mathsf{fma}\left(0.5, \frac{1}{\sqrt{1}}, 0.1875 \cdot \frac{{x}^{4}}{{\left(\sqrt{1}\right)}^{5}}\right)\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{\log \left(\log \left(e^{\left(\frac{1}{\mathsf{hypot}\left(1, x\right)} + 1\right) \cdot \left(-0.5\right) + 1 \cdot 1}\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019344 +o rules:numerics
(FPCore (x)
  :name "Given's Rotation SVD example, simplified"
  :precision binary64
  (- 1 (sqrt (* 0.5 (+ 1 (/ 1 (hypot 1 x)))))))