Average Error: 13.1 → 13.1
Time: 5.6s
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)}\]
\[\sqrt{0.5 \cdot \left(\left(\log \left(\sqrt{e^{1}}\right) + \log \left(\sqrt{e^{\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right)\right) + \frac{1}{2} \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)}
\sqrt{0.5 \cdot \left(\left(\log \left(\sqrt{e^{1}}\right) + \log \left(\sqrt{e^{\frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right)\right) + \frac{1}{2} \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)\right)}
double code(double p, double x) {
	return sqrt((0.5 * (1.0 + (x / sqrt((((4.0 * p) * p) + (x * x)))))));
}
double code(double p, double x) {
	return sqrt((0.5 * ((log(sqrt(exp(1.0))) + log(sqrt(exp((x / sqrt((((4.0 * p) * p) + (x * x)))))))) + (0.5 * (1.0 + (x / sqrt((((4.0 * p) * p) + (x * x)))))))));
}

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.1
\[\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 add-log-exp13.1

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

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

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

    \[\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)}}\]
  7. Using strategy rm
  8. Applied add-sqr-sqrt13.1

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

    \[\leadsto \sqrt{0.5 \cdot \color{blue}{\left(\log \left(\sqrt{e^{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right) + \log \left(\sqrt{e^{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right)\right)}}\]
  10. Using strategy rm
  11. Applied pow1/213.1

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

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

    \[\leadsto \sqrt{0.5 \cdot \left(\log \left(\sqrt{e^{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}}\right) + \frac{1}{2} \cdot \color{blue}{\left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\right)}\]
  14. Using strategy rm
  15. Applied exp-sum13.1

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

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

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

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

Reproduce

herbie shell --seed 2020091 
(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))))))))