Average Error: 13.1 → 13.1
Time: 5.3s
Precision: 64
\[1.00000000000000001 \cdot 10^{-150} \lt \left|x\right| \lt 9.99999999999999981 \cdot 10^{149}\]
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\]
\[\sqrt{0.5 \cdot \frac{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \left(\sqrt[3]{\frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}} \cdot \sqrt[3]{\frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) \cdot \sqrt[3]{\frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{0.5 \cdot \frac{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \left(\sqrt[3]{\frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}} \cdot \sqrt[3]{\frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) \cdot \sqrt[3]{\frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}
double f(double p, double x) {
        double r321687 = 0.5;
        double r321688 = 1.0;
        double r321689 = x;
        double r321690 = 4.0;
        double r321691 = p;
        double r321692 = r321690 * r321691;
        double r321693 = r321692 * r321691;
        double r321694 = r321689 * r321689;
        double r321695 = r321693 + r321694;
        double r321696 = sqrt(r321695);
        double r321697 = r321689 / r321696;
        double r321698 = r321688 + r321697;
        double r321699 = r321687 * r321698;
        double r321700 = sqrt(r321699);
        return r321700;
}

double f(double p, double x) {
        double r321701 = 0.5;
        double r321702 = 1.0;
        double r321703 = 3.0;
        double r321704 = pow(r321702, r321703);
        double r321705 = x;
        double r321706 = 4.0;
        double r321707 = p;
        double r321708 = r321706 * r321707;
        double r321709 = r321708 * r321707;
        double r321710 = r321705 * r321705;
        double r321711 = r321709 + r321710;
        double r321712 = sqrt(r321711);
        double r321713 = r321705 / r321712;
        double r321714 = pow(r321713, r321703);
        double r321715 = r321704 + r321714;
        double r321716 = r321702 - r321713;
        double r321717 = r321702 * r321716;
        double r321718 = 2.0;
        double r321719 = pow(r321705, r321718);
        double r321720 = r321719 / r321711;
        double r321721 = cbrt(r321720);
        double r321722 = r321721 * r321721;
        double r321723 = r321722 * r321721;
        double r321724 = r321717 + r321723;
        double r321725 = r321715 / r321724;
        double r321726 = r321701 * r321725;
        double r321727 = sqrt(r321726);
        return r321727;
}

Error

Bits error versus p

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original13.1
Target13.1
Herbie13.1
\[\sqrt{0.5 + \frac{\mathsf{copysign}\left(0.5, x\right)}{\mathsf{hypot}\left(1, \frac{2 \cdot p}{x}\right)}}\]

Derivation

  1. Initial program 13.1

    \[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\]
  2. Using strategy rm
  3. Applied flip3-+13.1

    \[\leadsto \sqrt{0.5 \cdot \color{blue}{\frac{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}{1 \cdot 1 + \left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} \cdot \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} - 1 \cdot \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}}\]
  4. Simplified13.1

    \[\leadsto \sqrt{0.5 \cdot \frac{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}{\color{blue}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\]
  5. Using strategy rm
  6. Applied add-cube-cbrt13.1

    \[\leadsto \sqrt{0.5 \cdot \frac{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \color{blue}{\left(\sqrt[3]{\frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}} \cdot \sqrt[3]{\frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) \cdot \sqrt[3]{\frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}}\]
  7. Final simplification13.1

    \[\leadsto \sqrt{0.5 \cdot \frac{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \left(\sqrt[3]{\frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}} \cdot \sqrt[3]{\frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) \cdot \sqrt[3]{\frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\]

Reproduce

herbie shell --seed 2020065 
(FPCore (p x)
  :name "Given's Rotation SVD example"
  :precision binary64
  :pre (< 1e-150 (fabs x) 1e+150)

  :herbie-target
  (sqrt (+ 0.5 (/ (copysign 0.5 x) (hypot 1 (/ (* 2 p) x)))))

  (sqrt (* 0.5 (+ 1 (/ x (sqrt (+ (* (* 4 p) p) (* x x))))))))