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




Bits error versus p




Bits error versus x
Results
| Original | 13.2 |
|---|---|
| Target | 13.2 |
| Herbie | 13.5 |
Initial program 13.2
rmApplied div-inv13.5
rmApplied add-log-exp13.5
rmApplied add-exp-log13.5
Final simplification13.5
herbie shell --seed 2020049 +o rules:numerics
(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))))))))