Average Error: 13.0 → 13.0
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)}\]
\[\frac{\sqrt{0.5 \cdot \left({1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}\right)}}{\sqrt{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)}}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\frac{\sqrt{0.5 \cdot \left({1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}\right)}}{\sqrt{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)}}
double f(double p, double x) {
        double r232822 = 0.5;
        double r232823 = 1.0;
        double r232824 = x;
        double r232825 = 4.0;
        double r232826 = p;
        double r232827 = r232825 * r232826;
        double r232828 = r232827 * r232826;
        double r232829 = r232824 * r232824;
        double r232830 = r232828 + r232829;
        double r232831 = sqrt(r232830);
        double r232832 = r232824 / r232831;
        double r232833 = r232823 + r232832;
        double r232834 = r232822 * r232833;
        double r232835 = sqrt(r232834);
        return r232835;
}

double f(double p, double x) {
        double r232836 = 0.5;
        double r232837 = 1.0;
        double r232838 = 3.0;
        double r232839 = pow(r232837, r232838);
        double r232840 = x;
        double r232841 = 4.0;
        double r232842 = p;
        double r232843 = r232841 * r232842;
        double r232844 = r232843 * r232842;
        double r232845 = r232840 * r232840;
        double r232846 = r232844 + r232845;
        double r232847 = sqrt(r232846);
        double r232848 = r232840 / r232847;
        double r232849 = pow(r232848, r232838);
        double r232850 = r232839 + r232849;
        double r232851 = r232836 * r232850;
        double r232852 = sqrt(r232851);
        double r232853 = r232837 * r232837;
        double r232854 = r232848 * r232848;
        double r232855 = r232837 * r232848;
        double r232856 = r232854 - r232855;
        double r232857 = r232853 + r232856;
        double r232858 = sqrt(r232857);
        double r232859 = r232852 / r232858;
        return r232859;
}

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.0
\[\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 flip3-+13.0

    \[\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. Applied associate-*r/13.0

    \[\leadsto \sqrt{\color{blue}{\frac{0.5 \cdot \left({1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}\right)}{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)}}}\]
  5. Applied sqrt-div13.0

    \[\leadsto \color{blue}{\frac{\sqrt{0.5 \cdot \left({1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}\right)}}{\sqrt{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)}}}\]
  6. Final simplification13.0

    \[\leadsto \frac{\sqrt{0.5 \cdot \left({1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}\right)}}{\sqrt{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)}}\]

Reproduce

herbie shell --seed 2019347 +o rules:numerics
(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))))))))