Average Error: 13.2 → 13.4
Time: 5.5s
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)}\]
\[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 r328752 = 0.5;
        double r328753 = 1.0;
        double r328754 = x;
        double r328755 = 4.0;
        double r328756 = p;
        double r328757 = r328755 * r328756;
        double r328758 = r328757 * r328756;
        double r328759 = r328754 * r328754;
        double r328760 = r328758 + r328759;
        double r328761 = sqrt(r328760);
        double r328762 = r328754 / r328761;
        double r328763 = r328753 + r328762;
        double r328764 = r328752 * r328763;
        double r328765 = sqrt(r328764);
        return r328765;
}

double f(double p, double x) {
        double r328766 = 0.5;
        double r328767 = 1.0;
        double r328768 = x;
        double r328769 = 1.0;
        double r328770 = 4.0;
        double r328771 = p;
        double r328772 = r328770 * r328771;
        double r328773 = r328772 * r328771;
        double r328774 = r328768 * r328768;
        double r328775 = r328773 + r328774;
        double r328776 = sqrt(r328775);
        double r328777 = r328769 / r328776;
        double r328778 = r328768 * r328777;
        double r328779 = r328767 + r328778;
        double r328780 = r328766 * r328779;
        double r328781 = sqrt(r328780);
        double r328782 = exp(r328781);
        double r328783 = log(r328782);
        double r328784 = log(r328783);
        double r328785 = exp(r328784);
        return r328785;
}

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.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.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.4

    \[\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 2020039 
(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))))))))