Average Error: 15.3 → 0.2
Time: 10.3s
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.00180314527098315142:\\ \;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left(1, 1, \left(-0.5\right) \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)}\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \mathbf{elif}\;x \le 0.0026989909516307821:\\ \;\;\;\;\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 \sqrt{1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(1, 1, \left(-0.5\right) \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)}{\sqrt{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}}{\sqrt{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}\;x \le -0.00180314527098315142:\\
\;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left(1, 1, \left(-0.5\right) \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)}\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\

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

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

\end{array}
double f(double x) {
        double r365424 = 1.0;
        double r365425 = 0.5;
        double r365426 = x;
        double r365427 = hypot(r365424, r365426);
        double r365428 = r365424 / r365427;
        double r365429 = r365424 + r365428;
        double r365430 = r365425 * r365429;
        double r365431 = sqrt(r365430);
        double r365432 = r365424 - r365431;
        return r365432;
}

double f(double x) {
        double r365433 = x;
        double r365434 = -0.0018031452709831514;
        bool r365435 = r365433 <= r365434;
        double r365436 = 1.0;
        double r365437 = 0.5;
        double r365438 = -r365437;
        double r365439 = hypot(r365436, r365433);
        double r365440 = r365436 / r365439;
        double r365441 = r365436 + r365440;
        double r365442 = r365438 * r365441;
        double r365443 = fma(r365436, r365436, r365442);
        double r365444 = exp(r365443);
        double r365445 = log(r365444);
        double r365446 = r365437 * r365441;
        double r365447 = sqrt(r365446);
        double r365448 = r365436 + r365447;
        double r365449 = r365445 / r365448;
        double r365450 = 0.002698990951630782;
        bool r365451 = r365433 <= r365450;
        double r365452 = 0.25;
        double r365453 = 2.0;
        double r365454 = pow(r365433, r365453);
        double r365455 = sqrt(r365436);
        double r365456 = 3.0;
        double r365457 = pow(r365455, r365456);
        double r365458 = r365454 / r365457;
        double r365459 = 1.0;
        double r365460 = r365459 / r365455;
        double r365461 = 0.1875;
        double r365462 = 4.0;
        double r365463 = pow(r365433, r365462);
        double r365464 = 5.0;
        double r365465 = pow(r365455, r365464);
        double r365466 = r365463 / r365465;
        double r365467 = r365461 * r365466;
        double r365468 = fma(r365437, r365460, r365467);
        double r365469 = r365437 - r365468;
        double r365470 = fma(r365452, r365458, r365469);
        double r365471 = sqrt(r365437);
        double r365472 = sqrt(r365441);
        double r365473 = r365471 * r365472;
        double r365474 = r365436 + r365473;
        double r365475 = r365470 / r365474;
        double r365476 = sqrt(r365448);
        double r365477 = r365443 / r365476;
        double r365478 = r365477 / r365476;
        double r365479 = r365451 ? r365475 : r365478;
        double r365480 = r365435 ? r365449 : r365479;
        return r365480;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 1.1

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

      \[\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(1, 1, \left(-0.5\right) \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\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(1, 1, \left(-0.5\right) \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)}\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]

    if -0.0018031452709831514 < x < 0.002698990951630782

    1. Initial program 29.8

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

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

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

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

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

      \[\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 \sqrt{1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}}}\]

    if 0.002698990951630782 < x

    1. Initial program 1.1

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

      \[\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(1, 1, \left(-0.5\right) \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\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(1, 1, \left(-0.5\right) \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)}\right)}}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt1.1

      \[\leadsto \frac{\log \left(e^{\mathsf{fma}\left(1, 1, \left(-0.5\right) \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)}\right)}{\color{blue}{\sqrt{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}} \cdot \sqrt{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}}\]
    9. Applied associate-/r*0.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.00180314527098315142:\\ \;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left(1, 1, \left(-0.5\right) \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)}\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\ \mathbf{elif}\;x \le 0.0026989909516307821:\\ \;\;\;\;\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 \sqrt{1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(1, 1, \left(-0.5\right) \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)\right)}{\sqrt{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}}{\sqrt{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}\\ \end{array}\]

Reproduce

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