Average Error: 13.4 → 13.4
Time: 6.3s
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 \frac{\log \left(e^{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}\right)}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{0.5 \cdot \frac{\log \left(e^{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}\right)}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}
double f(double p, double x) {
        double r267463 = 0.5;
        double r267464 = 1.0;
        double r267465 = x;
        double r267466 = 4.0;
        double r267467 = p;
        double r267468 = r267466 * r267467;
        double r267469 = r267468 * r267467;
        double r267470 = r267465 * r267465;
        double r267471 = r267469 + r267470;
        double r267472 = sqrt(r267471);
        double r267473 = r267465 / r267472;
        double r267474 = r267464 + r267473;
        double r267475 = r267463 * r267474;
        double r267476 = sqrt(r267475);
        return r267476;
}

double f(double p, double x) {
        double r267477 = 0.5;
        double r267478 = 1.0;
        double r267479 = 3.0;
        double r267480 = pow(r267478, r267479);
        double r267481 = x;
        double r267482 = 4.0;
        double r267483 = p;
        double r267484 = r267482 * r267483;
        double r267485 = r267484 * r267483;
        double r267486 = r267481 * r267481;
        double r267487 = r267485 + r267486;
        double r267488 = sqrt(r267487);
        double r267489 = r267481 / r267488;
        double r267490 = pow(r267489, r267479);
        double r267491 = r267480 + r267490;
        double r267492 = exp(r267491);
        double r267493 = log(r267492);
        double r267494 = r267478 - r267489;
        double r267495 = r267478 * r267494;
        double r267496 = 2.0;
        double r267497 = pow(r267481, r267496);
        double r267498 = r267497 / r267487;
        double r267499 = r267495 + r267498;
        double r267500 = r267493 / r267499;
        double r267501 = r267477 * r267500;
        double r267502 = sqrt(r267501);
        return r267502;
}

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.4
\[\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 flip3-+13.4

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

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

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

    \[\leadsto \sqrt{0.5 \cdot \frac{\color{blue}{\log \left(e^{{1}^{3}}\right)} + \log \left(e^{{\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}\right)}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\]
  8. Applied sum-log13.4

    \[\leadsto \sqrt{0.5 \cdot \frac{\color{blue}{\log \left(e^{{1}^{3}} \cdot e^{{\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}\right)}}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\]
  9. Simplified13.4

    \[\leadsto \sqrt{0.5 \cdot \frac{\log \color{blue}{\left(e^{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}\right)}}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \frac{{x}^{2}}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\]
  10. Final simplification13.4

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

Reproduce

herbie shell --seed 2020036 
(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))))))))