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 r396325 = 0.5;
        double r396326 = 1.0;
        double r396327 = x;
        double r396328 = 4.0;
        double r396329 = p;
        double r396330 = r396328 * r396329;
        double r396331 = r396330 * r396329;
        double r396332 = r396327 * r396327;
        double r396333 = r396331 + r396332;
        double r396334 = sqrt(r396333);
        double r396335 = r396327 / r396334;
        double r396336 = r396326 + r396335;
        double r396337 = r396325 * r396336;
        double r396338 = sqrt(r396337);
        return r396338;
}

double f(double p, double x) {
        double r396339 = 0.5;
        double r396340 = 1.0;
        double r396341 = x;
        double r396342 = 4.0;
        double r396343 = p;
        double r396344 = r396342 * r396343;
        double r396345 = r396344 * r396343;
        double r396346 = r396341 * r396341;
        double r396347 = r396345 + r396346;
        double r396348 = cbrt(r396347);
        double r396349 = fabs(r396348);
        double r396350 = r396341 / r396349;
        double r396351 = sqrt(r396348);
        double r396352 = r396350 / r396351;
        double r396353 = r396340 + r396352;
        double r396354 = 3.0;
        double r396355 = pow(r396353, r396354);
        double r396356 = cbrt(r396355);
        double r396357 = r396339 * r396356;
        double r396358 = sqrt(r396357);
        return r396358;
}

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