Average Error: 15.1 → 0.4
Time: 8.5s
Precision: 64
\[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.00303917109191770242:\\ \;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \mathbf{elif}\;x \le 0.521686422125491212:\\ \;\;\;\;\frac{\mathsf{fma}\left(0.25, \frac{{x}^{2}}{{\left(\sqrt{1}\right)}^{3}}, 0.5 - \mathsf{fma}\left(0.5, \frac{1}{\sqrt{1}}, 0.1875 \cdot \frac{{x}^{4}}{{\left(\sqrt{1}\right)}^{5}}\right)\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{\mathsf{fma}\left(0.5, \frac{\sqrt{0.5}}{x \cdot \sqrt{1}}, \mathsf{fma}\left(\sqrt{1}, \sqrt{0.5}, 1\right) - 0.125 \cdot \frac{\sqrt{0.5}}{{x}^{2} \cdot {\left(\sqrt{1}\right)}^{3}}\right)}\\ \end{array}\]
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\begin{array}{l}
\mathbf{if}\;x \le -0.00303917109191770242:\\
\;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\

\mathbf{elif}\;x \le 0.521686422125491212:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.25, \frac{{x}^{2}}{{\left(\sqrt{1}\right)}^{3}}, 0.5 - \mathsf{fma}\left(0.5, \frac{1}{\sqrt{1}}, 0.1875 \cdot \frac{{x}^{4}}{{\left(\sqrt{1}\right)}^{5}}\right)\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\

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

\end{array}
double f(double x) {
        double r321375 = 1.0;
        double r321376 = 0.5;
        double r321377 = x;
        double r321378 = hypot(r321375, r321377);
        double r321379 = r321375 / r321378;
        double r321380 = r321375 + r321379;
        double r321381 = r321376 * r321380;
        double r321382 = sqrt(r321381);
        double r321383 = r321375 - r321382;
        return r321383;
}

double f(double x) {
        double r321384 = x;
        double r321385 = -0.0030391710919177024;
        bool r321386 = r321384 <= r321385;
        double r321387 = 0.5;
        double r321388 = -r321387;
        double r321389 = 1.0;
        double r321390 = hypot(r321389, r321384);
        double r321391 = r321389 / r321390;
        double r321392 = r321389 + r321391;
        double r321393 = r321389 * r321389;
        double r321394 = fma(r321388, r321392, r321393);
        double r321395 = exp(r321394);
        double r321396 = log(r321395);
        double r321397 = r321387 * r321392;
        double r321398 = sqrt(r321397);
        double r321399 = r321389 + r321398;
        double r321400 = r321396 / r321399;
        double r321401 = 0.5216864221254912;
        bool r321402 = r321384 <= r321401;
        double r321403 = 0.25;
        double r321404 = 2.0;
        double r321405 = pow(r321384, r321404);
        double r321406 = sqrt(r321389);
        double r321407 = 3.0;
        double r321408 = pow(r321406, r321407);
        double r321409 = r321405 / r321408;
        double r321410 = 1.0;
        double r321411 = r321410 / r321406;
        double r321412 = 0.1875;
        double r321413 = 4.0;
        double r321414 = pow(r321384, r321413);
        double r321415 = 5.0;
        double r321416 = pow(r321406, r321415);
        double r321417 = r321414 / r321416;
        double r321418 = r321412 * r321417;
        double r321419 = fma(r321387, r321411, r321418);
        double r321420 = r321387 - r321419;
        double r321421 = fma(r321403, r321409, r321420);
        double r321422 = r321421 / r321399;
        double r321423 = sqrt(r321387);
        double r321424 = r321384 * r321406;
        double r321425 = r321423 / r321424;
        double r321426 = fma(r321406, r321423, r321389);
        double r321427 = 0.125;
        double r321428 = r321405 * r321408;
        double r321429 = r321423 / r321428;
        double r321430 = r321427 * r321429;
        double r321431 = r321426 - r321430;
        double r321432 = fma(r321387, r321425, r321431);
        double r321433 = r321394 / r321432;
        double r321434 = r321402 ? r321422 : r321433;
        double r321435 = r321386 ? r321400 : r321434;
        return r321435;
}

Error

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if x < -0.0030391710919177024

    1. Initial program 1.0

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

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

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

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

    if -0.0030391710919177024 < x < 0.5216864221254912

    1. Initial program 29.2

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

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

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

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

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

    if 0.5216864221254912 < x

    1. Initial program 1.0

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{\color{blue}{\mathsf{fma}\left(0.5, \frac{\sqrt{0.5}}{x \cdot \sqrt{1}}, \mathsf{fma}\left(\sqrt{1}, \sqrt{0.5}, 1\right) - 0.125 \cdot \frac{\sqrt{0.5}}{{x}^{2} \cdot {\left(\sqrt{1}\right)}^{3}}\right)}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.00303917109191770242:\\ \;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \mathbf{elif}\;x \le 0.521686422125491212:\\ \;\;\;\;\frac{\mathsf{fma}\left(0.25, \frac{{x}^{2}}{{\left(\sqrt{1}\right)}^{3}}, 0.5 - \mathsf{fma}\left(0.5, \frac{1}{\sqrt{1}}, 0.1875 \cdot \frac{{x}^{4}}{{\left(\sqrt{1}\right)}^{5}}\right)\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{\mathsf{fma}\left(0.5, \frac{\sqrt{0.5}}{x \cdot \sqrt{1}}, \mathsf{fma}\left(\sqrt{1}, \sqrt{0.5}, 1\right) - 0.125 \cdot \frac{\sqrt{0.5}}{{x}^{2} \cdot {\left(\sqrt{1}\right)}^{3}}\right)}\\ \end{array}\]

Reproduce

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