Average Error: 13.5 → 14.8
Time: 16.3s
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{x}{\left(\sqrt{\left|\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}\right|} \cdot \sqrt{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) \cdot \sqrt{\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{x}{\left(\sqrt{\left|\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}\right|} \cdot \sqrt{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) \cdot \sqrt{\sqrt{\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right)}^{3}}}
double f(double p, double x) {
        double r169276 = 0.5;
        double r169277 = 1.0;
        double r169278 = x;
        double r169279 = 4.0;
        double r169280 = p;
        double r169281 = r169279 * r169280;
        double r169282 = r169281 * r169280;
        double r169283 = r169278 * r169278;
        double r169284 = r169282 + r169283;
        double r169285 = sqrt(r169284);
        double r169286 = r169278 / r169285;
        double r169287 = r169277 + r169286;
        double r169288 = r169276 * r169287;
        double r169289 = sqrt(r169288);
        return r169289;
}

double f(double p, double x) {
        double r169290 = 0.5;
        double r169291 = 1.0;
        double r169292 = x;
        double r169293 = 4.0;
        double r169294 = p;
        double r169295 = r169293 * r169294;
        double r169296 = r169295 * r169294;
        double r169297 = r169292 * r169292;
        double r169298 = r169296 + r169297;
        double r169299 = cbrt(r169298);
        double r169300 = fabs(r169299);
        double r169301 = sqrt(r169300);
        double r169302 = sqrt(r169298);
        double r169303 = sqrt(r169302);
        double r169304 = r169301 * r169303;
        double r169305 = sqrt(r169299);
        double r169306 = sqrt(r169305);
        double r169307 = r169304 * r169306;
        double r169308 = r169292 / r169307;
        double r169309 = r169291 + r169308;
        double r169310 = 3.0;
        double r169311 = pow(r169309, r169310);
        double r169312 = cbrt(r169311);
        double r169313 = r169290 * r169312;
        double r169314 = sqrt(r169313);
        return r169314;
}

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.5
Target13.5
Herbie14.8
\[\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.5

    \[\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-sqr-sqrt13.5

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

    \[\leadsto \sqrt{0.5 \cdot \left(1 + \frac{x}{\color{blue}{\sqrt{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} \cdot \sqrt{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right)}\]
  5. Using strategy rm
  6. Applied add-cube-cbrt14.8

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

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

    \[\leadsto \sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} \cdot \color{blue}{\left(\sqrt{\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{\sqrt[3]{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}}\right)}\]
  9. Applied associate-*r*14.8

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

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

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

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

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

Reproduce

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