Average Error: 13.7 → 13.7
Time: 14.2s
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{\frac{{\left(\frac{x}{\sqrt{x \cdot x + {p}^{2} \cdot 4}}\right)}^{3} + {1}^{3}}{1 \cdot 1 + \left(\frac{x}{\sqrt{x \cdot x + {p}^{2} \cdot 4}} - 1\right) \cdot \frac{x}{\sqrt{x \cdot x + {p}^{2} \cdot 4}}} \cdot 0.5}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{\frac{{\left(\frac{x}{\sqrt{x \cdot x + {p}^{2} \cdot 4}}\right)}^{3} + {1}^{3}}{1 \cdot 1 + \left(\frac{x}{\sqrt{x \cdot x + {p}^{2} \cdot 4}} - 1\right) \cdot \frac{x}{\sqrt{x \cdot x + {p}^{2} \cdot 4}}} \cdot 0.5}
double f(double p, double x) {
        double r569886 = 0.5;
        double r569887 = 1.0;
        double r569888 = x;
        double r569889 = 4.0;
        double r569890 = p;
        double r569891 = r569889 * r569890;
        double r569892 = r569891 * r569890;
        double r569893 = r569888 * r569888;
        double r569894 = r569892 + r569893;
        double r569895 = sqrt(r569894);
        double r569896 = r569888 / r569895;
        double r569897 = r569887 + r569896;
        double r569898 = r569886 * r569897;
        double r569899 = sqrt(r569898);
        return r569899;
}

double f(double p, double x) {
        double r569900 = x;
        double r569901 = r569900 * r569900;
        double r569902 = p;
        double r569903 = 2.0;
        double r569904 = pow(r569902, r569903);
        double r569905 = 4.0;
        double r569906 = r569904 * r569905;
        double r569907 = r569901 + r569906;
        double r569908 = sqrt(r569907);
        double r569909 = r569900 / r569908;
        double r569910 = 3.0;
        double r569911 = pow(r569909, r569910);
        double r569912 = 1.0;
        double r569913 = pow(r569912, r569910);
        double r569914 = r569911 + r569913;
        double r569915 = r569912 * r569912;
        double r569916 = r569909 - r569912;
        double r569917 = r569916 * r569909;
        double r569918 = r569915 + r569917;
        double r569919 = r569914 / r569918;
        double r569920 = 0.5;
        double r569921 = r569919 * r569920;
        double r569922 = sqrt(r569921);
        return r569922;
}

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

    \[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\]
  2. Simplified13.7

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

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

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

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

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

Reproduce

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

  :herbie-target
  (sqrt (+ 0.5 (/ (copysign 0.5 x) (hypot 1.0 (/ (* 2.0 p) x)))))

  (sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x))))))))