\frac{\cosh x \cdot \frac{y}{x}}{z}\begin{array}{l}
\mathbf{if}\;z \leq -1.5319762094625696 \cdot 10^{+39}:\\
\;\;\;\;0.041666666666666664 \cdot \frac{{x}^{3} \cdot y}{z} + \left(0.5 \cdot \frac{x \cdot y}{z} + \left(0.001388888888888889 \cdot \frac{y \cdot {x}^{5}}{z} + \frac{y}{z \cdot x}\right)\right)\\
\mathbf{elif}\;z \leq 8.670599136611819 \cdot 10^{-21}:\\
\;\;\;\;\cosh x \cdot \frac{\frac{y}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot \left(e^{x} + e^{-x}\right)}{z \cdot x}\\
\end{array}(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
:precision binary64
(if (<= z -1.5319762094625696e+39)
(+
(* 0.041666666666666664 (/ (* (pow x 3.0) y) z))
(+
(* 0.5 (/ (* x y) z))
(+ (* 0.001388888888888889 (/ (* y (pow x 5.0)) z)) (/ y (* z x)))))
(if (<= z 8.670599136611819e-21)
(* (cosh x) (/ (/ y x) z))
(* 0.5 (/ (* y (+ (exp x) (exp (- x)))) (* z 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 (z <= -1.5319762094625696e+39) {
tmp = (0.041666666666666664 * ((pow(x, 3.0) * y) / z)) + ((0.5 * ((x * y) / z)) + ((0.001388888888888889 * ((y * pow(x, 5.0)) / z)) + (y / (z * x))));
} else if (z <= 8.670599136611819e-21) {
tmp = cosh(x) * ((y / x) / z);
} else {
tmp = 0.5 * ((y * (exp(x) + exp(-x))) / (z * x));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 7.2 |
|---|---|
| Target | 0.4 |
| Herbie | 0.5 |
if z < -1.5319762094625696e39Initial program 11.3
Taylor expanded around 0 0.8
if -1.5319762094625696e39 < z < 8.67059913661181889e-21Initial program 0.5
rmApplied *-un-lft-identity_binary64_140590.5
Applied times-frac_binary64_140650.5
if 8.67059913661181889e-21 < z Initial program 10.9
Taylor expanded around inf 0.3
Final simplification0.5
herbie shell --seed 2021014
(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))