\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(\sqrt{1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}} \cdot \sqrt{1 + \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
(*
(sqrt (+ 1.0 (/ x (sqrt (+ (* p (* p 4.0)) (* x x))))))
(sqrt (+ 1.0 (/ 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 * (sqrt(1.0 + (x / sqrt((p * (p * 4.0)) + (x * x)))) * sqrt(1.0 + (x / sqrt((p * (p * 4.0)) + (x * x))))));
}




Bits error versus p




Bits error versus x
Results
| Original | 13.4 |
|---|---|
| Target | 13.4 |
| Herbie | 13.4 |
Initial program 13.4
rmApplied add-sqr-sqrt_binary6413.4
Simplified13.4
Simplified13.4
Final simplification13.4
herbie shell --seed 2020253
(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))))))))