Average Error: 13.2 → 13.2
Time: 6.4s
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(\sqrt{e^{\sqrt{0.5 \cdot \sqrt[3]{{\left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}}}}\right) + \log \left(\sqrt{e^{\sqrt{0.5 \cdot \left(1 + \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(\sqrt{e^{\sqrt{0.5 \cdot \sqrt[3]{{\left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}^{3}}}}}\right) + \log \left(\sqrt{e^{\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}}}\right)
double f(double p, double x) {
        double r268779 = 0.5;
        double r268780 = 1.0;
        double r268781 = x;
        double r268782 = 4.0;
        double r268783 = p;
        double r268784 = r268782 * r268783;
        double r268785 = r268784 * r268783;
        double r268786 = r268781 * r268781;
        double r268787 = r268785 + r268786;
        double r268788 = sqrt(r268787);
        double r268789 = r268781 / r268788;
        double r268790 = r268780 + r268789;
        double r268791 = r268779 * r268790;
        double r268792 = sqrt(r268791);
        return r268792;
}

double f(double p, double x) {
        double r268793 = 0.5;
        double r268794 = 1.0;
        double r268795 = x;
        double r268796 = 4.0;
        double r268797 = p;
        double r268798 = r268796 * r268797;
        double r268799 = r268798 * r268797;
        double r268800 = r268795 * r268795;
        double r268801 = r268799 + r268800;
        double r268802 = sqrt(r268801);
        double r268803 = r268795 / r268802;
        double r268804 = r268794 + r268803;
        double r268805 = 3.0;
        double r268806 = pow(r268804, r268805);
        double r268807 = cbrt(r268806);
        double r268808 = r268793 * r268807;
        double r268809 = sqrt(r268808);
        double r268810 = exp(r268809);
        double r268811 = sqrt(r268810);
        double r268812 = log(r268811);
        double r268813 = r268793 * r268804;
        double r268814 = sqrt(r268813);
        double r268815 = exp(r268814);
        double r268816 = sqrt(r268815);
        double r268817 = log(r268816);
        double r268818 = r268812 + r268817;
        return r268818;
}

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 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 add-sqr-sqrt13.2

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

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

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

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

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

Reproduce

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