Average Error: 13.0 → 13.3
Time: 6.2s
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 \left(1 + x \cdot {\left(\left(4 \cdot p\right) \cdot p + x \cdot x\right)}^{\left(-\frac{1}{2}\right)}\right)}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{0.5 \cdot \left(1 + x \cdot {\left(\left(4 \cdot p\right) \cdot p + x \cdot x\right)}^{\left(-\frac{1}{2}\right)}\right)}
double f(double p, double x) {
        double r260874 = 0.5;
        double r260875 = 1.0;
        double r260876 = x;
        double r260877 = 4.0;
        double r260878 = p;
        double r260879 = r260877 * r260878;
        double r260880 = r260879 * r260878;
        double r260881 = r260876 * r260876;
        double r260882 = r260880 + r260881;
        double r260883 = sqrt(r260882);
        double r260884 = r260876 / r260883;
        double r260885 = r260875 + r260884;
        double r260886 = r260874 * r260885;
        double r260887 = sqrt(r260886);
        return r260887;
}

double f(double p, double x) {
        double r260888 = 0.5;
        double r260889 = 1.0;
        double r260890 = x;
        double r260891 = 4.0;
        double r260892 = p;
        double r260893 = r260891 * r260892;
        double r260894 = r260893 * r260892;
        double r260895 = r260890 * r260890;
        double r260896 = r260894 + r260895;
        double r260897 = 0.5;
        double r260898 = -r260897;
        double r260899 = pow(r260896, r260898);
        double r260900 = r260890 * r260899;
        double r260901 = r260889 + r260900;
        double r260902 = r260888 * r260901;
        double r260903 = sqrt(r260902);
        return r260903;
}

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.0
Target13.0
Herbie13.3
\[\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.0

    \[\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.3

    \[\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 pow1/213.3

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

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

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

Reproduce

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