Average Error: 13.4 → 13.4
Time: 15.4s
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 \log \left(e^{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 \log \left(e^{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}
double f(double p, double x) {
        double r178441 = 0.5;
        double r178442 = 1.0;
        double r178443 = x;
        double r178444 = 4.0;
        double r178445 = p;
        double r178446 = r178444 * r178445;
        double r178447 = r178446 * r178445;
        double r178448 = r178443 * r178443;
        double r178449 = r178447 + r178448;
        double r178450 = sqrt(r178449);
        double r178451 = r178443 / r178450;
        double r178452 = r178442 + r178451;
        double r178453 = r178441 * r178452;
        double r178454 = sqrt(r178453);
        return r178454;
}

double f(double p, double x) {
        double r178455 = 0.5;
        double r178456 = 1.0;
        double r178457 = x;
        double r178458 = 4.0;
        double r178459 = p;
        double r178460 = r178458 * r178459;
        double r178461 = r178460 * r178459;
        double r178462 = r178457 * r178457;
        double r178463 = r178461 + r178462;
        double r178464 = sqrt(r178463);
        double r178465 = r178457 / r178464;
        double r178466 = r178456 + r178465;
        double r178467 = exp(r178466);
        double r178468 = log(r178467);
        double r178469 = r178455 * r178468;
        double r178470 = sqrt(r178469);
        return r178470;
}

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 add-log-exp13.4

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

    \[\leadsto \sqrt{0.5 \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)}\]
  5. Applied sum-log13.4

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

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

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

Reproduce

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