numerically stable tanh