Average Error: 0.0 → 0.0
Time: 1.6s
Precision: binary64
\[\frac{2}{e^{x} + e^{-x}} \]
\[e^{\log \left(e^{-\log \cosh x}\right)} \]
(FPCore (x) :precision binary64 (/ 2.0 (+ (exp x) (exp (- x)))))
(FPCore (x) :precision binary64 (exp (log (exp (- (log (cosh x)))))))
double code(double x) {
	return 2.0 / (exp(x) + exp(-x));
}
double code(double x) {
	return exp(log(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 = exp(log(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.exp(Math.log(Math.exp(-Math.log(Math.cosh(x)))));
}
def code(x):
	return 2.0 / (math.exp(x) + math.exp(-x))
def code(x):
	return math.exp(math.log(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 exp(log(exp(Float64(-log(cosh(x))))))
end
function tmp = code(x)
	tmp = 2.0 / (exp(x) + exp(-x));
end
function tmp = code(x)
	tmp = exp(log(exp(-log(cosh(x)))));
end
code[x_] := N[(2.0 / N[(N[Exp[x], $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[Exp[N[Log[N[Exp[(-N[Log[N[Cosh[x], $MachinePrecision]], $MachinePrecision])], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\frac{2}{e^{x} + e^{-x}}
e^{\log \left(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.0

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

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

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

Reproduce

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