\frac{2}{e^{x} + e^{-x}}e^{\log 2 - \log \left(e^{x} + e^{-x}\right)}(FPCore (x) :precision binary64 (/ 2.0 (+ (exp x) (exp (- x)))))
(FPCore (x) :precision binary64 (exp (- (log 2.0) (log (+ (exp x) (exp (- x)))))))
double code(double x) {
return 2.0 / (exp(x) + exp(-x));
}
double code(double x) {
return exp(log(2.0) - log(exp(x) + exp(-x)));
}



Bits error versus x
Results
Initial program 0.0
rmApplied add-exp-log_binary64_11390.0
Applied add-exp-log_binary64_11390.0
Applied div-exp_binary64_11520.0
Final simplification0.0
herbie shell --seed 2021019
(FPCore (x)
:name "Hyperbolic secant"
:precision binary64
(/ 2.0 (+ (exp x) (exp (- x)))))