\frac{\cosh x \cdot \frac{y}{x}}{z}\begin{array}{l}
\mathbf{if}\;z \le -3.41133532920946507 \cdot 10^{-19} \lor \neg \left(z \le 2.23617164171117214 \cdot 10^{-52}\right):\\
\;\;\;\;\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z \cdot \left(2 \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{e^{x} + e^{-x}}{2}}{x} \cdot \frac{y}{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 (((z <= -3.411335329209465e-19) || !(z <= 2.236171641711172e-52))) {
temp = (((exp(x) + exp(-x)) * y) / (z * (2.0 * x)));
} else {
temp = ((((exp(x) + exp(-x)) / 2.0) / x) * (y / z));
}
return temp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 7.8 |
|---|---|
| Target | 0.4 |
| Herbie | 0.4 |
if z < -3.411335329209465e-19 or 2.236171641711172e-52 < z Initial program 11.1
rmApplied cosh-def11.1
Applied frac-times11.1
Applied associate-/l/0.4
if -3.411335329209465e-19 < z < 2.236171641711172e-52Initial program 0.3
rmApplied cosh-def0.3
Applied frac-times0.3
Applied associate-/l/22.3
rmApplied *-commutative22.3
Applied times-frac0.4
Simplified0.4
Final simplification0.4
herbie shell --seed 2020066 +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))