Average Error: 15.3 → 0.2
Time: 9.7s
Precision: 64
\[1 - \sqrt{0.5 \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.000000000001613:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{{x}^{2}}{{\left(\sqrt{1}\right)}^{3}}, 0.25, 0.5 - \mathsf{fma}\left(0.1875, \frac{{x}^{4}}{{\left(\sqrt{1}\right)}^{5}}, \frac{0.5}{\sqrt{1}}\right)\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 \cdot 1 - \left(1 + \frac{\frac{1}{\sqrt{\mathsf{hypot}\left(1, x\right)}}}{\sqrt{\mathsf{hypot}\left(1, x\right)}}\right) \cdot 0.5}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \end{array}\]
1 - \sqrt{0.5 \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.000000000001613:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{{x}^{2}}{{\left(\sqrt{1}\right)}^{3}}, 0.25, 0.5 - \mathsf{fma}\left(0.1875, \frac{{x}^{4}}{{\left(\sqrt{1}\right)}^{5}}, \frac{0.5}{\sqrt{1}}\right)\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\

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

\end{array}
double f(double x) {
        double r267381 = 1.0;
        double r267382 = 0.5;
        double r267383 = x;
        double r267384 = hypot(r267381, r267383);
        double r267385 = r267381 / r267384;
        double r267386 = r267381 + r267385;
        double r267387 = r267382 * r267386;
        double r267388 = sqrt(r267387);
        double r267389 = r267381 - r267388;
        return r267389;
}

double f(double x) {
        double r267390 = 1.0;
        double r267391 = x;
        double r267392 = hypot(r267390, r267391);
        double r267393 = 1.000000000001613;
        bool r267394 = r267392 <= r267393;
        double r267395 = 2.0;
        double r267396 = pow(r267391, r267395);
        double r267397 = sqrt(r267390);
        double r267398 = 3.0;
        double r267399 = pow(r267397, r267398);
        double r267400 = r267396 / r267399;
        double r267401 = 0.25;
        double r267402 = 0.5;
        double r267403 = 0.1875;
        double r267404 = 4.0;
        double r267405 = pow(r267391, r267404);
        double r267406 = 5.0;
        double r267407 = pow(r267397, r267406);
        double r267408 = r267405 / r267407;
        double r267409 = r267402 / r267397;
        double r267410 = fma(r267403, r267408, r267409);
        double r267411 = r267402 - r267410;
        double r267412 = fma(r267400, r267401, r267411);
        double r267413 = r267390 / r267392;
        double r267414 = r267390 + r267413;
        double r267415 = r267402 * r267414;
        double r267416 = sqrt(r267415);
        double r267417 = r267390 + r267416;
        double r267418 = r267412 / r267417;
        double r267419 = r267390 * r267390;
        double r267420 = sqrt(r267392);
        double r267421 = r267390 / r267420;
        double r267422 = r267421 / r267420;
        double r267423 = r267390 + r267422;
        double r267424 = r267423 * r267402;
        double r267425 = r267419 - r267424;
        double r267426 = r267425 / r267417;
        double r267427 = r267394 ? r267418 : r267426;
        return r267427;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 29.9

      \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
    2. Using strategy rm
    3. Applied flip--29.9

      \[\leadsto \color{blue}{\frac{1 \cdot 1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \cdot \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}\]
    4. Simplified29.9

      \[\leadsto \frac{\color{blue}{1 \cdot 1 - \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right) \cdot 0.5}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    5. Taylor expanded around 0 29.9

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{{x}^{2}}{{\left(\sqrt{1}\right)}^{3}}, 0.25, 0.5 - \mathsf{fma}\left(0.1875, \frac{{x}^{4}}{{\left(\sqrt{1}\right)}^{5}}, \frac{0.5}{\sqrt{1}}\right)\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]

    if 1.000000000001613 < (hypot 1.0 x)

    1. Initial program 1.3

      \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
    2. Using strategy rm
    3. Applied flip--1.3

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

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

      \[\leadsto \frac{1 \cdot 1 - \left(1 + \frac{1}{\color{blue}{\sqrt{\mathsf{hypot}\left(1, x\right)} \cdot \sqrt{\mathsf{hypot}\left(1, x\right)}}}\right) \cdot 0.5}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    7. Applied associate-/r*0.4

      \[\leadsto \frac{1 \cdot 1 - \left(1 + \color{blue}{\frac{\frac{1}{\sqrt{\mathsf{hypot}\left(1, x\right)}}}{\sqrt{\mathsf{hypot}\left(1, x\right)}}}\right) \cdot 0.5}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\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.000000000001613:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{{x}^{2}}{{\left(\sqrt{1}\right)}^{3}}, 0.25, 0.5 - \mathsf{fma}\left(0.1875, \frac{{x}^{4}}{{\left(\sqrt{1}\right)}^{5}}, \frac{0.5}{\sqrt{1}}\right)\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 \cdot 1 - \left(1 + \frac{\frac{1}{\sqrt{\mathsf{hypot}\left(1, x\right)}}}{\sqrt{\mathsf{hypot}\left(1, x\right)}}\right) \cdot 0.5}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \end{array}\]

Reproduce

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