Average Error: 15.5 → 0.0
Time: 15.0s
Precision: 64
\[1 - \sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.00990965624909386:\\ \;\;\;\;\frac{\frac{1}{2} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}\\ \mathbf{elif}\;x \le 0.011507891242233352:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{8}, \left(x \cdot x\right), \left(\mathsf{fma}\left(\frac{69}{1024}, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right), \left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{-11}{128}\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1}{8} - \frac{\frac{1}{8}}{\left(\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)\right) \cdot \mathsf{hypot}\left(1, x\right)}}{\mathsf{fma}\left(\left(\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}\right), \left(\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}\right), \frac{1}{4}\right)}}{1 + \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}\\ \end{array}\]
1 - \sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\begin{array}{l}
\mathbf{if}\;x \le -0.00990965624909386:\\
\;\;\;\;\frac{\frac{1}{2} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}\\

\mathbf{elif}\;x \le 0.011507891242233352:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{8}, \left(x \cdot x\right), \left(\mathsf{fma}\left(\frac{69}{1024}, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right), \left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{-11}{128}\right)\right)\right)\right)\\

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

\end{array}
double f(double x) {
        double r2071731 = 1.0;
        double r2071732 = 0.5;
        double r2071733 = x;
        double r2071734 = hypot(r2071731, r2071733);
        double r2071735 = r2071731 / r2071734;
        double r2071736 = r2071731 + r2071735;
        double r2071737 = r2071732 * r2071736;
        double r2071738 = sqrt(r2071737);
        double r2071739 = r2071731 - r2071738;
        return r2071739;
}

double f(double x) {
        double r2071740 = x;
        double r2071741 = -0.00990965624909386;
        bool r2071742 = r2071740 <= r2071741;
        double r2071743 = 0.5;
        double r2071744 = 1.0;
        double r2071745 = hypot(r2071744, r2071740);
        double r2071746 = r2071743 / r2071745;
        double r2071747 = r2071743 - r2071746;
        double r2071748 = r2071743 + r2071746;
        double r2071749 = sqrt(r2071748);
        double r2071750 = r2071744 + r2071749;
        double r2071751 = r2071747 / r2071750;
        double r2071752 = 0.011507891242233352;
        bool r2071753 = r2071740 <= r2071752;
        double r2071754 = 0.125;
        double r2071755 = r2071740 * r2071740;
        double r2071756 = 0.0673828125;
        double r2071757 = r2071755 * r2071740;
        double r2071758 = r2071757 * r2071757;
        double r2071759 = r2071755 * r2071755;
        double r2071760 = -0.0859375;
        double r2071761 = r2071759 * r2071760;
        double r2071762 = fma(r2071756, r2071758, r2071761);
        double r2071763 = fma(r2071754, r2071755, r2071762);
        double r2071764 = r2071745 * r2071745;
        double r2071765 = r2071764 * r2071745;
        double r2071766 = r2071754 / r2071765;
        double r2071767 = r2071754 - r2071766;
        double r2071768 = 0.25;
        double r2071769 = fma(r2071746, r2071748, r2071768);
        double r2071770 = r2071767 / r2071769;
        double r2071771 = r2071770 / r2071750;
        double r2071772 = r2071753 ? r2071763 : r2071771;
        double r2071773 = r2071742 ? r2071751 : r2071772;
        return r2071773;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 1.0

      \[1 - \sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
    2. Simplified1.0

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

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

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

      \[\leadsto \frac{1 - \left(\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}\right)}{\color{blue}{1 + \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}}\]
    7. Using strategy rm
    8. Applied associate--r+0.1

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

      \[\leadsto \frac{\color{blue}{\frac{1}{2}} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}\]

    if -0.00990965624909386 < x < 0.011507891242233352

    1. Initial program 29.9

      \[1 - \sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
    2. Simplified29.9

      \[\leadsto \color{blue}{1 - \sqrt{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)} + \frac{1}{2}}}\]
    3. Taylor expanded around 0 0.0

      \[\leadsto \color{blue}{\left(\frac{1}{8} \cdot {x}^{2} + \frac{69}{1024} \cdot {x}^{6}\right) - \frac{11}{128} \cdot {x}^{4}}\]
    4. Simplified0.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{8}, \left(x \cdot x\right), \left(\mathsf{fma}\left(\frac{69}{1024}, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right), \left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{-11}{128}\right)\right)\right)\right)}\]

    if 0.011507891242233352 < x

    1. Initial program 1.0

      \[1 - \sqrt{\frac{1}{2} \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\]
    2. Simplified1.0

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

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

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

      \[\leadsto \frac{1 - \left(\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}\right)}{\color{blue}{1 + \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}}\]
    7. Using strategy rm
    8. Applied associate--r+0.0

      \[\leadsto \frac{\color{blue}{\left(1 - \frac{1}{2}\right) - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}\]
    9. Simplified0.0

      \[\leadsto \frac{\color{blue}{\frac{1}{2}} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}\]
    10. Using strategy rm
    11. Applied flip3--0.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.00990965624909386:\\ \;\;\;\;\frac{\frac{1}{2} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}\\ \mathbf{elif}\;x \le 0.011507891242233352:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{8}, \left(x \cdot x\right), \left(\mathsf{fma}\left(\frac{69}{1024}, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right), \left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{-11}{128}\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1}{8} - \frac{\frac{1}{8}}{\left(\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)\right) \cdot \mathsf{hypot}\left(1, x\right)}}{\mathsf{fma}\left(\left(\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}\right), \left(\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}\right), \frac{1}{4}\right)}}{1 + \sqrt{\frac{1}{2} + \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}}\\ \end{array}\]

Reproduce

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