Average Error: 13.2 → 13.6
Time: 14.5s
Precision: 64
\[10^{-150} \lt \left|x\right| \lt 10^{+150}\]
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\]
\[\sqrt{\sqrt{\log \left(e^{0.5 + \frac{0.5}{\sqrt{x \cdot x + \left(p \cdot p\right) \cdot 4}} \cdot x}\right)} \cdot \log \left(e^{\sqrt{0.5 + x \cdot \frac{0.5}{\sqrt{\sqrt[3]{x \cdot x + \left(p \cdot p\right) \cdot 4}} \cdot \sqrt{\sqrt[3]{x \cdot x + \left(p \cdot p\right) \cdot 4} \cdot \sqrt[3]{x \cdot x + \left(p \cdot p\right) \cdot 4}}}}}\right)}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{\sqrt{\log \left(e^{0.5 + \frac{0.5}{\sqrt{x \cdot x + \left(p \cdot p\right) \cdot 4}} \cdot x}\right)} \cdot \log \left(e^{\sqrt{0.5 + x \cdot \frac{0.5}{\sqrt{\sqrt[3]{x \cdot x + \left(p \cdot p\right) \cdot 4}} \cdot \sqrt{\sqrt[3]{x \cdot x + \left(p \cdot p\right) \cdot 4} \cdot \sqrt[3]{x \cdot x + \left(p \cdot p\right) \cdot 4}}}}}\right)}
double f(double p, double x) {
        double r9219155 = 0.5;
        double r9219156 = 1.0;
        double r9219157 = x;
        double r9219158 = 4.0;
        double r9219159 = p;
        double r9219160 = r9219158 * r9219159;
        double r9219161 = r9219160 * r9219159;
        double r9219162 = r9219157 * r9219157;
        double r9219163 = r9219161 + r9219162;
        double r9219164 = sqrt(r9219163);
        double r9219165 = r9219157 / r9219164;
        double r9219166 = r9219156 + r9219165;
        double r9219167 = r9219155 * r9219166;
        double r9219168 = sqrt(r9219167);
        return r9219168;
}

double f(double p, double x) {
        double r9219169 = 0.5;
        double r9219170 = x;
        double r9219171 = r9219170 * r9219170;
        double r9219172 = p;
        double r9219173 = r9219172 * r9219172;
        double r9219174 = 4.0;
        double r9219175 = r9219173 * r9219174;
        double r9219176 = r9219171 + r9219175;
        double r9219177 = sqrt(r9219176);
        double r9219178 = r9219169 / r9219177;
        double r9219179 = r9219178 * r9219170;
        double r9219180 = r9219169 + r9219179;
        double r9219181 = exp(r9219180);
        double r9219182 = log(r9219181);
        double r9219183 = sqrt(r9219182);
        double r9219184 = cbrt(r9219176);
        double r9219185 = sqrt(r9219184);
        double r9219186 = r9219184 * r9219184;
        double r9219187 = sqrt(r9219186);
        double r9219188 = r9219185 * r9219187;
        double r9219189 = r9219169 / r9219188;
        double r9219190 = r9219170 * r9219189;
        double r9219191 = r9219169 + r9219190;
        double r9219192 = sqrt(r9219191);
        double r9219193 = exp(r9219192);
        double r9219194 = log(r9219193);
        double r9219195 = r9219183 * r9219194;
        double r9219196 = sqrt(r9219195);
        return r9219196;
}

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.6
\[\sqrt{\frac{1}{2} + \frac{\mathsf{copysign}\left(\frac{1}{2}, 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. Simplified13.2

    \[\leadsto \color{blue}{\sqrt{0.5 \cdot \frac{x}{\sqrt{x \cdot x + \left(p \cdot p\right) \cdot 4}} + 0.5}}\]
  3. Using strategy rm
  4. Applied add-log-exp13.2

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

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

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

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

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

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

    \[\leadsto \sqrt{\color{blue}{\sqrt{0.5 + \frac{0.5}{\sqrt{\left(p \cdot p\right) \cdot 4 + x \cdot x}} \cdot x} \cdot \log \left(e^{\sqrt{0.5 + \frac{0.5}{\sqrt{\left(p \cdot p\right) \cdot 4 + x \cdot x}} \cdot x}}\right)}}\]
  12. Using strategy rm
  13. Applied add-log-exp13.2

    \[\leadsto \sqrt{\sqrt{\color{blue}{\log \left(e^{0.5 + \frac{0.5}{\sqrt{\left(p \cdot p\right) \cdot 4 + x \cdot x}} \cdot x}\right)}} \cdot \log \left(e^{\sqrt{0.5 + \frac{0.5}{\sqrt{\left(p \cdot p\right) \cdot 4 + x \cdot x}} \cdot x}}\right)}\]
  14. Using strategy rm
  15. Applied add-cube-cbrt13.5

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

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

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

Reproduce

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

  :herbie-target
  (sqrt (+ 1/2 (/ (copysign 1/2 x) (hypot 1 (/ (* 2 p) x)))))

  (sqrt (* 0.5 (+ 1 (/ x (sqrt (+ (* (* 4 p) p) (* x x))))))))