\frac{2}{e^{x} + e^{-x}}
\begin{array}{l}
t_0 := \sqrt{e^{x}}\\
\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2}{\mathsf{fma}\left(t_0, t_0, e^{-x}\right)}\right)\right)
\end{array}
(FPCore (x) :precision binary64 (/ 2.0 (+ (exp x) (exp (- x)))))
(FPCore (x) :precision binary64 (let* ((t_0 (sqrt (exp x)))) (expm1 (log1p (/ 2.0 (fma t_0 t_0 (exp (- x))))))))
double code(double x) {
return 2.0 / (exp(x) + exp(-x));
}
double code(double x) {
double t_0 = sqrt(exp(x));
return expm1(log1p(2.0 / fma(t_0, t_0, exp(-x))));
}



Bits error versus x
Initial program 0.0
Applied add-sqr-sqrt_binary640.0
Applied fma-def_binary640.0
Applied expm1-log1p-u_binary640.0
Final simplification0.0
herbie shell --seed 2022082
(FPCore (x)
:name "Hyperbolic secant"
:precision binary64
(/ 2.0 (+ (exp x) (exp (- x)))))