\frac{\cosh x \cdot \frac{y}{x}}{z}\begin{array}{l}
\mathbf{if}\;\cosh x \cdot \frac{y}{x} \le -1.865052624181062 \cdot 10^{247}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{2}, x \cdot \frac{y}{z}, \frac{y}{x \cdot z}\right)\\
\mathbf{elif}\;\cosh x \cdot \frac{y}{x} \le 2.4776903717072572 \cdot 10^{243}:\\
\;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{x \cdot y}{z}, \frac{1}{\frac{x \cdot z}{y}}\right)\\
\end{array}double code(double x, double y, double z) {
return ((cosh(x) * (y / x)) / z);
}
double code(double x, double y, double z) {
double temp;
if (((cosh(x) * (y / x)) <= -1.865052624181062e+247)) {
temp = fma(0.5, (x * (y / z)), (y / (x * z)));
} else {
double temp_1;
if (((cosh(x) * (y / x)) <= 2.477690371707257e+243)) {
temp_1 = ((cosh(x) * (y / x)) / z);
} else {
temp_1 = fma(0.5, ((x * y) / z), (1.0 / ((x * z) / y)));
}
temp = temp_1;
}
return temp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 7.9 |
|---|---|
| Target | 0.5 |
| Herbie | 0.5 |
if (* (cosh x) (/ y x)) < -1.865052624181062e+247Initial program 38.8
Taylor expanded around 0 1.3
Simplified1.3
rmApplied *-un-lft-identity1.3
Applied times-frac1.3
Simplified1.3
if -1.865052624181062e+247 < (* (cosh x) (/ y x)) < 2.477690371707257e+243Initial program 0.2
if 2.477690371707257e+243 < (* (cosh x) (/ y x)) Initial program 39.3
Taylor expanded around 0 1.5
Simplified1.5
rmApplied clear-num1.6
Final simplification0.5
herbie shell --seed 2020060 +o rules:numerics
(FPCore (x y z)
:name "Linear.Quaternion:$ctan from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< y -4.618902267687042e-52) (* (/ (/ y z) x) (cosh x)) (if (< y 1.0385305359351529e-39) (/ (/ (* (cosh x) y) x) z) (* (/ (/ y z) x) (cosh x))))
(/ (* (cosh x) (/ y x)) z))