Average Error: 13.4 → 13.6
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 \left(\left(\sqrt[3]{1 + \frac{x}{\left(\sqrt[3]{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} \cdot \sqrt[3]{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) \cdot \sqrt[3]{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}} \cdot \sqrt[3]{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right) \cdot \sqrt[3]{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{0.5 \cdot \left(\left(\sqrt[3]{1 + \frac{x}{\left(\sqrt[3]{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} \cdot \sqrt[3]{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) \cdot \sqrt[3]{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}} \cdot \sqrt[3]{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right) \cdot \sqrt[3]{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}
double f(double p, double x) {
        double r169313 = 0.5;
        double r169314 = 1.0;
        double r169315 = x;
        double r169316 = 4.0;
        double r169317 = p;
        double r169318 = r169316 * r169317;
        double r169319 = r169318 * r169317;
        double r169320 = r169315 * r169315;
        double r169321 = r169319 + r169320;
        double r169322 = sqrt(r169321);
        double r169323 = r169315 / r169322;
        double r169324 = r169314 + r169323;
        double r169325 = r169313 * r169324;
        double r169326 = sqrt(r169325);
        return r169326;
}

double f(double p, double x) {
        double r169327 = 0.5;
        double r169328 = 1.0;
        double r169329 = x;
        double r169330 = 4.0;
        double r169331 = p;
        double r169332 = r169330 * r169331;
        double r169333 = r169332 * r169331;
        double r169334 = r169329 * r169329;
        double r169335 = r169333 + r169334;
        double r169336 = sqrt(r169335);
        double r169337 = cbrt(r169336);
        double r169338 = r169337 * r169337;
        double r169339 = r169338 * r169337;
        double r169340 = r169329 / r169339;
        double r169341 = r169328 + r169340;
        double r169342 = cbrt(r169341);
        double r169343 = r169329 / r169336;
        double r169344 = r169328 + r169343;
        double r169345 = cbrt(r169344);
        double r169346 = r169342 * r169345;
        double r169347 = r169346 * r169345;
        double r169348 = r169327 * r169347;
        double r169349 = sqrt(r169348);
        return r169349;
}

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
Herbie13.6
\[\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-cbrt13.6

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

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

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

Reproduce

herbie shell --seed 2019306 
(FPCore (p x)
  :name "Given's Rotation SVD example"
  :precision binary64
  :pre (< 1.00000000000000001e-150 (fabs x) 9.99999999999999981e149)

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