Average Error: 13.5 → 14.8
Time: 18.6s
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 r296079 = 0.5;
        double r296080 = 1.0;
        double r296081 = x;
        double r296082 = 4.0;
        double r296083 = p;
        double r296084 = r296082 * r296083;
        double r296085 = r296084 * r296083;
        double r296086 = r296081 * r296081;
        double r296087 = r296085 + r296086;
        double r296088 = sqrt(r296087);
        double r296089 = r296081 / r296088;
        double r296090 = r296080 + r296089;
        double r296091 = r296079 * r296090;
        double r296092 = sqrt(r296091);
        return r296092;
}

double f(double p, double x) {
        double r296093 = 0.5;
        double r296094 = 1.0;
        double r296095 = x;
        double r296096 = 4.0;
        double r296097 = p;
        double r296098 = r296096 * r296097;
        double r296099 = r296098 * r296097;
        double r296100 = r296095 * r296095;
        double r296101 = r296099 + r296100;
        double r296102 = cbrt(r296101);
        double r296103 = fabs(r296102);
        double r296104 = sqrt(r296103);
        double r296105 = sqrt(r296101);
        double r296106 = sqrt(r296105);
        double r296107 = r296104 * r296106;
        double r296108 = sqrt(r296102);
        double r296109 = sqrt(r296108);
        double r296110 = r296107 * r296109;
        double r296111 = r296095 / r296110;
        double r296112 = r296094 + r296111;
        double r296113 = 3.0;
        double r296114 = pow(r296112, r296113);
        double r296115 = cbrt(r296114);
        double r296116 = r296093 * r296115;
        double r296117 = sqrt(r296116);
        return r296117;
}

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