In PHP, tanh() returns the hyperbolic tangent of a number.
The hyperbolic tangent is sinh(x) divided by cosh(x). It squeezes any number into the range -1 to 1, which is why it is popular in machine learning.
Syntax
Call tanh() with the values you need. Start with this line.
PHP
$result = tanh(1);
Call
What it does
tanh(0)
Returns 0.
tanh(1)
Returns about 0.7616.
tanh(-1)
Returns about -0.7616.
tanh() output always stays between -1 and 1. Large positive inputs get very close to 1, and large negative inputs get very close to -1. The inverse function is atanh().
Library declarations
PHP
tanh(float $num): float
Parameters
Parameter
Description
num
Required. The number to calculate the hyperbolic tangent for.