Average Error: 13.1 → 13.4
Time: 6.2s
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)}\]
\[e^{\log \left(\log \left(e^{\sqrt{0.5 \cdot \left(1 + x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}\right)\right)}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
e^{\log \left(\log \left(e^{\sqrt{0.5 \cdot \left(1 + x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}\right)\right)}
double f(double p, double x) {
        double r376533 = 0.5;
        double r376534 = 1.0;
        double r376535 = x;
        double r376536 = 4.0;
        double r376537 = p;
        double r376538 = r376536 * r376537;
        double r376539 = r376538 * r376537;
        double r376540 = r376535 * r376535;
        double r376541 = r376539 + r376540;
        double r376542 = sqrt(r376541);
        double r376543 = r376535 / r376542;
        double r376544 = r376534 + r376543;
        double r376545 = r376533 * r376544;
        double r376546 = sqrt(r376545);
        return r376546;
}

double f(double p, double x) {
        double r376547 = 0.5;
        double r376548 = 1.0;
        double r376549 = x;
        double r376550 = 1.0;
        double r376551 = 4.0;
        double r376552 = p;
        double r376553 = r376551 * r376552;
        double r376554 = r376553 * r376552;
        double r376555 = r376549 * r376549;
        double r376556 = r376554 + r376555;
        double r376557 = sqrt(r376556);
        double r376558 = r376550 / r376557;
        double r376559 = r376549 * r376558;
        double r376560 = r376548 + r376559;
        double r376561 = r376547 * r376560;
        double r376562 = sqrt(r376561);
        double r376563 = exp(r376562);
        double r376564 = log(r376563);
        double r376565 = log(r376564);
        double r376566 = exp(r376565);
        return r376566;
}

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.1
Target13.1
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.1

    \[\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 div-inv13.3

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

    \[\leadsto \color{blue}{\log \left(e^{\sqrt{0.5 \cdot \left(1 + x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}\right)}\]
  6. Using strategy rm
  7. Applied add-exp-log13.4

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

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

Reproduce

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