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 r246992 = 0.5;
        double r246993 = 1.0;
        double r246994 = x;
        double r246995 = 4.0;
        double r246996 = p;
        double r246997 = r246995 * r246996;
        double r246998 = r246997 * r246996;
        double r246999 = r246994 * r246994;
        double r247000 = r246998 + r246999;
        double r247001 = sqrt(r247000);
        double r247002 = r246994 / r247001;
        double r247003 = r246993 + r247002;
        double r247004 = r246992 * r247003;
        double r247005 = sqrt(r247004);
        return r247005;
}

double f(double p, double x) {
        double r247006 = 0.5;
        double r247007 = 1.0;
        double r247008 = x;
        double r247009 = 1.0;
        double r247010 = 4.0;
        double r247011 = p;
        double r247012 = r247010 * r247011;
        double r247013 = r247012 * r247011;
        double r247014 = r247008 * r247008;
        double r247015 = r247013 + r247014;
        double r247016 = sqrt(r247015);
        double r247017 = r247009 / r247016;
        double r247018 = r247008 * r247017;
        double r247019 = r247007 + r247018;
        double r247020 = r247006 * r247019;
        double r247021 = sqrt(r247020);
        double r247022 = exp(r247021);
        double r247023 = log(r247022);
        double r247024 = log(r247023);
        double r247025 = exp(r247024);
        return r247025;
}

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))))))))