Average Error: 13.3 → 14.3
Time: 10.0s
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{\left(1 + \frac{x}{\sqrt{\sqrt{\left(p \cdot p\right) \cdot 4 + x \cdot x}} \cdot \sqrt{\sqrt{\left(p \cdot p\right) \cdot 4 + x \cdot x}}}\right) \cdot 0.5}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{\left(1 + \frac{x}{\sqrt{\sqrt{\left(p \cdot p\right) \cdot 4 + x \cdot x}} \cdot \sqrt{\sqrt{\left(p \cdot p\right) \cdot 4 + x \cdot x}}}\right) \cdot 0.5}
double f(double p, double x) {
        double r173522 = 0.5;
        double r173523 = 1.0;
        double r173524 = x;
        double r173525 = 4.0;
        double r173526 = p;
        double r173527 = r173525 * r173526;
        double r173528 = r173527 * r173526;
        double r173529 = r173524 * r173524;
        double r173530 = r173528 + r173529;
        double r173531 = sqrt(r173530);
        double r173532 = r173524 / r173531;
        double r173533 = r173523 + r173532;
        double r173534 = r173522 * r173533;
        double r173535 = sqrt(r173534);
        return r173535;
}

double f(double p, double x) {
        double r173536 = 1.0;
        double r173537 = x;
        double r173538 = p;
        double r173539 = r173538 * r173538;
        double r173540 = 4.0;
        double r173541 = r173539 * r173540;
        double r173542 = r173537 * r173537;
        double r173543 = r173541 + r173542;
        double r173544 = sqrt(r173543);
        double r173545 = sqrt(r173544);
        double r173546 = r173545 * r173545;
        double r173547 = r173537 / r173546;
        double r173548 = r173536 + r173547;
        double r173549 = 0.5;
        double r173550 = r173548 * r173549;
        double r173551 = sqrt(r173550);
        return r173551;
}

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.3
Target13.3
Herbie14.3
\[\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.3

    \[\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 *-un-lft-identity13.3

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

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

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

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

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

    \[\leadsto \sqrt{0.5 \cdot \left(1 + 1 \cdot \color{blue}{\frac{x}{\sqrt{x \cdot x + p \cdot \left(p \cdot 4\right)}}}\right)}\]
  9. Using strategy rm
  10. Applied add-sqr-sqrt13.3

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

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

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

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

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

Reproduce

herbie shell --seed 2019194 
(FPCore (p x)
  :name "Given's Rotation SVD example"
  :pre (< 1e-150 (fabs x) 1e+150)

  :herbie-target
  (sqrt (+ 0.5 (/ (copysign 0.5 x) (hypot 1.0 (/ (* 2.0 p) x)))))

  (sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x))))))))