\frac{\cosh x \cdot \frac{y}{x}}{z}\begin{array}{l}
\mathbf{if}\;\cosh x \cdot \frac{y}{x} \le -7.55329883715929418 \cdot 10^{264} \lor \neg \left(\cosh x \cdot \frac{y}{x} \le 1.7336052333149463 \cdot 10^{303}\right):\\
\;\;\;\;\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z \cdot \left(2 \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(e^{x}, \frac{1}{2}, \frac{\frac{1}{2}}{e^{x}}\right) \cdot \frac{y}{x}}{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 VAR;
if ((((cosh(x) * (y / x)) <= -7.553298837159294e+264) || !((cosh(x) * (y / x)) <= 1.7336052333149463e+303))) {
VAR = (((exp(x) + exp(-x)) * y) / (z * (2.0 * x)));
} else {
VAR = ((fma(exp(x), 0.5, (0.5 / exp(x))) * (y / x)) / z);
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 7.8 |
|---|---|
| Target | 0.5 |
| Herbie | 0.3 |
if (* (cosh x) (/ y x)) < -7.553298837159294e+264 or 1.7336052333149463e+303 < (* (cosh x) (/ y x)) Initial program 50.4
rmApplied cosh-def50.4
Applied frac-times50.4
Applied associate-/l/0.5
if -7.553298837159294e+264 < (* (cosh x) (/ y x)) < 1.7336052333149463e+303Initial program 0.2
Taylor expanded around inf 0.2
Simplified0.2
Final simplification0.3
herbie shell --seed 2020078 +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))