Average Error: 13.9 → 13.9
Time: 13.4s
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)}\]
\[\sqrt{\log \left(e^{1 + \frac{x}{\sqrt{x \cdot x + p \cdot \left(4 \cdot p\right)}}}\right) \cdot 0.5}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{\log \left(e^{1 + \frac{x}{\sqrt{x \cdot x + p \cdot \left(4 \cdot p\right)}}}\right) \cdot 0.5}
double f(double p, double x) {
        double r11706876 = 0.5;
        double r11706877 = 1.0;
        double r11706878 = x;
        double r11706879 = 4.0;
        double r11706880 = p;
        double r11706881 = r11706879 * r11706880;
        double r11706882 = r11706881 * r11706880;
        double r11706883 = r11706878 * r11706878;
        double r11706884 = r11706882 + r11706883;
        double r11706885 = sqrt(r11706884);
        double r11706886 = r11706878 / r11706885;
        double r11706887 = r11706877 + r11706886;
        double r11706888 = r11706876 * r11706887;
        double r11706889 = sqrt(r11706888);
        return r11706889;
}

double f(double p, double x) {
        double r11706890 = 1.0;
        double r11706891 = x;
        double r11706892 = r11706891 * r11706891;
        double r11706893 = p;
        double r11706894 = 4.0;
        double r11706895 = r11706894 * r11706893;
        double r11706896 = r11706893 * r11706895;
        double r11706897 = r11706892 + r11706896;
        double r11706898 = sqrt(r11706897);
        double r11706899 = r11706891 / r11706898;
        double r11706900 = r11706890 + r11706899;
        double r11706901 = exp(r11706900);
        double r11706902 = log(r11706901);
        double r11706903 = 0.5;
        double r11706904 = r11706902 * r11706903;
        double r11706905 = sqrt(r11706904);
        return r11706905;
}

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

    \[\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-inv14.1

    \[\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-sqr-sqrt14.9

    \[\leadsto \sqrt{0.5 \cdot \left(1 + x \cdot \color{blue}{\left(\sqrt{\frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}} \cdot \sqrt{\frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}\right)}\]
  6. Applied associate-*r*15.0

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

    \[\leadsto \sqrt{0.5 \cdot \left(1 + \color{blue}{\log \left(e^{\left(x \cdot \sqrt{\frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right) \cdot \sqrt{\frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right)}\right)}\]
  9. Applied add-log-exp15.0

    \[\leadsto \sqrt{0.5 \cdot \left(\color{blue}{\log \left(e^{1}\right)} + \log \left(e^{\left(x \cdot \sqrt{\frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right) \cdot \sqrt{\frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right)\right)}\]
  10. Applied sum-log15.0

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

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

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

Reproduce

herbie shell --seed 2019172 
(FPCore (p x)
  :name "Given's Rotation SVD example"
  :pre (< 1e-150 (fabs x) 1e+150)

  :herbie-target
  (sqrt (+ 0.5 (/ (copysign 0.5 x) (hypot 1.0 (/ (* 2.0 p) x)))))

  (sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x))))))))