Average Error: 15.6 → 0.3
Time: 18.1s
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 -9.508968473805668765452825397233027615584 \cdot 10^{-4}:\\ \;\;\;\;\frac{1 \cdot 1 - \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right) \cdot 0.5}{1 + \sqrt{\left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right) \cdot 0.5}}\\ \mathbf{elif}\;x \le 0.9600273501121953101389294715772848576307:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{\frac{x \cdot x}{\sqrt{1}}}{1}, 0.25, 0.5 - \mathsf{fma}\left(0.1875, \frac{x \cdot x}{{\left(\sqrt{1}\right)}^{\frac{5}{2}}} \cdot \frac{x \cdot x}{{\left(\sqrt{1}\right)}^{\frac{5}{2}}}, \frac{0.5}{\sqrt{1}}\right)\right)}{1 + \sqrt{\left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right) \cdot 0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(0.5 - \frac{0.5}{x}\right) + \frac{\frac{0.25}{x}}{x \cdot x}}{1 + \sqrt{\left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right) \cdot 0.5}}\\ \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 -9.508968473805668765452825397233027615584 \cdot 10^{-4}:\\
\;\;\;\;\frac{1 \cdot 1 - \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right) \cdot 0.5}{1 + \sqrt{\left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right) \cdot 0.5}}\\

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

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

\end{array}
double f(double x) {
        double r11541583 = 1.0;
        double r11541584 = 0.5;
        double r11541585 = x;
        double r11541586 = hypot(r11541583, r11541585);
        double r11541587 = r11541583 / r11541586;
        double r11541588 = r11541583 + r11541587;
        double r11541589 = r11541584 * r11541588;
        double r11541590 = sqrt(r11541589);
        double r11541591 = r11541583 - r11541590;
        return r11541591;
}

double f(double x) {
        double r11541592 = x;
        double r11541593 = -0.0009508968473805669;
        bool r11541594 = r11541592 <= r11541593;
        double r11541595 = 1.0;
        double r11541596 = r11541595 * r11541595;
        double r11541597 = hypot(r11541595, r11541592);
        double r11541598 = r11541595 / r11541597;
        double r11541599 = r11541595 + r11541598;
        double r11541600 = 0.5;
        double r11541601 = r11541599 * r11541600;
        double r11541602 = r11541596 - r11541601;
        double r11541603 = sqrt(r11541601);
        double r11541604 = r11541595 + r11541603;
        double r11541605 = r11541602 / r11541604;
        double r11541606 = 0.9600273501121953;
        bool r11541607 = r11541592 <= r11541606;
        double r11541608 = r11541592 * r11541592;
        double r11541609 = sqrt(r11541595);
        double r11541610 = r11541608 / r11541609;
        double r11541611 = r11541610 / r11541595;
        double r11541612 = 0.25;
        double r11541613 = 0.1875;
        double r11541614 = 2.5;
        double r11541615 = pow(r11541609, r11541614);
        double r11541616 = r11541608 / r11541615;
        double r11541617 = r11541616 * r11541616;
        double r11541618 = r11541600 / r11541609;
        double r11541619 = fma(r11541613, r11541617, r11541618);
        double r11541620 = r11541600 - r11541619;
        double r11541621 = fma(r11541611, r11541612, r11541620);
        double r11541622 = r11541621 / r11541604;
        double r11541623 = r11541600 / r11541592;
        double r11541624 = r11541600 - r11541623;
        double r11541625 = r11541612 / r11541592;
        double r11541626 = r11541625 / r11541608;
        double r11541627 = r11541624 + r11541626;
        double r11541628 = r11541627 / r11541604;
        double r11541629 = r11541607 ? r11541622 : r11541628;
        double r11541630 = r11541594 ? r11541605 : r11541629;
        return r11541630;
}

Error

Bits error versus x

Derivation

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

    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}{1 \cdot 1 - 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)}}\]

    if -0.0009508968473805669 < x < 0.9600273501121953

    1. Initial program 30.0

      \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
    2. Using strategy rm
    3. Applied flip--30.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. Simplified30.0

      \[\leadsto \frac{\color{blue}{1 \cdot 1 - 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)}}\]
    5. Taylor expanded around 0 30.1

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

    if 0.9600273501121953 < 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}{1 \cdot 1 - 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)}}\]
    5. Taylor expanded around inf 0.3

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

      \[\leadsto \frac{\color{blue}{\frac{\frac{0.25}{x}}{x \cdot x} + \left(0.5 - \frac{0.5}{x}\right)}}{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.3

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

Reproduce

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