Average Error: 15.3 → 0.2
Time: 15.4s
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.0000000000000075:\\ \;\;\;\;\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{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}} \cdot \sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}} \cdot \left(\frac{\sqrt[3]{1}}{\sqrt{\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}} \cdot \frac{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{\sqrt{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\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.0000000000000075:\\
\;\;\;\;\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{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}} \cdot \sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}} \cdot \left(\frac{\sqrt[3]{1}}{\sqrt{\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}} \cdot \frac{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{\sqrt{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}\right)\\

\end{array}
double f(double x) {
        double r405490 = 1.0;
        double r405491 = 0.5;
        double r405492 = x;
        double r405493 = hypot(r405490, r405492);
        double r405494 = r405490 / r405493;
        double r405495 = r405490 + r405494;
        double r405496 = r405491 * r405495;
        double r405497 = sqrt(r405496);
        double r405498 = r405490 - r405497;
        return r405498;
}

double f(double x) {
        double r405499 = 1.0;
        double r405500 = x;
        double r405501 = hypot(r405499, r405500);
        double r405502 = 1.0000000000000075;
        bool r405503 = r405501 <= r405502;
        double r405504 = 0.25;
        double r405505 = 2.0;
        double r405506 = pow(r405500, r405505);
        double r405507 = sqrt(r405499);
        double r405508 = 3.0;
        double r405509 = pow(r405507, r405508);
        double r405510 = r405506 / r405509;
        double r405511 = 0.5;
        double r405512 = 1.0;
        double r405513 = r405512 / r405507;
        double r405514 = 0.1875;
        double r405515 = 4.0;
        double r405516 = pow(r405500, r405515);
        double r405517 = 5.0;
        double r405518 = pow(r405507, r405517);
        double r405519 = r405516 / r405518;
        double r405520 = r405514 * r405519;
        double r405521 = fma(r405511, r405513, r405520);
        double r405522 = r405511 - r405521;
        double r405523 = fma(r405504, r405510, r405522);
        double r405524 = r405499 / r405501;
        double r405525 = r405499 + r405524;
        double r405526 = r405511 * r405525;
        double r405527 = sqrt(r405526);
        double r405528 = r405499 + r405527;
        double r405529 = r405523 / r405528;
        double r405530 = cbrt(r405512);
        double r405531 = r405530 * r405530;
        double r405532 = cbrt(r405528);
        double r405533 = r405532 * r405532;
        double r405534 = sqrt(r405533);
        double r405535 = r405531 / r405534;
        double r405536 = sqrt(r405532);
        double r405537 = r405530 / r405536;
        double r405538 = -r405511;
        double r405539 = r405499 * r405499;
        double r405540 = fma(r405538, r405525, r405539);
        double r405541 = sqrt(r405528);
        double r405542 = r405540 / r405541;
        double r405543 = r405537 * r405542;
        double r405544 = r405535 * r405543;
        double r405545 = r405503 ? r405529 : r405544;
        return r405545;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 29.5

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

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

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

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

      \[\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 1.0000000000000075 < (hypot 1.0 x)

    1. Initial program 1.4

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\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)}}}}\]
    7. Applied *-un-lft-identity1.4

      \[\leadsto \frac{\color{blue}{1 \cdot \mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}}{\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)}}}\]
    8. Applied times-frac0.5

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

      \[\leadsto \frac{1}{\sqrt{\color{blue}{\left(\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}} \cdot \sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\right) \cdot \sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}}} \cdot \frac{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{\sqrt{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}\]
    11. Applied sqrt-prod0.5

      \[\leadsto \frac{1}{\color{blue}{\sqrt{\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}} \cdot \sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}} \cdot \sqrt{\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}}} \cdot \frac{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{\sqrt{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}\]
    12. Applied add-cube-cbrt0.5

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\sqrt{\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}} \cdot \sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}} \cdot \sqrt{\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}} \cdot \frac{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{\sqrt{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}\]
    13. Applied times-frac0.5

      \[\leadsto \color{blue}{\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}} \cdot \sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}} \cdot \frac{\sqrt[3]{1}}{\sqrt{\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}}\right)} \cdot \frac{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{\sqrt{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}\]
    14. Applied associate-*l*0.5

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}} \cdot \sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}} \cdot \left(\frac{\sqrt[3]{1}}{\sqrt{\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}} \cdot \frac{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{\sqrt{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\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.0000000000000075:\\ \;\;\;\;\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{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}} \cdot \sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}} \cdot \left(\frac{\sqrt[3]{1}}{\sqrt{\sqrt[3]{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}} \cdot \frac{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}{\sqrt{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}}\right)\\ \end{array}\]

Reproduce

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