Average Error: 15.2 → 0.1
Time: 15.0s
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.0000019089260588:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{8}, x \cdot x, \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(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{-11}{128}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\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)}{1 + \left(\left(\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}\right) + \sqrt{\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.0000019089260588:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{8}, x \cdot x, \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(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{-11}{128}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\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)}{1 + \left(\left(\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}\right) + \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}\right)}\\

\end{array}
double f(double x) {
        double r2121284 = 1.0;
        double r2121285 = 0.5;
        double r2121286 = x;
        double r2121287 = hypot(r2121284, r2121286);
        double r2121288 = r2121284 / r2121287;
        double r2121289 = r2121284 + r2121288;
        double r2121290 = r2121285 * r2121289;
        double r2121291 = sqrt(r2121290);
        double r2121292 = r2121284 - r2121291;
        return r2121292;
}

double f(double x) {
        double r2121293 = 1.0;
        double r2121294 = x;
        double r2121295 = hypot(r2121293, r2121294);
        double r2121296 = 1.0000019089260588;
        bool r2121297 = r2121295 <= r2121296;
        double r2121298 = 0.125;
        double r2121299 = r2121294 * r2121294;
        double r2121300 = r2121299 * r2121294;
        double r2121301 = r2121300 * r2121300;
        double r2121302 = 0.0673828125;
        double r2121303 = r2121299 * r2121299;
        double r2121304 = -0.0859375;
        double r2121305 = r2121303 * r2121304;
        double r2121306 = fma(r2121301, r2121302, r2121305);
        double r2121307 = fma(r2121298, r2121299, r2121306);
        double r2121308 = 0.5;
        double r2121309 = r2121308 / r2121295;
        double r2121310 = r2121308 + r2121309;
        double r2121311 = sqrt(r2121310);
        double r2121312 = r2121311 * r2121310;
        double r2121313 = r2121293 - r2121312;
        double r2121314 = r2121310 + r2121311;
        double r2121315 = r2121293 + r2121314;
        double r2121316 = r2121313 / r2121315;
        double r2121317 = r2121297 ? r2121307 : r2121316;
        return r2121317;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 29.9

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

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

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

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

    if 1.0000019089260588 < (hypot 1 x)

    1. Initial program 1.0

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

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

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

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

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

Reproduce

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