Average Error: 15.6 → 0.3
Time: 20.5s
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.0000000000000193:\\ \;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right), \frac{-11}{128}, \mathsf{fma}\left(x \cdot x, \frac{1}{8}, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot \frac{69}{1024}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(1 - \sqrt{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}} \cdot \sqrt{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}\right) - \frac{1}{2}}{\sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}} + 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.0000000000000193:\\
\;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right), \frac{-11}{128}, \mathsf{fma}\left(x \cdot x, \frac{1}{8}, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot \frac{69}{1024}\right)\right)\\

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

\end{array}
double f(double x) {
        double r2255039 = 1.0;
        double r2255040 = 0.5;
        double r2255041 = x;
        double r2255042 = hypot(r2255039, r2255041);
        double r2255043 = r2255039 / r2255042;
        double r2255044 = r2255039 + r2255043;
        double r2255045 = r2255040 * r2255044;
        double r2255046 = sqrt(r2255045);
        double r2255047 = r2255039 - r2255046;
        return r2255047;
}

double f(double x) {
        double r2255048 = 1.0;
        double r2255049 = x;
        double r2255050 = hypot(r2255048, r2255049);
        double r2255051 = 1.0000000000000193;
        bool r2255052 = r2255050 <= r2255051;
        double r2255053 = r2255049 * r2255049;
        double r2255054 = r2255053 * r2255053;
        double r2255055 = -0.0859375;
        double r2255056 = 0.125;
        double r2255057 = r2255053 * r2255049;
        double r2255058 = r2255057 * r2255057;
        double r2255059 = 0.0673828125;
        double r2255060 = r2255058 * r2255059;
        double r2255061 = fma(r2255053, r2255056, r2255060);
        double r2255062 = fma(r2255054, r2255055, r2255061);
        double r2255063 = 0.5;
        double r2255064 = r2255063 / r2255050;
        double r2255065 = sqrt(r2255064);
        double r2255066 = r2255065 * r2255065;
        double r2255067 = r2255048 - r2255066;
        double r2255068 = r2255067 - r2255063;
        double r2255069 = r2255063 + r2255064;
        double r2255070 = sqrt(r2255069);
        double r2255071 = r2255070 + r2255048;
        double r2255072 = r2255068 / r2255071;
        double r2255073 = r2255052 ? r2255062 : r2255072;
        return r2255073;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 30.7

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

      \[\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 x\right) \cdot \left(x \cdot x\right), \frac{-11}{128}, \mathsf{fma}\left(x \cdot x, \frac{1}{8}, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot \frac{69}{1024}\right)\right)}\]

    if 1.0000000000000193 < (hypot 1 x)

    1. Initial program 1.4

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

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

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

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

      \[\leadsto \frac{\left(1 - \color{blue}{\sqrt{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}} \cdot \sqrt{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}\right) - \frac{1}{2}}{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.3

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

Reproduce

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