\frac{\cosh x \cdot \frac{y}{x}}{z}\begin{array}{l}
\mathbf{if}\;y \leq -2.1664839211293362 \cdot 10^{+74}:\\
\;\;\;\;\frac{y}{x \cdot z} \cdot \cosh x\\
\mathbf{elif}\;y \leq 1.9232029565270297 \cdot 10^{-141}:\\
\;\;\;\;\frac{\frac{y \cdot \left(e^{x} + e^{-x}\right)}{x \cdot 2}}{z}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\frac{y}{x \cdot z} \cdot \left(e^{x} + e^{-x}\right)\right)\\
\end{array}(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
:precision binary64
(if (<= y -2.1664839211293362e+74)
(* (/ y (* x z)) (cosh x))
(if (<= y 1.9232029565270297e-141)
(/ (/ (* y (+ (exp x) (exp (- x)))) (* x 2.0)) z)
(* 0.5 (* (/ y (* x z)) (+ (exp x) (exp (- x))))))))double code(double x, double y, double z) {
return (cosh(x) * (y / x)) / z;
}
double code(double x, double y, double z) {
double tmp;
if (y <= -2.1664839211293362e+74) {
tmp = (y / (x * z)) * cosh(x);
} else if (y <= 1.9232029565270297e-141) {
tmp = ((y * (exp(x) + exp(-x))) / (x * 2.0)) / z;
} else {
tmp = 0.5 * ((y / (x * z)) * (exp(x) + exp(-x)));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 7.5 |
|---|---|
| Target | 0.5 |
| Herbie | 1.4 |
if y < -2.1664839211293362e74Initial program 28.6
rmApplied clear-num_binary6428.7
Simplified28.7
rmApplied *-un-lft-identity_binary6428.7
Applied add-sqr-sqrt_binary6428.7
Applied times-frac_binary6428.7
Simplified28.7
Simplified0.3
if -2.1664839211293362e74 < y < 1.9232029565270297e-141Initial program 0.9
rmApplied div-inv_binary641.0
Applied associate-*r*_binary641.0
Simplified1.0
rmApplied cosh-def_binary641.0
Applied associate-*r/_binary641.0
Applied frac-times_binary640.9
if 1.9232029565270297e-141 < y Initial program 11.6
Taylor expanded around inf 2.7
Simplified2.7
Final simplification1.4
herbie shell --seed 2021118
(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))