Average Error: 13.5 → 14.8
Time: 18.8s
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 r177082 = 0.5;
        double r177083 = 1.0;
        double r177084 = x;
        double r177085 = 4.0;
        double r177086 = p;
        double r177087 = r177085 * r177086;
        double r177088 = r177087 * r177086;
        double r177089 = r177084 * r177084;
        double r177090 = r177088 + r177089;
        double r177091 = sqrt(r177090);
        double r177092 = r177084 / r177091;
        double r177093 = r177083 + r177092;
        double r177094 = r177082 * r177093;
        double r177095 = sqrt(r177094);
        return r177095;
}

double f(double p, double x) {
        double r177096 = 0.5;
        double r177097 = 1.0;
        double r177098 = x;
        double r177099 = 4.0;
        double r177100 = p;
        double r177101 = r177099 * r177100;
        double r177102 = r177101 * r177100;
        double r177103 = r177098 * r177098;
        double r177104 = r177102 + r177103;
        double r177105 = cbrt(r177104);
        double r177106 = fabs(r177105);
        double r177107 = sqrt(r177106);
        double r177108 = sqrt(r177104);
        double r177109 = sqrt(r177108);
        double r177110 = r177107 * r177109;
        double r177111 = sqrt(r177105);
        double r177112 = sqrt(r177111);
        double r177113 = r177110 * r177112;
        double r177114 = r177098 / r177113;
        double r177115 = r177097 + r177114;
        double r177116 = 3.0;
        double r177117 = pow(r177115, r177116);
        double r177118 = cbrt(r177117);
        double r177119 = r177096 * r177118;
        double r177120 = sqrt(r177119);
        return r177120;
}

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