Average Error: 13.4 → 13.6
Time: 5.0s
Precision: 64
\[1.000000000000000006295358232172963997211 \cdot 10^{-150} \lt \left|x\right| \lt 9.999999999999999808355961724373745905731 \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 \sqrt[3]{{\left(x \cdot \frac{\sqrt{1}}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} + 1\right)}^{3}}}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{0.5 \cdot \sqrt[3]{{\left(x \cdot \frac{\sqrt{1}}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} + 1\right)}^{3}}}
double f(double p, double x) {
        double r367828 = 0.5;
        double r367829 = 1.0;
        double r367830 = x;
        double r367831 = 4.0;
        double r367832 = p;
        double r367833 = r367831 * r367832;
        double r367834 = r367833 * r367832;
        double r367835 = r367830 * r367830;
        double r367836 = r367834 + r367835;
        double r367837 = sqrt(r367836);
        double r367838 = r367830 / r367837;
        double r367839 = r367829 + r367838;
        double r367840 = r367828 * r367839;
        double r367841 = sqrt(r367840);
        return r367841;
}

double f(double p, double x) {
        double r367842 = 0.5;
        double r367843 = x;
        double r367844 = 1.0;
        double r367845 = sqrt(r367844);
        double r367846 = 4.0;
        double r367847 = p;
        double r367848 = r367846 * r367847;
        double r367849 = r367848 * r367847;
        double r367850 = r367843 * r367843;
        double r367851 = r367849 + r367850;
        double r367852 = sqrt(r367851);
        double r367853 = r367845 / r367852;
        double r367854 = r367843 * r367853;
        double r367855 = 1.0;
        double r367856 = r367854 + r367855;
        double r367857 = 3.0;
        double r367858 = pow(r367856, r367857);
        double r367859 = cbrt(r367858);
        double r367860 = r367842 * r367859;
        double r367861 = sqrt(r367860);
        return r367861;
}

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.4
Target13.4
Herbie13.6
\[\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.4

    \[\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 div-inv13.6

    \[\leadsto \sqrt{0.5 \cdot \left(1 + \color{blue}{x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}\]
  4. Using strategy rm
  5. Applied add-sqr-sqrt14.5

    \[\leadsto \sqrt{0.5 \cdot \left(1 + x \cdot \color{blue}{\left(\sqrt{\frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}} \cdot \sqrt{\frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}\right)}\]
  6. Applied associate-*r*14.5

    \[\leadsto \sqrt{0.5 \cdot \left(1 + \color{blue}{\left(x \cdot \sqrt{\frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right) \cdot \sqrt{\frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right)}\]
  7. Using strategy rm
  8. Applied add-cbrt-cube14.5

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

    \[\leadsto \sqrt{0.5 \cdot \sqrt[3]{\color{blue}{{\left(x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} + 1\right)}^{3}}}}\]
  10. Using strategy rm
  11. Applied *-un-lft-identity13.6

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

    \[\leadsto \sqrt{0.5 \cdot \sqrt[3]{{\left(x \cdot \frac{1}{\color{blue}{\sqrt{1} \cdot \sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}} + 1\right)}^{3}}}\]
  13. Applied add-sqr-sqrt13.6

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

    \[\leadsto \sqrt{0.5 \cdot \sqrt[3]{{\left(x \cdot \color{blue}{\left(\frac{\sqrt{1}}{\sqrt{1}} \cdot \frac{\sqrt{1}}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)} + 1\right)}^{3}}}\]
  15. Applied associate-*r*13.6

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

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

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

Reproduce

herbie shell --seed 2019356 
(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))))))))