Average Error: 13.2 → 13.5
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)}\]
\[\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)\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\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)
double f(double p, double x) {
        double r261383 = 0.5;
        double r261384 = 1.0;
        double r261385 = x;
        double r261386 = 4.0;
        double r261387 = p;
        double r261388 = r261386 * r261387;
        double r261389 = r261388 * r261387;
        double r261390 = r261385 * r261385;
        double r261391 = r261389 + r261390;
        double r261392 = sqrt(r261391);
        double r261393 = r261385 / r261392;
        double r261394 = r261384 + r261393;
        double r261395 = r261383 * r261394;
        double r261396 = sqrt(r261395);
        return r261396;
}

double f(double p, double x) {
        double r261397 = 0.5;
        double r261398 = 1.0;
        double r261399 = x;
        double r261400 = 1.0;
        double r261401 = 4.0;
        double r261402 = p;
        double r261403 = r261401 * r261402;
        double r261404 = r261403 * r261402;
        double r261405 = r261399 * r261399;
        double r261406 = r261404 + r261405;
        double r261407 = sqrt(r261406);
        double r261408 = r261400 / r261407;
        double r261409 = r261399 * r261408;
        double r261410 = r261398 + r261409;
        double r261411 = r261397 * r261410;
        double r261412 = sqrt(r261411);
        double r261413 = exp(r261412);
        double r261414 = log(r261413);
        return r261414;
}

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.2
Target13.2
Herbie13.5
\[\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.2

    \[\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.2

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

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

    \[\leadsto \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)\]

Reproduce

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