Average Error: 15.1 → 0.2
Time: 21.7s
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.00000000134154998221447385731153190136:\\ \;\;\;\;\frac{\mathsf{fma}\left(0.25, \frac{\frac{x \cdot x}{1}}{\sqrt{1}}, 0.5 - \mathsf{fma}\left(\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}{{\left(\sqrt{1}\right)}^{5}}, 0.1875, \frac{0.5}{\sqrt{1}}\right)\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(1 \cdot 1\right) \cdot \left(\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right)\right) - \left(\left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)}{\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right) + \left(\left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right) + \left(1 \cdot 1\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\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}\;\mathsf{hypot}\left(1, x\right) \le 1.00000000134154998221447385731153190136:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.25, \frac{\frac{x \cdot x}{1}}{\sqrt{1}}, 0.5 - \mathsf{fma}\left(\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}{{\left(\sqrt{1}\right)}^{5}}, 0.1875, \frac{0.5}{\sqrt{1}}\right)\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(1 \cdot 1\right) \cdot \left(\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right)\right) - \left(\left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)}{\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right) + \left(\left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right) + \left(1 \cdot 1\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\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 r12505913 = 1.0;
        double r12505914 = 0.5;
        double r12505915 = x;
        double r12505916 = hypot(r12505913, r12505915);
        double r12505917 = r12505913 / r12505916;
        double r12505918 = r12505913 + r12505917;
        double r12505919 = r12505914 * r12505918;
        double r12505920 = sqrt(r12505919);
        double r12505921 = r12505913 - r12505920;
        return r12505921;
}

double f(double x) {
        double r12505922 = 1.0;
        double r12505923 = x;
        double r12505924 = hypot(r12505922, r12505923);
        double r12505925 = 1.00000000134155;
        bool r12505926 = r12505924 <= r12505925;
        double r12505927 = 0.25;
        double r12505928 = r12505923 * r12505923;
        double r12505929 = r12505928 / r12505922;
        double r12505930 = sqrt(r12505922);
        double r12505931 = r12505929 / r12505930;
        double r12505932 = 0.5;
        double r12505933 = r12505928 * r12505928;
        double r12505934 = 5.0;
        double r12505935 = pow(r12505930, r12505934);
        double r12505936 = r12505933 / r12505935;
        double r12505937 = 0.1875;
        double r12505938 = r12505932 / r12505930;
        double r12505939 = fma(r12505936, r12505937, r12505938);
        double r12505940 = r12505932 - r12505939;
        double r12505941 = fma(r12505927, r12505931, r12505940);
        double r12505942 = r12505922 / r12505924;
        double r12505943 = r12505922 + r12505942;
        double r12505944 = r12505932 * r12505943;
        double r12505945 = sqrt(r12505944);
        double r12505946 = r12505922 + r12505945;
        double r12505947 = r12505941 / r12505946;
        double r12505948 = r12505922 * r12505922;
        double r12505949 = r12505948 * r12505948;
        double r12505950 = r12505948 * r12505949;
        double r12505951 = r12505944 * r12505944;
        double r12505952 = r12505951 * r12505944;
        double r12505953 = r12505950 - r12505952;
        double r12505954 = r12505948 * r12505944;
        double r12505955 = r12505951 + r12505954;
        double r12505956 = r12505949 + r12505955;
        double r12505957 = r12505953 / r12505956;
        double r12505958 = r12505957 / r12505946;
        double r12505959 = r12505926 ? r12505947 : r12505958;
        return r12505959;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 29.5

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot 1 - 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)}}\]
    5. Taylor expanded around 0 29.5

      \[\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{\frac{x \cdot x}{1}}{\sqrt{1}}, 0.5 - \mathsf{fma}\left(\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}{{\left(\sqrt{1}\right)}^{5}}, 0.1875, \frac{0.5}{\sqrt{1}}\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]

    if 1.00000000134155 < (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}{1 \cdot 1 - 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)}}\]
    5. Using strategy rm
    6. Applied flip3--0.2

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

      \[\leadsto \frac{\frac{\color{blue}{\left(1 \cdot 1\right) \cdot \left(\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right)\right) - \left(\left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)}}{\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right) + \left(\left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right) + \left(1 \cdot 1\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\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.00000000134154998221447385731153190136:\\ \;\;\;\;\frac{\mathsf{fma}\left(0.25, \frac{\frac{x \cdot x}{1}}{\sqrt{1}}, 0.5 - \mathsf{fma}\left(\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}{{\left(\sqrt{1}\right)}^{5}}, 0.1875, \frac{0.5}{\sqrt{1}}\right)\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(1 \cdot 1\right) \cdot \left(\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right)\right) - \left(\left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)}{\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right) + \left(\left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right) + \left(1 \cdot 1\right) \cdot \left(0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \end{array}\]

Reproduce

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