Average Error: 13.4 → 14.7
Time: 5.1s
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 \sqrt[3]{{\left(1 + \frac{\frac{x}{\left|\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}\right|}}{\sqrt{\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}^{3}}}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{0.5 \cdot \sqrt[3]{{\left(1 + \frac{\frac{x}{\left|\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}\right|}}{\sqrt{\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}^{3}}}
double f(double p, double x) {
        double r248067 = 0.5;
        double r248068 = 1.0;
        double r248069 = x;
        double r248070 = 4.0;
        double r248071 = p;
        double r248072 = r248070 * r248071;
        double r248073 = r248072 * r248071;
        double r248074 = r248069 * r248069;
        double r248075 = r248073 + r248074;
        double r248076 = sqrt(r248075);
        double r248077 = r248069 / r248076;
        double r248078 = r248068 + r248077;
        double r248079 = r248067 * r248078;
        double r248080 = sqrt(r248079);
        return r248080;
}

double f(double p, double x) {
        double r248081 = 0.5;
        double r248082 = 1.0;
        double r248083 = x;
        double r248084 = 4.0;
        double r248085 = p;
        double r248086 = r248084 * r248085;
        double r248087 = r248086 * r248085;
        double r248088 = r248083 * r248083;
        double r248089 = r248087 + r248088;
        double r248090 = cbrt(r248089);
        double r248091 = fabs(r248090);
        double r248092 = r248083 / r248091;
        double r248093 = sqrt(r248090);
        double r248094 = r248092 / r248093;
        double r248095 = r248082 + r248094;
        double r248096 = 3.0;
        double r248097 = pow(r248095, r248096);
        double r248098 = cbrt(r248097);
        double r248099 = r248081 * r248098;
        double r248100 = sqrt(r248099);
        return r248100;
}

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
Herbie14.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.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 add-cube-cbrt14.8

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

    \[\leadsto \sqrt{0.5 \cdot \left(1 + \frac{x}{\color{blue}{\sqrt{\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x} \cdot \sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}} \cdot \sqrt{\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right)}\]
  5. Applied associate-/r*14.8

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

    \[\leadsto \sqrt{0.5 \cdot \left(1 + \frac{\color{blue}{\frac{x}{\left|\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}\right|}}}{\sqrt{\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}\]
  7. Using strategy rm
  8. Applied add-cbrt-cube14.7

    \[\leadsto \sqrt{0.5 \cdot \color{blue}{\sqrt[3]{\left(\left(1 + \frac{\frac{x}{\left|\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}\right|}}{\sqrt{\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right) \cdot \left(1 + \frac{\frac{x}{\left|\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}\right|}}{\sqrt{\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)\right) \cdot \left(1 + \frac{\frac{x}{\left|\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}\right|}}{\sqrt{\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}}}\]
  9. Simplified14.7

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

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

Reproduce

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