Average Error: 15.3 → 0.0
Time: 19.1s
Precision: 64
\[1 - \sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.011425002398452691:\\ \;\;\;\;\frac{\left(1 - \frac{1}{2}\right) - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \log \left(e^{\sqrt{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} + \frac{1}{2}}}\right)}\\ \mathbf{elif}\;x \le 0.012425117573170321:\\ \;\;\;\;\mathsf{fma}\left(x, x \cdot \frac{1}{8}, {x}^{6} \cdot \frac{69}{1024} - {x}^{4} \cdot \frac{11}{128}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(1 - \frac{1}{2}\right) - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \log \left(e^{\sqrt{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} + \frac{1}{2}}}\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}\;x \le -0.011425002398452691:\\
\;\;\;\;\frac{\left(1 - \frac{1}{2}\right) - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \log \left(e^{\sqrt{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} + \frac{1}{2}}}\right)}\\

\mathbf{elif}\;x \le 0.012425117573170321:\\
\;\;\;\;\mathsf{fma}\left(x, x \cdot \frac{1}{8}, {x}^{6} \cdot \frac{69}{1024} - {x}^{4} \cdot \frac{11}{128}\right)\\

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

\end{array}
double f(double x) {
        double r5211285 = 1.0;
        double r5211286 = 0.5;
        double r5211287 = x;
        double r5211288 = hypot(r5211285, r5211287);
        double r5211289 = r5211285 / r5211288;
        double r5211290 = r5211285 + r5211289;
        double r5211291 = r5211286 * r5211290;
        double r5211292 = sqrt(r5211291);
        double r5211293 = r5211285 - r5211292;
        return r5211293;
}

double f(double x) {
        double r5211294 = x;
        double r5211295 = -0.011425002398452691;
        bool r5211296 = r5211294 <= r5211295;
        double r5211297 = 1.0;
        double r5211298 = 0.5;
        double r5211299 = r5211297 - r5211298;
        double r5211300 = hypot(r5211297, r5211294);
        double r5211301 = r5211298 / r5211300;
        double r5211302 = r5211299 - r5211301;
        double r5211303 = r5211301 + r5211298;
        double r5211304 = sqrt(r5211303);
        double r5211305 = exp(r5211304);
        double r5211306 = log(r5211305);
        double r5211307 = r5211297 + r5211306;
        double r5211308 = r5211302 / r5211307;
        double r5211309 = 0.012425117573170321;
        bool r5211310 = r5211294 <= r5211309;
        double r5211311 = 0.125;
        double r5211312 = r5211294 * r5211311;
        double r5211313 = 6.0;
        double r5211314 = pow(r5211294, r5211313);
        double r5211315 = 0.0673828125;
        double r5211316 = r5211314 * r5211315;
        double r5211317 = 4.0;
        double r5211318 = pow(r5211294, r5211317);
        double r5211319 = 0.0859375;
        double r5211320 = r5211318 * r5211319;
        double r5211321 = r5211316 - r5211320;
        double r5211322 = fma(r5211294, r5211312, r5211321);
        double r5211323 = r5211310 ? r5211322 : r5211308;
        double r5211324 = r5211296 ? r5211308 : r5211323;
        return r5211324;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.011425002398452691 or 0.012425117573170321 < 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{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} + \frac{1}{2}}}\]
    3. Using strategy rm
    4. Applied flip--1.0

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

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

      \[\leadsto \frac{\left(1 - \frac{1}{2}\right) - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \color{blue}{\log \left(e^{\sqrt{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} + \frac{1}{2}}}\right)}}\]

    if -0.011425002398452691 < x < 0.012425117573170321

    1. Initial program 29.5

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

      \[\leadsto \color{blue}{1 - \sqrt{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} + \frac{1}{2}}}\]
    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(\frac{1}{8}, x \cdot x, {x}^{6} \cdot \frac{69}{1024}\right) - \frac{11}{128} \cdot {x}^{4}}\]
    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(x, \frac{1}{8} \cdot x, {x}^{6} \cdot \frac{69}{1024} - {x}^{4} \cdot \frac{11}{128}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

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

Reproduce

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