Average Error: 58.0 → 0.0
Time: 4.4s
Precision: binary64
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}} \]
\[\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\tanh x\right)\right)\right)\right) \]
(FPCore (x)
 :precision binary64
 (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))
(FPCore (x) :precision binary64 (expm1 (log1p (expm1 (log1p (tanh x))))))
double code(double x) {
	return (exp(x) - exp(-x)) / (exp(x) + exp(-x));
}
double code(double x) {
	return expm1(log1p(expm1(log1p(tanh(x)))));
}
public static double code(double x) {
	return (Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x));
}
public static double code(double x) {
	return Math.expm1(Math.log1p(Math.expm1(Math.log1p(Math.tanh(x)))));
}
def code(x):
	return (math.exp(x) - math.exp(-x)) / (math.exp(x) + math.exp(-x))
def code(x):
	return math.expm1(math.log1p(math.expm1(math.log1p(math.tanh(x)))))
function code(x)
	return Float64(Float64(exp(x) - exp(Float64(-x))) / Float64(exp(x) + exp(Float64(-x))))
end
function code(x)
	return expm1(log1p(expm1(log1p(tanh(x)))))
end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(Exp[N[Log[1 + N[(Exp[N[Log[1 + N[Tanh[x], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]
\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\tanh x\right)\right)\right)\right)

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.0

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}} \]
  2. Applied egg-rr0.0

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tanh x\right)\right)} \]
  3. Applied egg-rr0.0

    \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tanh x\right)\right)}\right)\right) \]
  4. Final simplification0.0

    \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\tanh x\right)\right)\right)\right) \]

Reproduce

herbie shell --seed 2022151 
(FPCore (x)
  :name "Hyperbolic tangent"
  :precision binary64
  (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))