Average Error: 13.0 → 13.0
Time: 9.9s
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{\frac{1}{2} \cdot \log \left(e^{\frac{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \frac{x \cdot x}{\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{\frac{1}{2} \cdot \log \left(e^{\frac{{1}^{3} + {\left(\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}{1 \cdot \left(1 - \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right) + \frac{x \cdot x}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}
double f(double p, double x) {
        double r210531 = 0.5;
        double r210532 = 1.0;
        double r210533 = x;
        double r210534 = 4.0;
        double r210535 = p;
        double r210536 = r210534 * r210535;
        double r210537 = r210536 * r210535;
        double r210538 = r210533 * r210533;
        double r210539 = r210537 + r210538;
        double r210540 = sqrt(r210539);
        double r210541 = r210533 / r210540;
        double r210542 = r210532 + r210541;
        double r210543 = r210531 * r210542;
        double r210544 = sqrt(r210543);
        return r210544;
}

double f(double p, double x) {
        double r210545 = 1.0;
        double r210546 = 2.0;
        double r210547 = r210545 / r210546;
        double r210548 = 3.0;
        double r210549 = pow(r210545, r210548);
        double r210550 = x;
        double r210551 = 4.0;
        double r210552 = p;
        double r210553 = r210551 * r210552;
        double r210554 = r210553 * r210552;
        double r210555 = r210550 * r210550;
        double r210556 = r210554 + r210555;
        double r210557 = sqrt(r210556);
        double r210558 = r210550 / r210557;
        double r210559 = pow(r210558, r210548);
        double r210560 = r210549 + r210559;
        double r210561 = r210545 - r210558;
        double r210562 = r210545 * r210561;
        double r210563 = r210555 / r210556;
        double r210564 = r210562 + r210563;
        double r210565 = r210560 / r210564;
        double r210566 = exp(r210565);
        double r210567 = log(r210566);
        double r210568 = r210547 * r210567;
        double r210569 = sqrt(r210568);
        return r210569;
}

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.0
Target13.0
Herbie13.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.0

    \[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\]
  2. Simplified13.0

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

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

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

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

    \[\leadsto \sqrt{\frac{1}{2} \cdot \log \color{blue}{\left(e^{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}}\]
  8. Using strategy rm
  9. Applied flip3-+13.0

    \[\leadsto \sqrt{\frac{1}{2} \cdot \log \left(e^{\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)}}}\right)}\]
  10. Simplified13.0

    \[\leadsto \sqrt{\frac{1}{2} \cdot \log \left(e^{\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 \cdot x}{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right)}\]
  11. Final simplification13.0

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

Reproduce

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