The tanh (hyperbolic tangent) function maps any real valued number in a range between -1 and 1. Similar to the sigmoid, its shape is a continuous “S” but it is centered over 0. It is commonly used in hidden layers of shallow neural networks and RNNs, since it helps them converge faster during training allowing both positive and negative values, and preventing the vanishing gradient problem.
$$tanh(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}$$