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

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

\end{array}
double f(double x) {
        double r5063180 = 1.0;
        double r5063181 = 0.5;
        double r5063182 = x;
        double r5063183 = hypot(r5063180, r5063182);
        double r5063184 = r5063180 / r5063183;
        double r5063185 = r5063180 + r5063184;
        double r5063186 = r5063181 * r5063185;
        double r5063187 = sqrt(r5063186);
        double r5063188 = r5063180 - r5063187;
        return r5063188;
}

double f(double x) {
        double r5063189 = 1.0;
        double r5063190 = x;
        double r5063191 = hypot(r5063189, r5063190);
        double r5063192 = 1.000000000001137;
        bool r5063193 = r5063191 <= r5063192;
        double r5063194 = r5063190 * r5063190;
        double r5063195 = 0.125;
        double r5063196 = r5063194 * r5063194;
        double r5063197 = r5063196 * r5063194;
        double r5063198 = 0.0673828125;
        double r5063199 = -0.0859375;
        double r5063200 = r5063196 * r5063199;
        double r5063201 = fma(r5063197, r5063198, r5063200);
        double r5063202 = fma(r5063194, r5063195, r5063201);
        double r5063203 = 0.5;
        double r5063204 = r5063203 / r5063191;
        double r5063205 = r5063203 + r5063204;
        double r5063206 = sqrt(r5063205);
        double r5063207 = r5063205 * r5063206;
        double r5063208 = r5063189 - r5063207;
        double r5063209 = r5063206 + r5063189;
        double r5063210 = r5063209 + r5063205;
        double r5063211 = r5063208 / r5063210;
        double r5063212 = r5063193 ? r5063202 : r5063211;
        return r5063212;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 29.6

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

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

    if 1.000000000001137 < (hypot 1 x)

    1. Initial program 1.3

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

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

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

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

      \[\leadsto \frac{1 - \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}} \cdot \left(\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}\right)}{\color{blue}{\left(\sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}} + 1\right) + \left(\frac{1}{2} + \frac{\frac{1}{2}}{\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.000000000001137:\\ \;\;\;\;\mathsf{fma}\left(x \cdot x, \frac{1}{8}, \mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right), \frac{69}{1024}, \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{-11}{128}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - \left(\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}\right) \cdot \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}{\left(\sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}} + 1\right) + \left(\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}\right)}\\ \end{array}\]

Reproduce

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