Average Error: 13.0 → 13.0
Time: 6.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 r330013 = 0.5;
        double r330014 = 1.0;
        double r330015 = x;
        double r330016 = 4.0;
        double r330017 = p;
        double r330018 = r330016 * r330017;
        double r330019 = r330018 * r330017;
        double r330020 = r330015 * r330015;
        double r330021 = r330019 + r330020;
        double r330022 = sqrt(r330021);
        double r330023 = r330015 / r330022;
        double r330024 = r330014 + r330023;
        double r330025 = r330013 * r330024;
        double r330026 = sqrt(r330025);
        return r330026;
}

double f(double p, double x) {
        double r330027 = 0.5;
        double r330028 = 1.0;
        double r330029 = 3.0;
        double r330030 = pow(r330028, r330029);
        double r330031 = x;
        double r330032 = 4.0;
        double r330033 = p;
        double r330034 = r330032 * r330033;
        double r330035 = r330034 * r330033;
        double r330036 = r330031 * r330031;
        double r330037 = r330035 + r330036;
        double r330038 = sqrt(r330037);
        double r330039 = r330031 / r330038;
        double r330040 = pow(r330039, r330029);
        double r330041 = r330030 + r330040;
        double r330042 = r330027 * r330041;
        double r330043 = sqrt(r330042);
        double r330044 = r330028 * r330028;
        double r330045 = r330039 * r330039;
        double r330046 = r330028 * r330039;
        double r330047 = r330045 - r330046;
        double r330048 = r330044 + r330047;
        double r330049 = sqrt(r330048);
        double r330050 = r330043 / r330049;
        return r330050;
}

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 2019354 
(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))))))))