Average Error: 13.1 → 13.4
Time: 6.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)}\]
\[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 r245273 = 0.5;
        double r245274 = 1.0;
        double r245275 = x;
        double r245276 = 4.0;
        double r245277 = p;
        double r245278 = r245276 * r245277;
        double r245279 = r245278 * r245277;
        double r245280 = r245275 * r245275;
        double r245281 = r245279 + r245280;
        double r245282 = sqrt(r245281);
        double r245283 = r245275 / r245282;
        double r245284 = r245274 + r245283;
        double r245285 = r245273 * r245284;
        double r245286 = sqrt(r245285);
        return r245286;
}

double f(double p, double x) {
        double r245287 = 0.5;
        double r245288 = 1.0;
        double r245289 = x;
        double r245290 = 1.0;
        double r245291 = 4.0;
        double r245292 = p;
        double r245293 = r245291 * r245292;
        double r245294 = r245293 * r245292;
        double r245295 = r245289 * r245289;
        double r245296 = r245294 + r245295;
        double r245297 = sqrt(r245296);
        double r245298 = r245290 / r245297;
        double r245299 = r245289 * r245298;
        double r245300 = r245288 + r245299;
        double r245301 = r245287 * r245300;
        double r245302 = sqrt(r245301);
        double r245303 = exp(r245302);
        double r245304 = log(r245303);
        double r245305 = log(r245304);
        double r245306 = exp(r245305);
        return r245306;
}

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 +o rules:numerics
(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))))))))