Average Error: 15.4 → 0.2
Time: 7.3s
Precision: 64
\[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
\[\begin{array}{l} \mathbf{if}\;\mathsf{hypot}\left(1, x\right) \le 1.00000002419962164:\\ \;\;\;\;\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{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{1 + \frac{\sqrt{0.5 \cdot \left(1 \cdot 1 - \frac{1}{\mathsf{hypot}\left(1, x\right)} \cdot \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}{\sqrt{1 - \frac{1}{\mathsf{hypot}\left(1, x\right)}}}}\\ \end{array}\]
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\begin{array}{l}
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \le 1.00000002419962164:\\
\;\;\;\;\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{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{1 + \frac{\sqrt{0.5 \cdot \left(1 \cdot 1 - \frac{1}{\mathsf{hypot}\left(1, x\right)} \cdot \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}{\sqrt{1 - \frac{1}{\mathsf{hypot}\left(1, x\right)}}}}\\

\end{array}
double f(double x) {
        double r283916 = 1.0;
        double r283917 = 0.5;
        double r283918 = x;
        double r283919 = hypot(r283916, r283918);
        double r283920 = r283916 / r283919;
        double r283921 = r283916 + r283920;
        double r283922 = r283917 * r283921;
        double r283923 = sqrt(r283922);
        double r283924 = r283916 - r283923;
        return r283924;
}

double f(double x) {
        double r283925 = 1.0;
        double r283926 = x;
        double r283927 = hypot(r283925, r283926);
        double r283928 = 1.0000000241996216;
        bool r283929 = r283927 <= r283928;
        double r283930 = 0.25;
        double r283931 = 2.0;
        double r283932 = pow(r283926, r283931);
        double r283933 = sqrt(r283925);
        double r283934 = 3.0;
        double r283935 = pow(r283933, r283934);
        double r283936 = r283932 / r283935;
        double r283937 = 0.5;
        double r283938 = 1.0;
        double r283939 = r283938 / r283933;
        double r283940 = 0.1875;
        double r283941 = 4.0;
        double r283942 = pow(r283926, r283941);
        double r283943 = 5.0;
        double r283944 = pow(r283933, r283943);
        double r283945 = r283942 / r283944;
        double r283946 = r283940 * r283945;
        double r283947 = fma(r283937, r283939, r283946);
        double r283948 = r283937 - r283947;
        double r283949 = fma(r283930, r283936, r283948);
        double r283950 = r283925 / r283927;
        double r283951 = r283925 + r283950;
        double r283952 = r283937 * r283951;
        double r283953 = sqrt(r283952);
        double r283954 = r283925 + r283953;
        double r283955 = r283949 / r283954;
        double r283956 = -r283937;
        double r283957 = r283925 * r283925;
        double r283958 = fma(r283956, r283951, r283957);
        double r283959 = r283950 * r283950;
        double r283960 = r283957 - r283959;
        double r283961 = r283937 * r283960;
        double r283962 = sqrt(r283961);
        double r283963 = r283925 - r283950;
        double r283964 = sqrt(r283963);
        double r283965 = r283962 / r283964;
        double r283966 = r283925 + r283965;
        double r283967 = r283958 / r283966;
        double r283968 = r283929 ? r283955 : r283967;
        return r283968;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if (hypot 1.0 x) < 1.0000000241996216

    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. Simplified30.0

      \[\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 30.0

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

      \[\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 1.0000000241996216 < (hypot 1.0 x)

    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.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 flip-+0.2

      \[\leadsto \frac{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{1 + \sqrt{0.5 \cdot \color{blue}{\frac{1 \cdot 1 - \frac{1}{\mathsf{hypot}\left(1, x\right)} \cdot \frac{1}{\mathsf{hypot}\left(1, x\right)}}{1 - \frac{1}{\mathsf{hypot}\left(1, x\right)}}}}}\]
    7. Applied associate-*r/0.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\mathsf{hypot}\left(1, x\right) \le 1.00000002419962164:\\ \;\;\;\;\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{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{1 + \frac{\sqrt{0.5 \cdot \left(1 \cdot 1 - \frac{1}{\mathsf{hypot}\left(1, x\right)} \cdot \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}{\sqrt{1 - \frac{1}{\mathsf{hypot}\left(1, x\right)}}}}\\ \end{array}\]

Reproduce

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