\frac{2}{e^{x} + e^{-x}}\begin{array}{l}
\mathbf{if}\;e^{x} + e^{-x} \le 2.0000000483992446:\\
\;\;\;\;\frac{2}{\mathsf{fma}\left(x, x, \mathsf{fma}\left(\frac{1}{12}, {x}^{4}, 2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\left(\sqrt[3]{e^{x} + e^{-x}} \cdot \sqrt[3]{e^{x} + e^{-x}}\right) \cdot \sqrt[3]{e^{x} + e^{-x}}}\\
\end{array}double code(double x) {
return (2.0 / (exp(x) + exp(-x)));
}
double code(double x) {
double VAR;
if (((exp(x) + exp(-x)) <= 2.0000000483992446)) {
VAR = (2.0 / fma(x, x, fma(0.08333333333333333, pow(x, 4.0), 2.0)));
} else {
VAR = (2.0 / ((cbrt((exp(x) + exp(-x))) * cbrt((exp(x) + exp(-x)))) * cbrt((exp(x) + exp(-x)))));
}
return VAR;
}



Bits error versus x
Results
if (+ (exp x) (exp (- x))) < 2.0000000483992446Initial program 0.0
Taylor expanded around 0 0.0
Simplified0.0
if 2.0000000483992446 < (+ (exp x) (exp (- x))) Initial program 0.0
rmApplied add-cube-cbrt0.0
Final simplification0.0
herbie shell --seed 2020100 +o rules:numerics
(FPCore (x)
:name "Hyperbolic secant"
:precision binary64
(/ 2 (+ (exp x) (exp (- x)))))