Average Error: 0.0 → 0.0
Time: 3.4s
Precision: 64
\[\frac{2}{e^{x} + e^{-x}}\]
\[\frac{2}{e^{\log \left(e^{-1 \cdot x} + e^{x}\right)}}\]
\frac{2}{e^{x} + e^{-x}}
\frac{2}{e^{\log \left(e^{-1 \cdot x} + e^{x}\right)}}
double code(double x) {
	return (2.0 / (exp(x) + exp(-x)));
}
double code(double x) {
	return (2.0 / exp(log((exp((-1.0 * 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-exp-log0.0

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

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

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

Reproduce

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