Average Error: 0.0 → 0.2
Time: 1.1s
Precision: binary64
\[\frac{2}{e^{x} + e^{-x}} \]
\[\log \left(e^{e^{-\log \cosh x}}\right) \]
(FPCore (x) :precision binary64 (/ 2.0 (+ (exp x) (exp (- x)))))
(FPCore (x) :precision binary64 (log (exp (exp (- (log (cosh x)))))))
double code(double x) {
	return 2.0 / (exp(x) + exp(-x));
}
double code(double x) {
	return log(exp(exp(-log(cosh(x)))));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 2.0d0 / (exp(x) + exp(-x))
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = log(exp(exp(-log(cosh(x)))))
end function
public static double code(double x) {
	return 2.0 / (Math.exp(x) + Math.exp(-x));
}
public static double code(double x) {
	return Math.log(Math.exp(Math.exp(-Math.log(Math.cosh(x)))));
}
def code(x):
	return 2.0 / (math.exp(x) + math.exp(-x))
def code(x):
	return math.log(math.exp(math.exp(-math.log(math.cosh(x)))))
function code(x)
	return Float64(2.0 / Float64(exp(x) + exp(Float64(-x))))
end
function code(x)
	return log(exp(exp(Float64(-log(cosh(x))))))
end
function tmp = code(x)
	tmp = 2.0 / (exp(x) + exp(-x));
end
function tmp = code(x)
	tmp = log(exp(exp(-log(cosh(x)))));
end
code[x_] := N[(2.0 / N[(N[Exp[x], $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[Log[N[Exp[N[Exp[(-N[Log[N[Cosh[x], $MachinePrecision]], $MachinePrecision])], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\frac{2}{e^{x} + e^{-x}}
\log \left(e^{e^{-\log \cosh x}}\right)

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 egg-rr0.2

    \[\leadsto \color{blue}{\log \left(e^{\frac{2}{2 \cdot \cosh x}}\right)} \]
  3. Applied egg-rr0.2

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

    \[\leadsto \log \left(e^{e^{-\log \cosh x}}\right) \]

Reproduce

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