Average Error: 15.5 → 0.2
Time: 7.6s
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.0000000843363774:\\ \;\;\;\;\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}:\\ \;\;\;\;\mathsf{fma}\left(-0.5, 1 + \log \left(e^{\frac{1}{\mathsf{hypot}\left(1, x\right)}}\right), 1 \cdot 1\right) \cdot \frac{1}{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}\;\mathsf{hypot}\left(1, x\right) \le 1.0000000843363774:\\
\;\;\;\;\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}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, 1 + \log \left(e^{\frac{1}{\mathsf{hypot}\left(1, x\right)}}\right), 1 \cdot 1\right) \cdot \frac{1}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\

\end{array}
double f(double x) {
        double r233740 = 1.0;
        double r233741 = 0.5;
        double r233742 = x;
        double r233743 = hypot(r233740, r233742);
        double r233744 = r233740 / r233743;
        double r233745 = r233740 + r233744;
        double r233746 = r233741 * r233745;
        double r233747 = sqrt(r233746);
        double r233748 = r233740 - r233747;
        return r233748;
}

double f(double x) {
        double r233749 = 1.0;
        double r233750 = x;
        double r233751 = hypot(r233749, r233750);
        double r233752 = 1.0000000843363774;
        bool r233753 = r233751 <= r233752;
        double r233754 = 0.25;
        double r233755 = 2.0;
        double r233756 = pow(r233750, r233755);
        double r233757 = sqrt(r233749);
        double r233758 = 3.0;
        double r233759 = pow(r233757, r233758);
        double r233760 = r233756 / r233759;
        double r233761 = 0.5;
        double r233762 = 1.0;
        double r233763 = r233762 / r233757;
        double r233764 = 0.1875;
        double r233765 = 4.0;
        double r233766 = pow(r233750, r233765);
        double r233767 = 5.0;
        double r233768 = pow(r233757, r233767);
        double r233769 = r233766 / r233768;
        double r233770 = r233764 * r233769;
        double r233771 = fma(r233761, r233763, r233770);
        double r233772 = r233761 - r233771;
        double r233773 = fma(r233754, r233760, r233772);
        double r233774 = r233749 / r233751;
        double r233775 = r233749 + r233774;
        double r233776 = r233761 * r233775;
        double r233777 = sqrt(r233776);
        double r233778 = r233749 + r233777;
        double r233779 = r233773 / r233778;
        double r233780 = -r233761;
        double r233781 = exp(r233774);
        double r233782 = log(r233781);
        double r233783 = r233749 + r233782;
        double r233784 = r233749 * r233749;
        double r233785 = fma(r233780, r233783, r233784);
        double r233786 = r233762 / r233778;
        double r233787 = r233785 * r233786;
        double r233788 = r233753 ? r233779 : r233787;
        return r233788;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 30.4

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

      \[\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 30.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.2

      \[\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.0000000843363774 < (hypot 1.0 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(-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-log-exp0.1

      \[\leadsto \frac{\mathsf{fma}\left(-0.5, 1 + \color{blue}{\log \left(e^{\frac{1}{\mathsf{hypot}\left(1, x\right)}}\right)}, 1 \cdot 1\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\]
    7. Using strategy rm
    8. Applied div-inv0.2

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

Reproduce

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