Average Error: 14.7 → 0.0
Time: 17.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.007827563730713092:\\ \;\;\;\;\frac{\frac{1}{2} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{\frac{1}{2} + \log \left(e^{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}\right)}}\\ \mathbf{elif}\;x \le 0.009360235500925969:\\ \;\;\;\;\frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right), \frac{5}{32}, \mathsf{fma}\left(x \cdot x, \frac{1}{4}, \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{-3}{16}\right)\right)}{1 + \sqrt{\frac{1}{2} + \log \left(e^{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{2} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{\frac{1}{2} + \log \left(e^{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}\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.007827563730713092:\\
\;\;\;\;\frac{\frac{1}{2} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{\frac{1}{2} + \log \left(e^{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}\right)}}\\

\mathbf{elif}\;x \le 0.009360235500925969:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right), \frac{5}{32}, \mathsf{fma}\left(x \cdot x, \frac{1}{4}, \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{-3}{16}\right)\right)}{1 + \sqrt{\frac{1}{2} + \log \left(e^{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{2} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{\frac{1}{2} + \log \left(e^{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}\right)}}\\

\end{array}
double f(double x) {
        double r5306626 = 1.0;
        double r5306627 = 0.5;
        double r5306628 = x;
        double r5306629 = hypot(r5306626, r5306628);
        double r5306630 = r5306626 / r5306629;
        double r5306631 = r5306626 + r5306630;
        double r5306632 = r5306627 * r5306631;
        double r5306633 = sqrt(r5306632);
        double r5306634 = r5306626 - r5306633;
        return r5306634;
}

double f(double x) {
        double r5306635 = x;
        double r5306636 = -0.007827563730713092;
        bool r5306637 = r5306635 <= r5306636;
        double r5306638 = 0.5;
        double r5306639 = 1.0;
        double r5306640 = hypot(r5306639, r5306635);
        double r5306641 = r5306638 / r5306640;
        double r5306642 = r5306638 - r5306641;
        double r5306643 = exp(r5306641);
        double r5306644 = log(r5306643);
        double r5306645 = r5306638 + r5306644;
        double r5306646 = sqrt(r5306645);
        double r5306647 = r5306639 + r5306646;
        double r5306648 = r5306642 / r5306647;
        double r5306649 = 0.009360235500925969;
        bool r5306650 = r5306635 <= r5306649;
        double r5306651 = r5306635 * r5306635;
        double r5306652 = r5306651 * r5306651;
        double r5306653 = r5306651 * r5306652;
        double r5306654 = 0.15625;
        double r5306655 = 0.25;
        double r5306656 = -0.1875;
        double r5306657 = r5306652 * r5306656;
        double r5306658 = fma(r5306651, r5306655, r5306657);
        double r5306659 = fma(r5306653, r5306654, r5306658);
        double r5306660 = r5306659 / r5306647;
        double r5306661 = r5306650 ? r5306660 : r5306648;
        double r5306662 = r5306637 ? r5306648 : r5306661;
        return r5306662;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.007827563730713092 or 0.009360235500925969 < 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.0

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

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

    if -0.007827563730713092 < x < 0.009360235500925969

    1. Initial program 28.8

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

      \[\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--28.8

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

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

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

      \[\leadsto \frac{\color{blue}{\left(\frac{1}{4} \cdot {x}^{2} + \frac{5}{32} \cdot {x}^{6}\right) - \frac{3}{16} \cdot {x}^{4}}}{1 + \sqrt{\log \left(e^{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}\right) + \frac{1}{2}}}\]
    9. Simplified0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.007827563730713092:\\ \;\;\;\;\frac{\frac{1}{2} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{\frac{1}{2} + \log \left(e^{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}\right)}}\\ \mathbf{elif}\;x \le 0.009360235500925969:\\ \;\;\;\;\frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right), \frac{5}{32}, \mathsf{fma}\left(x \cdot x, \frac{1}{4}, \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{-3}{16}\right)\right)}{1 + \sqrt{\frac{1}{2} + \log \left(e^{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{2} - \frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{\frac{1}{2} + \log \left(e^{\frac{\frac{1}{2}}{\mathsf{hypot}\left(1, x\right)}}\right)}}\\ \end{array}\]

Reproduce

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