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




Bits error versus p




Bits error versus x
Results
| Original | 13.0 |
|---|---|
| Target | 13.0 |
| Herbie | 13.0 |
Initial program 13.0
rmApplied add-log-exp13.0
Applied add-log-exp13.0
Applied sum-log13.0
Simplified13.0
rmApplied flip3-+13.0
Simplified13.0
Final simplification13.0
herbie shell --seed 2020053 +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))))))))