Average Error: 13.6 → 13.6
Time: 4.9s
Precision: binary64
\[10^{-150} < \left|x\right| \land \left|x\right| < 10^{+150}\]
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\]
\[\sqrt{0.5 \cdot \frac{\frac{1 + {\left({\left(\frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}^{3}\right)}^{3}}{1 + \left({\left(\frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}^{6} - {\left(\frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}^{3}\right)}}{1 + \left(\frac{x \cdot x}{p \cdot \left(p \cdot 4\right) + x \cdot x} - \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\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 \frac{\frac{1 + {\left({\left(\frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}^{3}\right)}^{3}}{1 + \left({\left(\frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}^{6} - {\left(\frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}^{3}\right)}}{1 + \left(\frac{x \cdot x}{p \cdot \left(p \cdot 4\right) + x \cdot x} - \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}}
(FPCore (p x)
 :precision binary64
 (sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x))))))))
(FPCore (p x)
 :precision binary64
 (sqrt
  (*
   0.5
   (/
    (/
     (+ 1.0 (pow (pow (/ x (sqrt (+ (* p (* p 4.0)) (* x x)))) 3.0) 3.0))
     (+
      1.0
      (-
       (pow (/ x (sqrt (+ (* p (* p 4.0)) (* x x)))) 6.0)
       (pow (/ x (sqrt (+ (* p (* p 4.0)) (* x x)))) 3.0))))
    (+
     1.0
     (-
      (/ (* x x) (+ (* p (* p 4.0)) (* x x)))
      (/ x (sqrt (+ (* p (* p 4.0)) (* x x))))))))))
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 * (((1.0 + pow(pow((x / sqrt((p * (p * 4.0)) + (x * x))), 3.0), 3.0)) / (1.0 + (pow((x / sqrt((p * (p * 4.0)) + (x * x))), 6.0) - pow((x / sqrt((p * (p * 4.0)) + (x * x))), 3.0)))) / (1.0 + (((x * x) / ((p * (p * 4.0)) + (x * x))) - (x / sqrt((p * (p * 4.0)) + (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.6
Target13.6
Herbie13.6
\[\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.6

    \[\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 flip3-+_binary6413.6

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

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

    \[\leadsto \sqrt{0.5 \cdot \frac{1 + {\left(\frac{x}{\sqrt{p \cdot \left(4 \cdot p\right) + x \cdot x}}\right)}^{3}}{\color{blue}{1 + \left(\frac{x \cdot x}{p \cdot \left(4 \cdot p\right) + x \cdot x} - \frac{x}{\sqrt{p \cdot \left(4 \cdot p\right) + x \cdot x}}\right)}}}\]
  6. Using strategy rm
  7. Applied flip3-+_binary6413.6

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

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

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

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

Reproduce

herbie shell --seed 2020233 
(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.0 (/ (* 2.0 p) x)))))

  (sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x))))))))