Average Error: 13.4 → 13.4
Time: 13.5s
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 \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) + \frac{x \cdot x}{\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) + \frac{x \cdot x}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}
double f(double p, double x) {
        double r206910 = 0.5;
        double r206911 = 1.0;
        double r206912 = x;
        double r206913 = 4.0;
        double r206914 = p;
        double r206915 = r206913 * r206914;
        double r206916 = r206915 * r206914;
        double r206917 = r206912 * r206912;
        double r206918 = r206916 + r206917;
        double r206919 = sqrt(r206918);
        double r206920 = r206912 / r206919;
        double r206921 = r206911 + r206920;
        double r206922 = r206910 * r206921;
        double r206923 = sqrt(r206922);
        return r206923;
}

double f(double p, double x) {
        double r206924 = 0.5;
        double r206925 = 1.0;
        double r206926 = 3.0;
        double r206927 = pow(r206925, r206926);
        double r206928 = x;
        double r206929 = 4.0;
        double r206930 = p;
        double r206931 = r206929 * r206930;
        double r206932 = r206931 * r206930;
        double r206933 = r206928 * r206928;
        double r206934 = r206932 + r206933;
        double r206935 = sqrt(r206934);
        double r206936 = r206928 / r206935;
        double r206937 = pow(r206936, r206926);
        double r206938 = r206927 + r206937;
        double r206939 = r206925 - r206936;
        double r206940 = r206925 * r206939;
        double r206941 = r206933 / r206934;
        double r206942 = r206940 + r206941;
        double r206943 = r206938 / r206942;
        double r206944 = r206924 * r206943;
        double r206945 = sqrt(r206944);
        return r206945;
}

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.4
\[\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 flip3-+13.4

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

    \[\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 \cdot x}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\]
  5. Final simplification13.4

    \[\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) + \frac{x \cdot x}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\]

Reproduce

herbie shell --seed 2019212 
(FPCore (p x)
  :name "Given's Rotation SVD example"
  :precision binary64
  :pre (< 1.00000000000000001e-150 (fabs x) 9.99999999999999981e149)

  :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))))))))