Average Error: 0.0 → 0.0
Time: 2.3s
Precision: binary64
\[\frac{2}{e^{x} + e^{-x}} \]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(0.5 \cdot \frac{2}{\cosh x}\right)\right) \]
\frac{2}{e^{x} + e^{-x}}
\mathsf{log1p}\left(\mathsf{expm1}\left(0.5 \cdot \frac{2}{\cosh x}\right)\right)
(FPCore (x) :precision binary64 (/ 2.0 (+ (exp x) (exp (- x)))))
(FPCore (x) :precision binary64 (log1p (expm1 (* 0.5 (/ 2.0 (cosh x))))))
double code(double x) {
	return 2.0 / (exp(x) + exp(-x));
}
double code(double x) {
	return log1p(expm1(0.5 * (2.0 / cosh(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. Applied log1p-expm1-u_binary640.0

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{2}{e^{x} + e^{-x}}\right)\right)} \]
  3. Applied cosh-undef_binary640.0

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{2}{\color{blue}{2 \cdot \cosh x}}\right)\right) \]
  4. Applied *-un-lft-identity_binary640.0

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\color{blue}{1 \cdot 2}}{2 \cdot \cosh x}\right)\right) \]
  5. Applied times-frac_binary640.0

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{1}{2} \cdot \frac{2}{\cosh x}}\right)\right) \]
  6. Simplified0.0

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{0.5} \cdot \frac{2}{\cosh x}\right)\right) \]
  7. Final simplification0.0

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(0.5 \cdot \frac{2}{\cosh x}\right)\right) \]

Reproduce

herbie shell --seed 2022068 
(FPCore (x)
  :name "Hyperbolic secant"
  :precision binary64
  (/ 2.0 (+ (exp x) (exp (- x)))))