Average Error: 0.0 → 0.2
Time: 1.7s
Precision: 64
\[\frac{2}{e^{x} + e^{-x}}\]
\[\log \left(e^{\frac{2}{e^{x} + e^{-x}}}\right)\]
\frac{2}{e^{x} + e^{-x}}
\log \left(e^{\frac{2}{e^{x} + e^{-x}}}\right)
double code(double x) {
	return (2.0 / (exp(x) + exp(-x)));
}
double code(double x) {
	return log(exp((2.0 / (exp(x) + exp(-x)))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.0

    \[\frac{2}{e^{x} + e^{-x}}\]
  2. Using strategy rm
  3. Applied add-log-exp0.2

    \[\leadsto \color{blue}{\log \left(e^{\frac{2}{e^{x} + e^{-x}}}\right)}\]
  4. Final simplification0.2

    \[\leadsto \log \left(e^{\frac{2}{e^{x} + e^{-x}}}\right)\]

Reproduce

herbie shell --seed 2020066 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic secant"
  :precision binary64
  (/ 2 (+ (exp x) (exp (- x)))))