Average Error: 12.9 → 13.1
Time: 5.1s
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{\frac{{\left({1}^{3}\right)}^{3} + {\left({\left(x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}\right)}^{3}}{\left({1}^{6} + {\left(x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{6}\right) - {1}^{3} \cdot {\left(x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}}{\frac{1}{\left(4 \cdot p\right) \cdot p + x \cdot x} \cdot {x}^{2} - \left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} \cdot 1 - 1 \cdot 1\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 \frac{\frac{{\left({1}^{3}\right)}^{3} + {\left({\left(x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}\right)}^{3}}{\left({1}^{6} + {\left(x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{6}\right) - {1}^{3} \cdot {\left(x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}}{\frac{1}{\left(4 \cdot p\right) \cdot p + x \cdot x} \cdot {x}^{2} - \left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} \cdot 1 - 1 \cdot 1\right)}}
double f(double p, double x) {
        double r256934 = 0.5;
        double r256935 = 1.0;
        double r256936 = x;
        double r256937 = 4.0;
        double r256938 = p;
        double r256939 = r256937 * r256938;
        double r256940 = r256939 * r256938;
        double r256941 = r256936 * r256936;
        double r256942 = r256940 + r256941;
        double r256943 = sqrt(r256942);
        double r256944 = r256936 / r256943;
        double r256945 = r256935 + r256944;
        double r256946 = r256934 * r256945;
        double r256947 = sqrt(r256946);
        return r256947;
}

double f(double p, double x) {
        double r256948 = 0.5;
        double r256949 = 1.0;
        double r256950 = 3.0;
        double r256951 = pow(r256949, r256950);
        double r256952 = pow(r256951, r256950);
        double r256953 = x;
        double r256954 = 1.0;
        double r256955 = 4.0;
        double r256956 = p;
        double r256957 = r256955 * r256956;
        double r256958 = r256957 * r256956;
        double r256959 = r256953 * r256953;
        double r256960 = r256958 + r256959;
        double r256961 = sqrt(r256960);
        double r256962 = r256954 / r256961;
        double r256963 = r256953 * r256962;
        double r256964 = pow(r256963, r256950);
        double r256965 = pow(r256964, r256950);
        double r256966 = r256952 + r256965;
        double r256967 = 6.0;
        double r256968 = pow(r256949, r256967);
        double r256969 = pow(r256963, r256967);
        double r256970 = r256968 + r256969;
        double r256971 = r256951 * r256964;
        double r256972 = r256970 - r256971;
        double r256973 = r256966 / r256972;
        double r256974 = r256954 / r256960;
        double r256975 = 2.0;
        double r256976 = pow(r256953, r256975);
        double r256977 = r256974 * r256976;
        double r256978 = r256953 / r256961;
        double r256979 = r256978 * r256949;
        double r256980 = r256949 * r256949;
        double r256981 = r256979 - r256980;
        double r256982 = r256977 - r256981;
        double r256983 = r256973 / r256982;
        double r256984 = r256948 * r256983;
        double r256985 = sqrt(r256984);
        return r256985;
}

Error

Bits error versus p

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.9
Target12.9
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 12.9

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

    \[\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 flip3-+13.1

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

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

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

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

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

Reproduce

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