\frac{\cosh x \cdot \frac{y}{x}}{z}\begin{array}{l}
\mathbf{if}\;\cosh x \cdot \frac{y}{x} \leq -1.9265948427821044 \cdot 10^{+247}:\\
\;\;\;\;\frac{0.5 \cdot \left(y \cdot e^{x}\right) + 0.5 \cdot \left(y \cdot e^{-x}\right)}{x \cdot z}\\
\mathbf{elif}\;\cosh x \cdot \frac{y}{x} \leq 2.3818179904215993 \cdot 10^{+243}:\\
\;\;\;\;\frac{\frac{\cosh x \cdot y}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 \cdot \frac{x \cdot z}{y \cdot \left(e^{x} + e^{-x}\right)}}\\
\end{array}(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
:precision binary64
(if (<= (* (cosh x) (/ y x)) -1.9265948427821044e+247)
(/ (+ (* 0.5 (* y (exp x))) (* 0.5 (* y (exp (- x))))) (* x z))
(if (<= (* (cosh x) (/ y x)) 2.3818179904215993e+243)
(/ (/ (* (cosh x) y) x) z)
(/ 1.0 (* 2.0 (/ (* x z) (* y (+ (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 ((cosh(x) * (y / x)) <= -1.9265948427821044e+247) {
tmp = ((0.5 * (y * exp(x))) + (0.5 * (y * exp(-x)))) / (x * z);
} else if ((cosh(x) * (y / x)) <= 2.3818179904215993e+243) {
tmp = ((cosh(x) * y) / x) / z;
} else {
tmp = 1.0 / (2.0 * ((x * z) / (y * (exp(x) + exp(-x)))));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 8.0 |
|---|---|
| Target | 0.4 |
| Herbie | 0.4 |
if (*.f64 (cosh.f64 x) (/.f64 y x)) < -1.92659484278210436e247Initial program 39.7
Taylor expanded around inf 0.7
if -1.92659484278210436e247 < (*.f64 (cosh.f64 x) (/.f64 y x)) < 2.38181799042159928e243Initial program 0.2
rmApplied associate-*r/_binary64_136600.2
if 2.38181799042159928e243 < (*.f64 (cosh.f64 x) (/.f64 y x)) Initial program 39.1
rmApplied clear-num_binary64_1371739.1
Simplified39.1
Taylor expanded around 0 1.0
Final simplification0.4
herbie shell --seed 2021090
(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))