\frac{\cosh x \cdot \frac{y}{x}}{z}\begin{array}{l}
\mathbf{if}\;\cosh x \cdot \frac{y}{x} \le -1.551768073007693 \cdot 10^{100}:\\
\;\;\;\;\frac{1}{\frac{x}{\frac{y}{z} \cdot \mathsf{fma}\left(e^{x}, \frac{1}{2}, \frac{\frac{1}{2}}{e^{x}}\right)}}\\
\mathbf{elif}\;\cosh x \cdot \frac{y}{x} \le 2.5851757423207426 \cdot 10^{215}:\\
\;\;\;\;\frac{\mathsf{fma}\left(e^{x}, \frac{1}{2}, \frac{\frac{1}{2}}{e^{x}}\right) \cdot \frac{y}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \mathsf{fma}\left(e^{x}, \frac{1}{2}, \frac{\frac{1}{2}}{e^{x}}\right)}{x \cdot z}\\
\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.551768073007693e+100)) {
temp = (1.0 / (x / ((y / z) * fma(exp(x), 0.5, (0.5 / exp(x))))));
} else {
double temp_1;
if (((cosh(x) * (y / x)) <= 2.5851757423207426e+215)) {
temp_1 = ((fma(exp(x), 0.5, (0.5 / exp(x))) * (y / x)) / z);
} else {
temp_1 = ((y * fma(exp(x), 0.5, (0.5 / exp(x)))) / (x * z));
}
temp = temp_1;
}
return temp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 7.6 |
|---|---|
| Target | 0.4 |
| Herbie | 0.9 |
if (* (cosh x) (/ y x)) < -1.551768073007693e+100Initial program 17.1
Taylor expanded around inf 2.3
Simplified2.8
rmApplied associate-*r/2.7
rmApplied clear-num2.8
if -1.551768073007693e+100 < (* (cosh x) (/ y x)) < 2.5851757423207426e+215Initial program 0.2
Taylor expanded around inf 0.2
Simplified0.3
if 2.5851757423207426e+215 < (* (cosh x) (/ y x)) Initial program 32.0
Taylor expanded around inf 0.9
Simplified0.7
rmApplied associate-*r/0.7
rmApplied associate-*l/0.7
Applied associate-/l/0.9
Final simplification0.9
herbie shell --seed 2020049 +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))