Average Error: 15.7 → 0.1
Time: 37.9s
Precision: 64
\[1 - \sqrt{\frac{1}{2} \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.0000000001609424:\\ \;\;\;\;\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right), \frac{69}{1024}, \left(\frac{1}{8} - \left(x \cdot x\right) \cdot \frac{11}{128}\right) \cdot \left(x \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1}{4} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} \cdot \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} + \frac{1}{2}}}{\sqrt{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} + \frac{1}{2}} + 1}\\ \end{array}\]
1 - \sqrt{\frac{1}{2} \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.0000000001609424:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right), \frac{69}{1024}, \left(\frac{1}{8} - \left(x \cdot x\right) \cdot \frac{11}{128}\right) \cdot \left(x \cdot x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{4} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} \cdot \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} + \frac{1}{2}}}{\sqrt{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} + \frac{1}{2}} + 1}\\

\end{array}
double f(double x) {
        double r3518795 = 1.0;
        double r3518796 = 0.5;
        double r3518797 = x;
        double r3518798 = hypot(r3518795, r3518797);
        double r3518799 = r3518795 / r3518798;
        double r3518800 = r3518795 + r3518799;
        double r3518801 = r3518796 * r3518800;
        double r3518802 = sqrt(r3518801);
        double r3518803 = r3518795 - r3518802;
        return r3518803;
}

double f(double x) {
        double r3518804 = 1.0;
        double r3518805 = x;
        double r3518806 = hypot(r3518804, r3518805);
        double r3518807 = 1.0000000001609424;
        bool r3518808 = r3518806 <= r3518807;
        double r3518809 = r3518805 * r3518805;
        double r3518810 = r3518809 * r3518805;
        double r3518811 = r3518810 * r3518810;
        double r3518812 = 0.0673828125;
        double r3518813 = 0.125;
        double r3518814 = 0.0859375;
        double r3518815 = r3518809 * r3518814;
        double r3518816 = r3518813 - r3518815;
        double r3518817 = r3518816 * r3518809;
        double r3518818 = fma(r3518811, r3518812, r3518817);
        double r3518819 = 0.25;
        double r3518820 = 0.5;
        double r3518821 = r3518820 / r3518806;
        double r3518822 = r3518821 * r3518821;
        double r3518823 = r3518819 - r3518822;
        double r3518824 = r3518821 + r3518820;
        double r3518825 = r3518823 / r3518824;
        double r3518826 = sqrt(r3518824);
        double r3518827 = r3518826 + r3518804;
        double r3518828 = r3518825 / r3518827;
        double r3518829 = r3518808 ? r3518818 : r3518828;
        return r3518829;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 30.5

      \[1 - \sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
    2. Simplified30.5

      \[\leadsto \color{blue}{1 - \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}\]
    3. Taylor expanded around 0 0.0

      \[\leadsto \color{blue}{\left(\frac{1}{8} \cdot {x}^{2} + \frac{69}{1024} \cdot {x}^{6}\right) - \frac{11}{128} \cdot {x}^{4}}\]
    4. Simplified0.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(x \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot \left(x \cdot x\right)\right), \frac{69}{1024}, \left(x \cdot x\right) \cdot \left(\frac{1}{8} - \frac{11}{128} \cdot \left(x \cdot x\right)\right)\right)}\]

    if 1.0000000001609424 < (hypot 1 x)

    1. Initial program 1.2

      \[1 - \sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
    2. Simplified1.2

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{2} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}\]
    6. Using strategy rm
    7. Applied flip--0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\mathsf{hypot}\left(1, x\right) \le 1.0000000001609424:\\ \;\;\;\;\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right), \frac{69}{1024}, \left(\frac{1}{8} - \left(x \cdot x\right) \cdot \frac{11}{128}\right) \cdot \left(x \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1}{4} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} \cdot \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} + \frac{1}{2}}}{\sqrt{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} + \frac{1}{2}} + 1}\\ \end{array}\]

Reproduce

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