Average Error: 13.6 → 14.0
Time: 6.0s
Precision: 64
\[1.00000000000000001 \cdot 10^{-150} \lt \left|x\right| \lt 9.99999999999999981 \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 + \sqrt[3]{\left(x \cdot x\right) \cdot {\left(\frac{\sqrt[3]{x}}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}\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 + \sqrt[3]{\left(x \cdot x\right) \cdot {\left(\frac{\sqrt[3]{x}}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}\right)}^{3}}}
double f(double p, double x) {
        double r512058 = 0.5;
        double r512059 = 1.0;
        double r512060 = x;
        double r512061 = 4.0;
        double r512062 = p;
        double r512063 = r512061 * r512062;
        double r512064 = r512063 * r512062;
        double r512065 = r512060 * r512060;
        double r512066 = r512064 + r512065;
        double r512067 = sqrt(r512066);
        double r512068 = r512060 / r512067;
        double r512069 = r512059 + r512068;
        double r512070 = r512058 * r512069;
        double r512071 = sqrt(r512070);
        return r512071;
}

double f(double p, double x) {
        double r512072 = 0.5;
        double r512073 = 1.0;
        double r512074 = x;
        double r512075 = r512074 * r512074;
        double r512076 = cbrt(r512074);
        double r512077 = 4.0;
        double r512078 = p;
        double r512079 = r512077 * r512078;
        double r512080 = r512079 * r512078;
        double r512081 = r512080 + r512075;
        double r512082 = sqrt(r512081);
        double r512083 = r512076 / r512082;
        double r512084 = 3.0;
        double r512085 = pow(r512083, r512084);
        double r512086 = r512075 * r512085;
        double r512087 = cbrt(r512086);
        double r512088 = r512073 + r512087;
        double r512089 = pow(r512088, r512084);
        double r512090 = cbrt(r512089);
        double r512091 = r512072 * r512090;
        double r512092 = sqrt(r512091);
        return r512092;
}

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.6
Target13.6
Herbie14.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.6

    \[\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-cbrt-cube19.5

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

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

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

    \[\leadsto \sqrt{0.5 \cdot \left(1 + \sqrt[3]{\color{blue}{{\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}}\right)}\]
  7. Using strategy rm
  8. Applied *-un-lft-identity13.6

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

    \[\leadsto \sqrt{0.5 \cdot \left(1 + \sqrt[3]{{\left(\frac{x}{\color{blue}{\sqrt{1} \cdot \sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}^{3}}\right)}\]
  10. Applied add-cube-cbrt14.7

    \[\leadsto \sqrt{0.5 \cdot \left(1 + \sqrt[3]{{\left(\frac{\color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}}}{\sqrt{1} \cdot \sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}\right)}\]
  11. Applied times-frac14.7

    \[\leadsto \sqrt{0.5 \cdot \left(1 + \sqrt[3]{{\color{blue}{\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt{1}} \cdot \frac{\sqrt[3]{x}}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}^{3}}\right)}\]
  12. Applied unpow-prod-down14.9

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

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

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

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

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

Reproduce

herbie shell --seed 2020046 +o rules:numerics
(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))))))))