Average Error: 13.2 → 13.2
Time: 5.7s
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 + 1 \cdot \frac{x}{\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 + 1 \cdot \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}\right)
double f(double p, double x) {
        double r371294 = 0.5;
        double r371295 = 1.0;
        double r371296 = x;
        double r371297 = 4.0;
        double r371298 = p;
        double r371299 = r371297 * r371298;
        double r371300 = r371299 * r371298;
        double r371301 = r371296 * r371296;
        double r371302 = r371300 + r371301;
        double r371303 = sqrt(r371302);
        double r371304 = r371296 / r371303;
        double r371305 = r371295 + r371304;
        double r371306 = r371294 * r371305;
        double r371307 = sqrt(r371306);
        return r371307;
}

double f(double p, double x) {
        double r371308 = 0.5;
        double r371309 = 1.0;
        double r371310 = 1.0;
        double r371311 = x;
        double r371312 = 4.0;
        double r371313 = p;
        double r371314 = r371312 * r371313;
        double r371315 = r371314 * r371313;
        double r371316 = r371311 * r371311;
        double r371317 = r371315 + r371316;
        double r371318 = sqrt(r371317);
        double r371319 = r371311 / r371318;
        double r371320 = r371310 * r371319;
        double r371321 = r371309 + r371320;
        double r371322 = r371308 * r371321;
        double r371323 = sqrt(r371322);
        double r371324 = exp(r371323);
        double r371325 = log(r371324);
        return r371325;
}

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

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

    \[\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 *-un-lft-identity13.5

    \[\leadsto \log \left(e^{\sqrt{0.5 \cdot \left(1 + \color{blue}{\left(1 \cdot x\right)} \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}\right)\]
  8. Applied associate-*l*13.5

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

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

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

Reproduce

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