Average Error: 13.1 → 13.3
Time: 4.3s
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 \sqrt[3]{{\left(x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} + 1\right)}^{3}}}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}
\sqrt{0.5 \cdot \sqrt[3]{{\left(x \cdot \frac{1}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}} + 1\right)}^{3}}}
double code(double p, double x) {
	return ((double) sqrt(((double) (0.5 * ((double) (1.0 + ((double) (x / ((double) sqrt(((double) (((double) (((double) (4.0 * p)) * p)) + ((double) (x * x))))))))))))));
}
double code(double p, double x) {
	return ((double) sqrt(((double) (0.5 * ((double) cbrt(((double) pow(((double) (((double) (x * ((double) (1.0 / ((double) sqrt(((double) (((double) (((double) (4.0 * p)) * p)) + ((double) (x * x)))))))))) + 1.0)), 3.0))))))));
}

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.3
\[\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 div-inv13.3

    \[\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.2

    \[\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*14.1

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

    \[\leadsto \sqrt{0.5 \cdot \color{blue}{\sqrt[3]{\left(\left(1 + \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) \cdot \left(1 + \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) \cdot \left(1 + \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)}}}\]
  9. Simplified13.3

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

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

Reproduce

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