\frac{x \cdot \frac{\sin y}{y}}{z}\begin{array}{l}
\mathbf{if}\;x \cdot \frac{\sin y}{y} \le 4.33073453739588 \cdot 10^{-310}:\\
\;\;\;\;\frac{\frac{\sin y}{y}}{\frac{z}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{\frac{y}{\sin y}}}{z}\\
\end{array}double code(double x, double y, double z) {
return ((x * (sin(y) / y)) / z);
}
double code(double x, double y, double z) {
double VAR;
if (((x * (sin(y) / y)) <= 4.3307345373959e-310)) {
VAR = ((sin(y) / y) / (z / x));
} else {
VAR = ((x / (y / sin(y))) / z);
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 2.7 |
|---|---|
| Target | 0.3 |
| Herbie | 1.7 |
if (* x (/ (sin y) y)) < 4.3307345373959e-310Initial program 4.7
rmApplied *-commutative4.7
Applied associate-/l*2.8
if 4.3307345373959e-310 < (* x (/ (sin y) y)) Initial program 0.2
rmApplied clear-num0.2
Applied un-div-inv0.2
Final simplification1.7
herbie shell --seed 2020071 +o rules:numerics
(FPCore (x y z)
:name "Linear.Quaternion:$ctanh from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< z -4.2173720203427147e-29) (/ (* x (/ 1 (/ y (sin y)))) z) (if (< z 4.446702369113811e+64) (/ x (* z (/ y (sin y)))) (/ (* x (/ 1 (/ y (sin y)))) z)))
(/ (* x (/ (sin y) y)) z))